]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
gettext-tools: Implement 'installcheck' target.
authorBruno Haible <bruno@clisp.org>
Thu, 19 Jun 2025 09:49:30 +0000 (11:49 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 19 Jun 2025 09:51:30 +0000 (11:51 +0200)
* gettext-tools/install-tests/test-version.c: New file.
* gettext-tools/install-tests/test-api.c: New file.
* gettext-tools/install-tests/de.po: New file.
* gettext-tools/install-tests/Makefile.am: New file.
* gettext-tools/configure.ac (PATH_SEPARATOR, AUGMENT_SHLIBPATH): New variables.
(AC_CONFIG_FILES): Add install-tests/Makefile.
* gettext-tools/Makefile.am (SUBDIRS): Add install-tests.

gettext-tools/Makefile.am
gettext-tools/configure.ac
gettext-tools/install-tests/Makefile.am [new file with mode: 0644]
gettext-tools/install-tests/de.po [new file with mode: 0644]
gettext-tools/install-tests/test-api.c [new file with mode: 0644]
gettext-tools/install-tests/test-version.c [new file with mode: 0644]

index 6d63c6a33f77414f105a5a73d79014a2a12c7959..bafc917f48ed29fa94a0089646256fe26e04dd2d 100644 (file)
@@ -19,7 +19,7 @@
 AUTOMAKE_OPTIONS = 1.5 gnu
 ACLOCAL_AMFLAGS = -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4 -I tests/gnulib-m4
 
-SUBDIRS = gnulib-lib libgrep src libgettextpo po its projects styles emacs misc man m4 tests system-tests gnulib-tests examples doc
+SUBDIRS = gnulib-lib libgrep src libgettextpo po its projects styles emacs misc man m4 tests system-tests gnulib-tests install-tests examples doc
 
 EXTRA_DIST = misc/disclaim-translations.txt
 MOSTLYCLEANFILES = core *.stackdump
index 3d327258d0808988daff7a152ecab024a0420df9..94f6434f18ecc9df907fca36842fcf8a237de270 100644 (file)
@@ -694,6 +694,20 @@ dnl Checks for optional programs for the its/* tests.
 AC_PATH_PROGS([XMLLINT], [xmllint], [:])
 AC_SUBST([HAVE_JAVAEXEC])
 
+dnl Test for features used in install-tests.
+dnl shlibpath_var and PATH_SEPARATOR are set by LT_INIT.
+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([examples])
 
 AC_CONFIG_FILES([Makefile],
@@ -740,6 +754,8 @@ AC_CONFIG_FILES([system-tests/Makefile])
 
 AC_CONFIG_FILES([gnulib-tests/Makefile])
 
+AC_CONFIG_FILES([install-tests/Makefile])
+
 AC_CONFIG_FILES([build-aux/xml-validate-10],
                 [chmod a+x build-aux/xml-validate-10])
 AC_CONFIG_FILES([build-aux/xml-validate-11],
diff --git a/gettext-tools/install-tests/Makefile.am b/gettext-tools/install-tests/Makefile.am
new file mode 100644 (file)
index 0000000..3228403
--- /dev/null
@@ -0,0 +1,40 @@
+## Makefile for gettext-tools/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 -lgettextpo
+       @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 -lgettextpo
+       @AUGMENT_SHLIBPATH@ ./test-api
+       rm -rf test-api test-api$(EXEEXT)
+       PATH='$(bindir)'@PATH_SEPARATOR@"$$PATH"; xgettext --version | grep 'GNU gettext' > /dev/null
+
+EXTRA_DIST = \
+  test-version.c \
+  test-api.c de.po
+CLEANFILES = \
+  test-version test-version$(EXEEXT) \
+  test-api test-api$(EXEEXT)
diff --git a/gettext-tools/install-tests/de.po b/gettext-tools/install-tests/de.po
new file mode 100644 (file)
index 0000000..742f86d
--- /dev/null
@@ -0,0 +1,20 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: GNU gettext-tools 0.25-pre1\n"
+"Report-Msgid-Bugs-To: bug-gettext@gnu.org\n"
+"POT-Creation-Date: 2025-05-04 18:44+0200\n"
+"PO-Revision-Date: 2025-04-28 17:12+0200\n"
+"Last-Translator: Mario Blättermann <mario.blaettermann@gmail.com>\n"
+"Language-Team: German <translation-team-de@lists.sourceforge.net>\n"
+"Language: de\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: src/msgcmp.c:561 src/msgfmt.c:799 src/msgfmt.c:1643 src/xgettext.c:1111
+#, c-format
+msgid "found %d fatal error"
+msgid_plural "found %d fatal errors"
+msgstr[0] "es ist %d fataler Fehler aufgetreten"
+msgstr[1] "es sind %d fatale Fehler aufgetreten"
diff --git a/gettext-tools/install-tests/test-api.c b/gettext-tools/install-tests/test-api.c
new file mode 100644 (file)
index 0000000..6afcc69
--- /dev/null
@@ -0,0 +1,137 @@
+/* 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 <gettext-po.h>
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+static void
+xerror (int severity,
+        po_message_t message,
+        const char *filename, size_t lineno, size_t column,
+        int multiline_p, const char *message_text)
+{
+  fprintf (stderr, "%s\n", message_text);
+}
+
+static void
+xerror2 (int severity,
+         po_message_t message1,
+         const char *filename1, size_t lineno1, size_t column1,
+         int multiline_p1, const char *message_text1,
+         po_message_t message2,
+         const char *filename2, size_t lineno2, size_t column2,
+         int multiline_p2, const char *message_text2)
+{
+  fprintf (stderr, "%s...\n", message_text1);
+  fprintf (stderr, "...%s\n", message_text2);
+}
+
+struct po_xerror_handler handler =
+{
+  xerror,
+  xerror2
+};
+
+int
+main ()
+{
+  po_file_t file = po_file_read (SRCDIR "de.po", &handler);
+  assert (file != NULL);
+
+  const char * const * domains = po_file_domains (file);
+  assert (domains != NULL);
+  assert (domains[0] != NULL);
+  assert (strcmp (domains[0], "messages") == 0);
+  assert (domains[1] == NULL);
+
+  const char *domain = domains[0];
+
+  const char *header = po_file_domain_header (file, domain);
+  assert (header != NULL);
+  {
+    char *field = po_header_field (header, "Language");
+    assert (field != NULL);
+    assert (strcmp (field, "de") == 0);
+    free (field);
+  }
+  {
+    char *field = po_header_field (header, "X-Generator");
+    assert (field == NULL);
+  }
+
+  {
+    po_message_iterator_t iter = po_message_iterator (file, domain);
+    int min, max;
+
+    {
+      po_message_t message = po_next_message (iter);
+      assert (message != NULL);
+      assert (strcmp (po_message_msgid (message), "") == 0);
+      assert (po_message_msgid_plural (message) == NULL);
+      assert (!po_message_is_obsolete (message));
+      assert (!po_message_is_fuzzy (message));
+      assert (!po_message_is_format (message, "c-format"));
+      assert (!po_message_is_format (message, "python-format"));
+      assert (!po_message_is_range (message, &min, &max));
+      assert (po_message_filepos (message, 0) == NULL);
+    }
+    {
+      po_message_t message = po_next_message (iter);
+      assert (message != NULL);
+      assert (strcmp (po_message_msgid (message), "found %d fatal error") == 0);
+      assert (strcmp (po_message_msgid_plural (message), "found %d fatal errors") == 0);
+      assert (!po_message_is_obsolete (message));
+      assert (!po_message_is_fuzzy (message));
+      assert (po_message_is_format (message, "c-format"));
+      assert (!po_message_is_format (message, "python-format"));
+      assert (!po_message_is_range (message, &min, &max));
+      {
+        po_filepos_t pos;
+        pos = po_message_filepos (message, 0);
+        assert (pos != NULL);
+        assert (strcmp (po_filepos_file (pos), "src/msgcmp.c") == 0);
+        assert (po_filepos_start_line (pos) == 561);
+        pos = po_message_filepos (message, 1);
+        assert (pos != NULL);
+        assert (strcmp (po_filepos_file (pos), "src/msgfmt.c") == 0);
+        assert (po_filepos_start_line (pos) == 799);
+        pos = po_message_filepos (message, 2);
+        assert (pos != NULL);
+        assert (strcmp (po_filepos_file (pos), "src/msgfmt.c") == 0);
+        assert (po_filepos_start_line (pos) == 1643);
+        pos = po_message_filepos (message, 3);
+        assert (pos != NULL);
+        assert (strcmp (po_filepos_file (pos), "src/xgettext.c") == 0);
+        assert (po_filepos_start_line (pos) == 1111);
+        pos = po_message_filepos (message, 4);
+        assert (pos == NULL);
+      }
+    }
+    {
+      po_message_t message = po_next_message (iter);
+      assert (message == NULL);
+    }
+  }
+
+  po_file_free (file);
+
+  return 0;
+}
diff --git a/gettext-tools/install-tests/test-version.c b/gettext-tools/install-tests/test-version.c
new file mode 100644 (file)
index 0000000..77c5323
--- /dev/null
@@ -0,0 +1,33 @@
+/* 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 <gettext-po.h>
+
+#include <stdio.h>
+
+int
+main ()
+{
+  if (!(libgettextpo_version == LIBGETTEXTPO_VERSION))
+    {
+      fprintf (stderr, "Installation problem: include file says version 0x%x, whereas library says version 0x%x\n",
+               LIBGETTEXTPO_VERSION, libgettextpo_version);
+      return 1;
+    }
+  return 0;
+}