]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
gettext-runtime: Implement 'installcheck' target.
authorBruno Haible <bruno@clisp.org>
Thu, 19 Jun 2025 09:46:19 +0000 (11:46 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 19 Jun 2025 09:49:05 +0000 (11:49 +0200)
* gettext-runtime/install-tests/test-version.c: New file.
* gettext-runtime/install-tests/test-api.c: New file.
* gettext-runtime/install-tests/itest.pot: New file.
* gettext-runtime/install-tests/locale/en_US/LC_MESSAGES/itest.mo: New file.
* gettext-runtime/install-tests/Makefile.am: New file.
* gettext-runtime/configure.ac (INSTALLED_LIBINTL, PATH_SEPARATOR,
AUGMENT_SHLIBPATH): New variables.
(AC_CONFIG_FILES): Add install-tests/Makefile.
* gettext-runtime/Makefile.am (SUBDIRS): Add install-tests.

gettext-runtime/Makefile.am
gettext-runtime/configure.ac
gettext-runtime/install-tests/Makefile.am [new file with mode: 0644]
gettext-runtime/install-tests/itest.pot [new file with mode: 0644]
gettext-runtime/install-tests/locale/en_US/LC_MESSAGES/itest.mo [new file with mode: 0644]
gettext-runtime/install-tests/test-api.c [new file with mode: 0644]
gettext-runtime/install-tests/test-version.c [new file with mode: 0644]

index 542f8c490f95443bf16ce6ab4c789c0c82ad9e3b..86c0ea754e3c0c002d297e2026ec50c9f37b4cdc 100644 (file)
@@ -26,7 +26,7 @@ SUBDIR_libasprintf = libasprintf
 else
 SUBDIR_libasprintf =
 endif
-SUBDIRS = doc intl intl-java intl-csharp intl-d intl-modula2 gnulib-lib $(SUBDIR_libasprintf) src po man m4 tests
+SUBDIRS = doc intl intl-java intl-csharp intl-d intl-modula2 gnulib-lib $(SUBDIR_libasprintf) src po man m4 tests install-tests
 
 EXTRA_DIST = BUGS
 
index 9d2b6060c8b7f7cdcb7f04ae4f512fd01a785146..c4119f8cd66dadafe0570a4703d51a554d4bc370 100644 (file)
@@ -238,6 +238,26 @@ dnl Determine variables used by uninstalled-config.sh.
 ENABLE_SHARED="$enable_shared"
 AC_SUBST([ENABLE_SHARED])
 
+dnl Test for features used in install-tests.
+dnl shlibpath_var and PATH_SEPARATOR are set by LT_INIT.
+if test $USE_INCLUDED_LIBINTL = yes; then
+  INSTALLED_LIBINTL="-lintl $INTL_MACOSX_LIBS"
+else
+  INSTALLED_LIBINTL=
+fi
+AC_SUBST([INSTALLED_LIBINTL])
+AC_SUBST([PATH_SEPARATOR])
+if test -n "${shlibpath_var}"; then
+  if test "${shlibpath_var}" = PATH; then
+    AUGMENT_SHLIBPATH="PATH='\$(bindir)'${PATH_SEPARATOR}\"\$\$PATH\";"
+  else
+    AUGMENT_SHLIBPATH="${shlibpath_var}='\$(libdir)':\"\$\$${shlibpath_var}\"; export ${shlibpath_var};"
+  fi
+else
+  AUGMENT_SHLIBPATH=
+fi
+AC_SUBST([AUGMENT_SHLIBPATH])
+
 AC_CONFIG_SUBDIRS([intl])
 
 AC_CONFIG_SUBDIRS([libasprintf])
@@ -271,4 +291,6 @@ AC_CONFIG_FILES([m4/Makefile])
 
 AC_CONFIG_FILES([tests/Makefile])
 
+AC_CONFIG_FILES([install-tests/Makefile])
+
 AC_OUTPUT
diff --git a/gettext-runtime/install-tests/Makefile.am b/gettext-runtime/install-tests/Makefile.am
new file mode 100644 (file)
index 0000000..a05ddd4
--- /dev/null
@@ -0,0 +1,40 @@
+## Makefile for gettext-runtime/install-tests.
+## Copyright (C) 2025 Free Software Foundation, Inc.
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+## Process this file with automake to produce Makefile.in.
+
+installcheck-local:
+       $(CC) -I$(includedir) -L$(libdir) \
+             $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+             $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
+             -o test-version $(srcdir)/test-version.c $(INSTALLED_LIBINTL)
+       @AUGMENT_SHLIBPATH@ ./test-version
+       rm -rf test-version test-version$(EXEEXT)
+       $(CC) -I$(includedir) -L$(libdir) \
+             $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+             -DSRCDIR=\"$(srcdir)/\" \
+             $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
+             -o test-api $(srcdir)/test-api.c $(INSTALLED_LIBINTL)
+       @AUGMENT_SHLIBPATH@ ./test-api
+       rm -rf test-api test-api$(EXEEXT)
+       PATH='$(bindir)'@PATH_SEPARATOR@"$$PATH"; gettext --version | grep 'GNU gettext' > /dev/null
+
+EXTRA_DIST = \
+  test-version.c \
+  test-api.c locale/en_US/LC_MESSAGES/itest.mo
+CLEANFILES = \
+  test-version test-version$(EXEEXT) \
+  test-api test-api$(EXEEXT)
diff --git a/gettext-runtime/install-tests/itest.pot b/gettext-runtime/install-tests/itest.pot
new file mode 100644 (file)
index 0000000..1e40476
--- /dev/null
@@ -0,0 +1,22 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR Free Software Foundation, Inc.
+# This file is distributed under the same license as the GNU gettext package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: GNU gettext 0.25\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2025-06-18 20:12+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: test-api.c:68
+msgid "She is the doppelganger of my fiancee."
+msgstr ""
diff --git a/gettext-runtime/install-tests/locale/en_US/LC_MESSAGES/itest.mo b/gettext-runtime/install-tests/locale/en_US/LC_MESSAGES/itest.mo
new file mode 100644 (file)
index 0000000..8707c3c
Binary files /dev/null and b/gettext-runtime/install-tests/locale/en_US/LC_MESSAGES/itest.mo differ
diff --git a/gettext-runtime/install-tests/test-api.c b/gettext-runtime/install-tests/test-api.c
new file mode 100644 (file)
index 0000000..16c7df1
--- /dev/null
@@ -0,0 +1,78 @@
+/* Test parts of the API.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2025.  */
+
+#include <libintl.h>
+
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if defined _WIN32 && !defined __CYGWIN__
+
+# define ENGLISH  "English_United States"
+# define ENCODING ".1252"
+
+# define LOCALE1 ENGLISH ENCODING
+
+#else
+
+# define LOCALE1 "en_US.UTF-8"
+
+#endif
+
+int
+main ()
+{
+  /* Clean up environment.  */
+#if defined _WIN32 && !defined __CYGWIN__
+  _putenv ("LANGUAGE=");
+  _putenv ("OUTPUT_CHARSET=");
+#else
+  unsetenv ("LANGUAGE");
+  unsetenv ("OUTPUT_CHARSET");
+#endif
+
+  textdomain ("itest");
+
+#if defined _WIN32 && !defined __CYGWIN__
+  _putenv ("LC_ALL=" LOCALE1);
+#else
+  setenv ("LC_ALL", LOCALE1, 1);
+#endif
+  if (setlocale (LC_ALL, "") == NULL)
+    {
+      fprintf (stderr, "Skipping test: Locale %s is not installed.\n", LOCALE1);
+      return 0;
+    }
+
+  bindtextdomain ("itest", SRCDIR "locale");
+
+  bind_textdomain_codeset ("itest", "UTF-8");
+
+  const char *s = gettext ("She is the doppelganger of my fiancee.");
+  const char *expected = "She is the doppelgänger of my fiancĂ©e.";
+  if (strcmp (s, expected) != 0)
+    {
+      fprintf (stderr, "gettext() => %s\n", s);
+      fprintf (stderr, "Expected:    %s\n", expected);
+      return 1;
+    }
+
+  return 0;
+}
diff --git a/gettext-runtime/install-tests/test-version.c b/gettext-runtime/install-tests/test-version.c
new file mode 100644 (file)
index 0000000..c2f9c8b
--- /dev/null
@@ -0,0 +1,36 @@
+/* Test the version information.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2025.  */
+
+#include <libintl.h>
+
+#include <stdio.h>
+
+int
+main ()
+{
+#if defined LIBINTL_VERSION /* GNU libintl, not GNU libc */
+  if (!(libintl_version == LIBINTL_VERSION))
+    {
+      fprintf (stderr, "Installation problem: include file says version 0x%x, whereas library says version 0x%x\n",
+               LIBINTL_VERSION, libintl_version);
+      return 1;
+    }
+#endif
+
+  return 0;
+}