From: Bruno Haible Date: Thu, 19 Jun 2025 09:49:30 +0000 (+0200) Subject: gettext-tools: Implement 'installcheck' target. X-Git-Tag: v0.26~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb587aa2a90a9be1881350aab0711b42cac77853;p=thirdparty%2Fgettext.git gettext-tools: Implement 'installcheck' target. * 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. --- diff --git a/gettext-tools/Makefile.am b/gettext-tools/Makefile.am index 6d63c6a33..bafc917f4 100644 --- a/gettext-tools/Makefile.am +++ b/gettext-tools/Makefile.am @@ -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 diff --git a/gettext-tools/configure.ac b/gettext-tools/configure.ac index 3d327258d..94f6434f1 100644 --- a/gettext-tools/configure.ac +++ b/gettext-tools/configure.ac @@ -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 index 000000000..322840347 --- /dev/null +++ b/gettext-tools/install-tests/Makefile.am @@ -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 . + +## 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 index 000000000..742f86dc9 --- /dev/null +++ b/gettext-tools/install-tests/de.po @@ -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 \n" +"Language-Team: German \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 index 000000000..6afcc697e --- /dev/null +++ b/gettext-tools/install-tests/test-api.c @@ -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 . */ + +/* Written by Bruno Haible , 2025. */ + +#include + +#include +#include +#include + +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 index 000000000..77c5323be --- /dev/null +++ b/gettext-tools/install-tests/test-version.c @@ -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 . */ + +/* Written by Bruno Haible , 2025. */ + +#include + +#include + +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; +}