From: Bruno Haible Date: Sun, 5 Sep 2010 23:16:56 +0000 (+0200) Subject: Internationalization tests. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45c45ae4ee5a4a60768a755bc66e707463de8d42;p=thirdparty%2Fautomake.git Internationalization tests. * tests/pot-macro-warn.test: New file. * tests/pot-enable1.test: New file. * tests/pot-enable2.test: New file. * tests/pot-warn1.test: New file. * tests/pot-warn2.test: New file. * tests/pot-empty.test: New file. * tests/pot-no-linguas.test: New file. * tests/pot-linguas.test: New file. * tests/pot-noinst.test: New file. * tests/pot-topsrcdir.test: New file. * tests/pot-samedir.test: New file. * tests/pot-override1.test: New file. * tests/pot-copyright.test: New file. * tests/pot-msgidbugs.test: New file. * tests/pot-xgettext1.test: New file. * tests/pot-xgettext2.test: New file. * tests/pot-xgettext3.test: New file. * tests/pot-xgettext4.test: New file. * tests/pot-download1.test: New file. * tests/pot-format-qt1.test: New file. * tests/pot-format-java1.test: New file. * tests/pot-format-java2.test: New file. * tests/pot-format-csharp1.test: New file. * tests/pot-format-tcl1.test: New file. --- diff --git a/ChangeLog b/ChangeLog index ae920796b..a21b60af3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2010-09-05 Bruno Haible + + Internationalization tests. + * tests/pot-macro-warn.test: New file. + * tests/pot-enable1.test: New file. + * tests/pot-enable2.test: New file. + * tests/pot-warn1.test: New file. + * tests/pot-warn2.test: New file. + * tests/pot-empty.test: New file. + * tests/pot-no-linguas.test: New file. + * tests/pot-linguas.test: New file. + * tests/pot-noinst.test: New file. + * tests/pot-topsrcdir.test: New file. + * tests/pot-samedir.test: New file. + * tests/pot-override1.test: New file. + * tests/pot-copyright.test: New file. + * tests/pot-msgidbugs.test: New file. + * tests/pot-xgettext1.test: New file. + * tests/pot-xgettext2.test: New file. + * tests/pot-xgettext3.test: New file. + * tests/pot-xgettext4.test: New file. + * tests/pot-download1.test: New file. + * tests/pot-format-qt1.test: New file. + * tests/pot-format-java1.test: New file. + * tests/pot-format-java2.test: New file. + * tests/pot-format-csharp1.test: New file. + * tests/pot-format-tcl1.test: New file. + 2010-08-29 Bruno Haible Internationalization documentation changes. diff --git a/tests/pot-copyright.test b/tests/pot-copyright.test new file mode 100644 index 000000000..e4f9ff2e5 --- /dev/null +++ b/tests/pot-copyright.test @@ -0,0 +1,106 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that when a _COPYRIGHT_HOLDER variable is specified, the POT +# file's header contains the copyright holder. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/main.c +posub_foo_bar_pot_COPYRIGHT_HOLDER = Yoyodyne, Inc. +EXTRA_DIST = src/main.c +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/main.c << 'END' +#include +int main () +{ + printf (gettext ("Hello, world.\n")); + return 0; +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Yoyodyne, Inc. +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-copyright 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/main.c:4 +#, c-format +msgid "Hello, world.\n" +msgstr "" +END + +for builddir in . sub; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + $sourcedir/configure --prefix="$instdir" + make + + # Check that "make dist" creates the expected .pot file. + # (It is created under $sourcedir, because the .pot file is distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir +done diff --git a/tests/pot-download1.test b/tests/pot-download1.test new file mode 100644 index 000000000..a70845ba8 --- /dev/null +++ b/tests/pot-download1.test @@ -0,0 +1,82 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check the download of translations from the Translation Project. + +required='gzip' +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = clisp.pot +posub_foo_bar_pot_SOURCES = spvw.c +clisp_pot_TP_URL = http://translationproject.org/latest/ +EXTRA_DIST = spvw.c +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +cat > spvw.c << 'END' +#include +#include "gettext.h" +int main () +{ + puts (gettext ("*** - Program stack overflow. RESET")); + return 0; +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +for builddir in . sub; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + LINGUAS="de" $sourcedir/configure --prefix="$instdir" + make + + # Check that after "make install", a German translation has been installed. + make install + test -f "$instdir"/share/locale/de/LC_MESSAGES/clisp.mo + + # Check that after "make dist", the tarball does not include the German + # translation. + make dist + gzip -d -c < pot-download1-1.0.tar.gz | tar tf - > filelist + if grep '^pot-download1-1\.0/clisp-de\.po$' filelist >/dev/null; then + exit 1 + fi + rm -f filelist + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir +done diff --git a/tests/pot-empty.test b/tests/pot-empty.test new file mode 100644 index 000000000..09bca2bc1 --- /dev/null +++ b/tests/pot-empty.test @@ -0,0 +1,81 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that when the package contains no internationalized strings, +# no POT file is created (because it would unnecessarily disturb the +# translators to ask them to translate an empty file). + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/main.c +EXTRA_DIST = src/main.c +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/main.c << 'END' +#include +int main () +{ + printf ("Hello, world.\n"); + return 0; +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +for builddir in . sub; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + $sourcedir/configure --prefix="$instdir" + make + make dist + + # Check that no .pot file was created. + test ! -f posub/foo-bar.pot + + make install + + # Check that still, no .pot file was created. + test ! -f posub/foo-bar.pot + + # Check that no .mo file was installed, not even its directory was created. + test ! -d "$instdir"/share/locale/de/LC_MESSAGES + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir +done diff --git a/tests/pot-enable1.test b/tests/pot-enable1.test new file mode 100644 index 000000000..77b154da3 --- /dev/null +++ b/tests/pot-enable1.test @@ -0,0 +1,52 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that when the AM_POT_TOOLS macro is used, the --enable-nls and +# --disable-nls options determine the value of USE_NLS, and +# --help advertises --disable-nls. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +check-USE_NLS-yes: + test "@USE_NLS@" = yes +check-USE_NLS-no: + test "@USE_NLS@" = no +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +# Check that the --help output advertises --disable-nls. +./configure --help | grep ' --disable-nls ' >/dev/null + +# Check that --enable-nls causes USE_NLS to be yes. +./configure --enable-nls +make check-USE_NLS-yes + +make distclean + +# Check that --disable-nls causes USE_NLS to be no. +./configure --disable-nls +make check-USE_NLS-no diff --git a/tests/pot-enable2.test b/tests/pot-enable2.test new file mode 100644 index 000000000..02bde5be4 --- /dev/null +++ b/tests/pot-enable2.test @@ -0,0 +1,52 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that when the AM_NLS macro is used, the --enable-nls and +# --disable-nls options determine the value of USE_NLS, and +# --help advertises --disable-nls. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +check-USE_NLS-yes: + test "@USE_NLS@" = yes +check-USE_NLS-no: + test "@USE_NLS@" = no +END + +cat >> configure.in << 'END' +AM_NLS +AC_OUTPUT +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +# Check that the --help output advertises --disable-nls. +./configure --help | grep ' --disable-nls ' >/dev/null + +# Check that --enable-nls causes USE_NLS to be yes. +./configure --enable-nls +make check-USE_NLS-yes + +make distclean + +# Check that --disable-nls causes USE_NLS to be no. +./configure --disable-nls +make check-USE_NLS-no diff --git a/tests/pot-format-csharp1.test b/tests/pot-format-csharp1.test new file mode 100644 index 000000000..8c7f6c7d9 --- /dev/null +++ b/tests/pot-format-csharp1.test @@ -0,0 +1,223 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check the creation of compiled message catalogs in C# format. + +required='gzip' +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +pkglibdir = $(libdir)/$(PACKAGE) +pkglib_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/main.cs +posub_foo_bar_pot_LINGUAS = de fr_CA@latin +posub_foo_bar_pot_CATALOGFORMAT = resources.dll +EXTRA_DIST = src/main.cs +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/main.cs << 'END' +using System; /* String, Console */ +using GNU.Gettext; /* GettextResourceManager */ +public class Hello { + public static void Main (String[] args) { + GettextResourceManager catalog = + new GettextResourceManager("foo-bar"); + Console.WriteLine(catalog.GetString("Hello, world!")); + } +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +# .po files for _LINGUAS. +mkdir posub +cat > posub/foo-bar-de.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Hallo Welt!" +END +cat > posub/foo-bar-fr_CA@latin.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Salut, le monde!" +END + +# A .po file not listed among _LINGUAS, and a junk .resources.dll file. +cat > posub/foo-bar-es.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Adiós, mundo!" +END +mkdir posub/es +cat > posub/es/foo-bar.resources.dll << 'END' +junk +END + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-format-csharp1 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/main.cs:7 +msgid "Hello, world!" +msgstr "" +END + +for builddir in . sub; do + for config_options in '' 'LINGUAS="es de"'; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + env $config_options $sourcedir/configure --prefix="$instdir" + make + + # Check that "make install" creates the expected .pot file, .po files + # and .resources.dll files. + # (They are created under $sourcedir, because the files are distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make install + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/posub/foo-bar-de.po + test ! -f $sourcedir/posub/foo-bar-de.resources.dll + test -f $sourcedir/posub/de/foo-bar.resources.dll + test -f $sourcedir/posub/foo-bar-fr_CA@latin.po + test ! -f $sourcedir/posub/foo-bar-fr_CA@latin.resources.dll + test -f $sourcedir/posub/fr-CA-Latn/foo-bar.resources.dll + test ! -f $sourcedir/posub/foo-bar-de.mo + test ! -f $sourcedir/posub/foo-bar-fr_CA@latin.mo + + if test -z "$config_options"; then + # Check that "make install" installed de,po and fr_CA@latin.po but not es.po. + test -f "$instdir"/lib/pot-format-csharp1/de/foo-bar.resources.dll + test -f "$instdir"/lib/pot-format-csharp1/fr-CA-Latn/foo-bar.resources.dll + test ! -f "$instdir"/lib/pot-format-csharp1/es/foo-bar.resources.dll + else + # Check that "make install" installed de.po but not fr_CA@latin.po nor es.po. + test -f "$instdir"/lib/pot-format-csharp1/de/foo-bar.resources.dll + test ! -f "$instdir"/lib/pot-format-csharp1/fr-CA-Latn/foo-bar.resources.dll + test ! -f "$instdir"/lib/pot-format-csharp1/es/foo-bar.resources.dll + fi + test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.resources.dll + test ! -f "$instdir"/share/locale/fr_CA@latin/LC_MESSAGES/foo-bar.resources.dll + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.resources.dll + test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/fr_CA@latin/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo + + # Check that "make dist" creates the expected .pot file. + + rm -f $sourcedir/posub/foo-bar.pot + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/posub/foo-bar-de.po + test ! -f $sourcedir/posub/foo-bar-de.resources.dll + test -f $sourcedir/posub/de/foo-bar.resources.dll + test -f $sourcedir/posub/foo-bar-fr_CA@latin.po + test ! -f $sourcedir/posub/foo-bar-fr_CA@latin.resources.dll + test -f $sourcedir/posub/fr-CA-Latn/foo-bar.resources.dll + test ! -f $sourcedir/posub/foo-bar-de.mo + test ! -f $sourcedir/posub/foo-bar-fr_CA@latin.mo + + # Check that the tarball contains posub/foo-bar-{de,fr}.{po,resources.dll} + # but not the others, regardless whether LINGUAS was specified or not. + gzip -d -c < pot-format-csharp1-1.0.tar.gz | tar tf - > filelist + grep '^pot-format-csharp1-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null + grep '^pot-format-csharp1-1\.0/posub/de/foo-bar\.resources.dll$' filelist >/dev/null + grep '^pot-format-csharp1-1\.0/posub/foo-bar-fr_CA@latin\.po$' filelist >/dev/null + grep '^pot-format-csharp1-1\.0/posub/fr-CA-Latn/foo-bar\.resources.dll$' filelist >/dev/null + if grep '^pot-format-csharp1-1\.0/posub/foo-bar-es\.po$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-csharp1-1\.0/posub/es/foo-bar\.resources.dll$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-csharp1-1\.0/posub/foo-bar-de\.mo$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-csharp1-1\.0/posub/foo-bar-fr_CA@latin\.mo$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-csharp1-1\.0/posub/foo-bar-es\.mo$' filelist >/dev/null; then + exit 1 + fi + rm -f filelist + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir + done +done diff --git a/tests/pot-format-java1.test b/tests/pot-format-java1.test new file mode 100644 index 000000000..6a9259b43 --- /dev/null +++ b/tests/pot-format-java1.test @@ -0,0 +1,224 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check the creation of compiled message catalogs in Java .properties format. +# FIXME: Resource names with a dash maybe don't work. If so, it should be +# mentioned in the documentation. + +required='gzip' +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +pkgresourcesdir = $(pkgdatadir)/resources +pkgresources_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/Hello.java +posub_foo_bar_pot_LINGUAS = de fr +posub_foo_bar_pot_CATALOGFORMAT = properties +EXTRA_DIST = src/Hello.java +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/Hello.java << 'END' +import java.util.*; +import gnu.gettext.*; + +public class Hello { + public static void main (String[] args) { + ResourceBundle catalog = ResourceBundle.getBundle("foo-bar"); + System.out.println(GettextResource.gettext(catalog,"Hello, world!")); + } +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +# .po files for _LINGUAS. +mkdir posub +cat > posub/foo-bar-de.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Hallo Welt!" +END +cat > posub/foo-bar-fr.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Salut, le monde!" +END + +# A .po file not listed among _LINGUAS, and a junk .properties file. +cat > posub/foo-bar-es.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Adiós, mundo!" +END +cat > posub/foo-bar-es.properties << 'END' +junk +END + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-format-java1 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/Hello.java:7 +msgid "Hello, world!" +msgstr "" +END + +for builddir in . sub; do + for config_options in '' 'LINGUAS="es de"'; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + env $config_options $sourcedir/configure --prefix="$instdir" + make + + # Check that "make install" creates the expected .pot file, .po files + # and .properties files. + # (They are created under $sourcedir, because the files are distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make install + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/posub/foo-bar-de.po + test ! -f $sourcedir/posub/foo-bar-de.properties + test -f $sourcedir/posub/foo-bar_de.properties + test -f $sourcedir/posub/foo-bar-fr.po + test ! -f $sourcedir/posub/foo-bar-fr.properties + test -f $sourcedir/posub/foo-bar_fr.properties + test ! -f $sourcedir/posub/foo-bar-de.mo + test ! -f $sourcedir/posub/foo-bar-fr.mo + + if test -z "$config_options"; then + # Check that "make install" installed de,po and fr.po but not es.po. + test -f "$instdir"/share/pot-format-java1/resources/foo-bar_de.properties + test -f "$instdir"/share/pot-format-java1/resources/foo-bar_fr.properties + test ! -f "$instdir"/share/pot-format-java1/resources/foo-bar_es.properties + else + # Check that "make install" installed de.po but not fr.po nor es.po. + test -f "$instdir"/share/pot-format-java1/resources/foo-bar_de.properties + test ! -f "$instdir"/share/pot-format-java1/resources/foo-bar_fr.properties + test ! -f "$instdir"/share/pot-format-java1/resources/foo-bar_es.properties + fi + test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.properties + test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.properties + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.properties + test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo + + # Check that "make dist" creates the expected .pot file. + + rm -f $sourcedir/posub/foo-bar.pot + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/posub/foo-bar-de.po + test ! -f $sourcedir/posub/foo-bar-de.properties + test -f $sourcedir/posub/foo-bar_de.properties + test -f $sourcedir/posub/foo-bar-fr.po + test ! -f $sourcedir/posub/foo-bar-fr.properties + test -f $sourcedir/posub/foo-bar_fr.properties + test ! -f $sourcedir/posub/foo-bar-de.mo + test ! -f $sourcedir/posub/foo-bar-fr.mo + + # Check that the tarball contains posub/foo-bar-{de,fr}.{po,properties} + # but not the others, regardless whether LINGUAS was specified or not. + gzip -d -c < pot-format-java1-1.0.tar.gz | tar tf - > filelist + grep '^pot-format-java1-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null + grep '^pot-format-java1-1\.0/posub/foo-bar_de\.properties$' filelist >/dev/null + grep '^pot-format-java1-1\.0/posub/foo-bar-fr\.po$' filelist >/dev/null + grep '^pot-format-java1-1\.0/posub/foo-bar_fr\.properties$' filelist >/dev/null + if grep '^pot-format-java1-1\.0/posub/foo-bar-es\.po$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-java1-1\.0/posub/foo-bar_es\.properties$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-java1-1\.0/posub/foo-bar-de\.mo$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-java1-1\.0/posub/foo-bar-fr\.mo$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-java1-1\.0/posub/foo-bar-es\.mo$' filelist >/dev/null; then + exit 1 + fi + rm -f filelist + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir + done +done diff --git a/tests/pot-format-java2.test b/tests/pot-format-java2.test new file mode 100644 index 000000000..e05d08ca7 --- /dev/null +++ b/tests/pot-format-java2.test @@ -0,0 +1,224 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check the creation of compiled message catalogs in Java .class format. +# FIXME: Class names with a dash probably don't work. If so, it should be +# mentioned in the documentation. + +required='gzip' +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +pkgresourcesdir = $(pkgdatadir)/resources +pkgresources_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/Hello.java +posub_foo_bar_pot_LINGUAS = de fr +posub_foo_bar_pot_CATALOGFORMAT = class +EXTRA_DIST = src/Hello.java +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/Hello.java << 'END' +import java.util.*; +import gnu.gettext.*; + +public class Hello { + public static void main (String[] args) { + ResourceBundle catalog = ResourceBundle.getBundle("foo-bar"); + System.out.println(GettextResource.gettext(catalog,"Hello, world!")); + } +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +# .po files for _LINGUAS. +mkdir posub +cat > posub/foo-bar-de.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Hallo Welt!" +END +cat > posub/foo-bar-fr.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Salut, le monde!" +END + +# A .po file not listed among _LINGUAS, and a junk .class file. +cat > posub/foo-bar-es.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Adiós, mundo!" +END +cat > posub/foo-bar-es.class << 'END' +junk +END + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-format-java2 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/Hello.java:7 +msgid "Hello, world!" +msgstr "" +END + +for builddir in . sub; do + for config_options in '' 'LINGUAS="es de"'; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + env $config_options $sourcedir/configure --prefix="$instdir" + make + + # Check that "make install" creates the expected .pot file, .po files + # and .class files. + # (They are created under $sourcedir, because the files are distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make install + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/posub/foo-bar-de.po + test ! -f $sourcedir/posub/foo-bar-de.class + test -f $sourcedir/posub/foo-bar_de.class + test -f $sourcedir/posub/foo-bar-fr.po + test ! -f $sourcedir/posub/foo-bar-fr.class + test -f $sourcedir/posub/foo-bar_fr.class + test ! -f $sourcedir/posub/foo-bar-de.mo + test ! -f $sourcedir/posub/foo-bar-fr.mo + + if test -z "$config_options"; then + # Check that "make install" installed de,po and fr.po but not es.po. + test -f "$instdir"/share/pot-format-java2/resources/foo-bar_de.class + test -f "$instdir"/share/pot-format-java2/resources/foo-bar_fr.class + test ! -f "$instdir"/share/pot-format-java2/resources/foo-bar_es.class + else + # Check that "make install" installed de.po but not fr.po nor es.po. + test -f "$instdir"/share/pot-format-java2/resources/foo-bar_de.class + test ! -f "$instdir"/share/pot-format-java2/resources/foo-bar_fr.class + test ! -f "$instdir"/share/pot-format-java2/resources/foo-bar_es.class + fi + test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.class + test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.class + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.class + test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo + + # Check that "make dist" creates the expected .pot file. + + rm -f $sourcedir/posub/foo-bar.pot + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/posub/foo-bar-de.po + test ! -f $sourcedir/posub/foo-bar-de.class + test -f $sourcedir/posub/foo-bar_de.class + test -f $sourcedir/posub/foo-bar-fr.po + test ! -f $sourcedir/posub/foo-bar-fr.class + test -f $sourcedir/posub/foo-bar_fr.class + test ! -f $sourcedir/posub/foo-bar-de.mo + test ! -f $sourcedir/posub/foo-bar-fr.mo + + # Check that the tarball contains posub/foo-bar-{de,fr}.{po,class} but not + # the others, regardless whether LINGUAS was specified or not. + gzip -d -c < pot-format-java2-1.0.tar.gz | tar tf - > filelist + grep '^pot-format-java2-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null + grep '^pot-format-java2-1\.0/posub/foo-bar_de\.class$' filelist >/dev/null + grep '^pot-format-java2-1\.0/posub/foo-bar-fr\.po$' filelist >/dev/null + grep '^pot-format-java2-1\.0/posub/foo-bar_fr\.class$' filelist >/dev/null + if grep '^pot-format-java2-1\.0/posub/foo-bar-es\.po$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-java2-1\.0/posub/foo-bar_es\.class$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-java2-1\.0/posub/foo-bar-de\.mo$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-java2-1\.0/posub/foo-bar-fr\.mo$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-java2-1\.0/posub/foo-bar-es\.mo$' filelist >/dev/null; then + exit 1 + fi + rm -f filelist + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir + done +done diff --git a/tests/pot-format-qt1.test b/tests/pot-format-qt1.test new file mode 100644 index 000000000..797a3472e --- /dev/null +++ b/tests/pot-format-qt1.test @@ -0,0 +1,244 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check the creation of compiled message catalogs in Qt format. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +pkglocaledir = $(pkgdatadir)/locale +pkglocale_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/main.cc +posub_foo_bar_pot_XGETTEXT_OPTIONS = \ + --qt \ + --keyword=translate:2 \ + --flag=translate:2:pass-c-format \ + --flag=translate:2:pass-qt-format \ + --keyword=_ \ + --flag=_:1:pass-c-format \ + --flag=_:1:pass-qt-format +posub_foo_bar_pot_LINGUAS = de fr +posub_foo_bar_pot_CATALOGFORMAT = qm +AM_CPPFLAGS = -DPKGLOCALEDIR=\"$(pkglocaledir)\" +EXTRA_DIST = src/main.cc +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/main.cc << 'END' +#include +#include +#include +#include +#include +#include + +int +main (int argc, char *argv[]) +{ + QApplication application (argc, argv); + QTranslator *translator = new QTranslator (NULL); + translator->load (QString ("foo-bar") + "_" + QTextCodec::locale(), + PKGLOCALEDIR); + application.installTranslator (translator); +#define _(string) application.translate ("", string) + QMainWindow *window = new QMainWindow (); + window->setCaption ("Hello example"); + QVBox *panel = new QVBox (window); + panel->setSpacing (2); + QLabel *label1 = new QLabel (_("Hello, world!"), panel); + panel->resize (panel->sizeHint ()); + window->resize (panel->frameSize ()); + application.setMainWidget (window); + window->show (); + return application.exec (); +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +# .po files for _LINGUAS. +mkdir posub +cat > posub/foo-bar-de.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Hallo Welt!" +END +cat > posub/foo-bar-fr.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Salut, le monde!" +END + +# A .po file not listed among _LINGUAS, and a junk .qm file. +cat > posub/foo-bar-es.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Adiós, mundo!" +END +cat > posub/foo-bar-es.qm << 'END' +junk +END + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-format-qt1 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/main.cc:21 +msgid "Hello, world!" +msgstr "" +END + +for builddir in . sub; do + for config_options in '' 'LINGUAS="es de"'; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + env $config_options $sourcedir/configure --prefix="$instdir" + make + + # Check that "make install" creates the expected .pot file, .po files + # and .qm files. + # (They are created under $sourcedir, because the files are distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make install + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/posub/foo-bar-de.po + test -f $sourcedir/posub/foo-bar-de.qm + test -f $sourcedir/posub/foo-bar-fr.po + test -f $sourcedir/posub/foo-bar-fr.qm + test ! -f $sourcedir/posub/foo-bar-de.mo + test ! -f $sourcedir/posub/foo-bar-fr.mo + + if test -z "$config_options"; then + # Check that "make install" installed de,po and fr.po but not es.po. + test -f "$instdir"/share/pot-format-qt1/locale/foo-bar_de.qm + test -f "$instdir"/share/pot-format-qt1/locale/foo-bar_fr.qm + test ! -f "$instdir"/share/pot-format-qt1/locale/foo-bar_es.qm + else + # Check that "make install" installed de.po but not fr.po nor es.po. + test -f "$instdir"/share/pot-format-qt1/locale/foo-bar_de.qm + test ! -f "$instdir"/share/pot-format-qt1/locale/foo-bar_fr.qm + test ! -f "$instdir"/share/pot-format-qt1/locale/foo-bar_es.qm + fi + test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.qm + test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.qm + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.qm + test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo + + # Check that "make dist" creates the expected .pot file. + + rm -f $sourcedir/posub/foo-bar.pot + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/posub/foo-bar-de.po + test -f $sourcedir/posub/foo-bar-de.qm + test -f $sourcedir/posub/foo-bar-fr.po + test -f $sourcedir/posub/foo-bar-fr.qm + test ! -f $sourcedir/posub/foo-bar-de.mo + test ! -f $sourcedir/posub/foo-bar-fr.mo + + # Check that the tarball contains posub/foo-bar-{de,fr}.{po,qm} but not + # the others, regardless whether LINGUAS was specified or not. + gzip -d -c < pot-format-qt1-1.0.tar.gz | tar tf - > filelist + grep '^pot-format-qt1-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null + grep '^pot-format-qt1-1\.0/posub/foo-bar-de\.qm$' filelist >/dev/null + grep '^pot-format-qt1-1\.0/posub/foo-bar-fr\.po$' filelist >/dev/null + grep '^pot-format-qt1-1\.0/posub/foo-bar-fr\.qm$' filelist >/dev/null + if grep '^pot-format-qt1-1\.0/posub/foo-bar-es\.po$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-qt1-1\.0/posub/foo-bar-es\.qm$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-qt1-1\.0/posub/foo-bar-de\.mo$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-qt1-1\.0/posub/foo-bar-fr\.mo$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-qt1-1\.0/posub/foo-bar-es\.mo$' filelist >/dev/null; then + exit 1 + fi + rm -f filelist + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir + done +done diff --git a/tests/pot-format-tcl1.test b/tests/pot-format-tcl1.test new file mode 100644 index 000000000..109245e04 --- /dev/null +++ b/tests/pot-format-tcl1.test @@ -0,0 +1,219 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check the creation of compiled message catalogs in Tcl format. + +required='gzip' +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +pkgmsgsdir = $(pkgdatadir)/msgs +pkgmsgs_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/main.tcl +posub_foo_bar_pot_XGETTEXT_OPTIONS = --keyword=_ --flag=_:1:pass-tcl-format +posub_foo_bar_pot_LINGUAS = de fr_CA +posub_foo_bar_pot_CATALOGFORMAT = msg +EXTRA_DIST = src/main.tcl +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/main.tcl << 'END' +package require msgcat +::msgcat::mcload [file join "/usr/share/pot-format-tcl1" "msgs" "foo-bar"] +proc _ {s} {return [::msgcat::mc $s]} + +puts [_ "Hello, world!"] +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +# .po files for _LINGUAS. +mkdir posub +cat > posub/foo-bar-de.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Hallo Welt!" +END +cat > posub/foo-bar-fr_CA.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Salut, le monde!" +END + +# A .po file not listed among _LINGUAS, and a junk .msg file. +cat > posub/foo-bar-es.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world!" +msgstr "Adiós, mundo!" +END +cat > posub/foo-bar-es.msg << 'END' +junk +END + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-format-tcl1 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/main.tcl:5 +msgid "Hello, world!" +msgstr "" +END + +for builddir in . sub; do + for config_options in '' 'LINGUAS="es de"'; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + env $config_options $sourcedir/configure --prefix="$instdir" + make + + # Check that "make install" creates the expected .pot file, .po files + # and .msg files. + # (They are created under $sourcedir, because the files are distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make install + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/posub/foo-bar-de.po + test ! -f $sourcedir/posub/foo-bar-de.msg + test -f $sourcedir/posub/foo-bar/de.msg + test -f $sourcedir/posub/foo-bar-fr_CA.po + test ! -f $sourcedir/posub/foo-bar-fr_CA.msg + test -f $sourcedir/posub/foo-bar/fr_ca.msg + test ! -f $sourcedir/posub/foo-bar-de.mo + test ! -f $sourcedir/posub/foo-bar-fr_CA.mo + + if test -z "$config_options"; then + # Check that "make install" installed de,po and fr_CA.po but not es.po. + test -f "$instdir"/share/pot-format-tcl1/msgs/foo-bar/de.msg + test -f "$instdir"/share/pot-format-tcl1/msgs/foo-bar/fr_ca.msg + test ! -f "$instdir"/share/pot-format-tcl1/msgs/foo-bar/es.msg + else + # Check that "make install" installed de.po but not fr_CA.po nor es.po. + test -f "$instdir"/share/pot-format-tcl1/msgs/foo-bar/de.msg + test ! -f "$instdir"/share/pot-format-tcl1/msgs/foo-bar/fr_ca.msg + test ! -f "$instdir"/share/pot-format-tcl1/msgs/foo-bar/es.msg + fi + test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.msg + test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.msg + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.msg + test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo + + # Check that "make dist" creates the expected .pot file. + + rm -f $sourcedir/posub/foo-bar.pot + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/posub/foo-bar-de.po + test ! -f $sourcedir/posub/foo-bar-de.msg + test -f $sourcedir/posub/foo-bar/de.msg + test -f $sourcedir/posub/foo-bar-fr_CA.po + test ! -f $sourcedir/posub/foo-bar-fr_CA.msg + test -f $sourcedir/posub/foo-bar/fr_ca.msg + test ! -f $sourcedir/posub/foo-bar-de.mo + test ! -f $sourcedir/posub/foo-bar-fr_CA.mo + + # Check that the tarball contains posub/foo-bar-{de,fr}.{po,msg} but not + # the others, regardless whether LINGUAS was specified or not. + gzip -d -c < pot-format-tcl1-1.0.tar.gz | tar tf - > filelist + grep '^pot-format-tcl1-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null + grep '^pot-format-tcl1-1\.0/posub/foo-bar/de\.msg$' filelist >/dev/null + grep '^pot-format-tcl1-1\.0/posub/foo-bar-fr_CA\.po$' filelist >/dev/null + grep '^pot-format-tcl1-1\.0/posub/foo-bar/fr_ca\.msg$' filelist >/dev/null + if grep '^pot-format-tcl1-1\.0/posub/foo-bar-es\.po$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-tcl1-1\.0/posub/foo-bar/es\.msg$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-tcl1-1\.0/posub/foo-bar-de\.mo$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-tcl1-1\.0/posub/foo-bar-fr_CA\.mo$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-format-tcl1-1\.0/posub/foo-bar-es\.mo$' filelist >/dev/null; then + exit 1 + fi + rm -f filelist + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir + done +done diff --git a/tests/pot-linguas.test b/tests/pot-linguas.test new file mode 100644 index 000000000..428152b09 --- /dev/null +++ b/tests/pot-linguas.test @@ -0,0 +1,286 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that when the _LINGUAS variable is specified, the POT file gets created +# and the .mo files for the listed languages get installed, but no .mo files +# for other languages get installed. Check that the POT file and PO files and +# MO files get updated by "make install" and "make dist" (but not by "make"!) +# when some of the source files is changed. +# FIXME: Should "make install" really update the PO files and MO files? +# Current po/Makefile.in.in does not do it. + +required='gzip' +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/main.c src/util.c +posub_foo_bar_pot_LINGUAS = de fr +EXTRA_DIST = src/main.c src/util.c +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/util.c << 'END' +#include +void usage () +{ + puts (gettext ("See the documentation for details.")); +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +# .po files for _LINGUAS. +mkdir posub +cat > posub/foo-bar-de.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#, c-format +msgid "Hello, world.\n" +msgstr "Hallo, Welt.\n" +END +cat > posub/foo-bar-fr.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#, c-format +msgid "Hello, world.\n" +msgstr "Salut, le monde.\n" +END + +# A .po file not listed among _LINGUAS, and a junk .mo file. +cat > posub/foo-bar-es.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#, c-format +msgid "Hello, world.\n" +msgstr "Adiós, mundo.\n" +END +cat > posub/foo-bar-es.mo << 'END' +junk +END + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-linguas 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/main.c:4 +#, c-format +msgid "Hello, world.\n" +msgstr "" + +#: src/util.c:4 +msgid "See the documentation for details." +msgstr "" +END + +for builddir in . sub; do + for config_options in '' 'LINGUAS="es de"'; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + env $config_options $sourcedir/configure --prefix="$instdir" + make + + cat > $sourcedir/src/main.c << 'END' +#include +int main () +{ + printf (gettext ("Hello, world.\n")); + return 0; +} +END + + # Check that "make install" creates the expected .pot file, .po files + # and .mo files. + # (They are created under $sourcedir, because the files are distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make install + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/posub/foo-bar-de.po + test -f $sourcedir/posub/foo-bar-de.mo + test -f $sourcedir/posub/foo-bar-fr.po + test -f $sourcedir/posub/foo-bar-fr.mo + + if test -z "$config_options"; then + # Check that "make install" installed de,po and fr.po but not es.po. + test -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo + test -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo + else + # Check that "make install" installed de.po but not fr.po nor es.po. + test -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo + fi + + # Check that "make dist" creates the expected .pot file. + + rm -f $sourcedir/posub/foo-bar.pot + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/posub/foo-bar-de.po + test -f $sourcedir/posub/foo-bar-de.mo + test -f $sourcedir/posub/foo-bar-fr.po + test -f $sourcedir/posub/foo-bar-fr.mo + + # Check that the tarball contains posub/foo-bar-{de,fr}.{po,mo} but not + # the others, regardless whether LINGUAS was specified or not. + gzip -d -c < pot-linguas-1.0.tar.gz | tar tf - > filelist + grep '^pot-linguas-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null + grep '^pot-linguas-1\.0/posub/foo-bar-de\.mo$' filelist >/dev/null + grep '^pot-linguas-1\.0/posub/foo-bar-fr\.po$' filelist >/dev/null + grep '^pot-linguas-1\.0/posub/foo-bar-fr\.mo$' filelist >/dev/null + if grep '^pot-linguas-1\.0/posub/foo-bar-es\.po$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-linguas-1\.0/posub/foo-bar-es\.mo$' filelist >/dev/null; then + exit 1 + fi + rm -f filelist + + # Try modifying a source file. + cat > $sourcedir/src/main.c << 'END' +#include +int main () +{ + printf (gettext ("Hello, great world!\n")); + return 0; +} +END + + # Check that "make" does not rebuild the POT file, the PO files, and the + # MO files. + cp -p $sourcedir/posub/foo-bar.pot $sourcedir/posub/foo-bar.potbak + cp -p $sourcedir/posub/foo-bar-de.po $sourcedir/posub/foo-bar-de.pobak + cp -p $sourcedir/posub/foo-bar-de.mo $sourcedir/posub/foo-bar-de.mobak + cp -p $sourcedir/posub/foo-bar-fr.po $sourcedir/posub/foo-bar-fr.pobak + cp -p $sourcedir/posub/foo-bar-fr.mo $sourcedir/posub/foo-bar-fr.mobak + cp -p $sourcedir/posub/foo-bar-es.po $sourcedir/posub/foo-bar-es.pobak + cp -p $sourcedir/posub/foo-bar-es.mo $sourcedir/posub/foo-bar-es.mobak + make + diff $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot + cmp $sourcedir/posub/foo-bar-de.pobak $sourcedir/posub/foo-bar-de.po >/dev/null + cmp $sourcedir/posub/foo-bar-de.mobak $sourcedir/posub/foo-bar-de.mo >/dev/null + cmp $sourcedir/posub/foo-bar-fr.pobak $sourcedir/posub/foo-bar-fr.po >/dev/null + cmp $sourcedir/posub/foo-bar-fr.mobak $sourcedir/posub/foo-bar-fr.mo >/dev/null + cmp $sourcedir/posub/foo-bar-es.pobak $sourcedir/posub/foo-bar-es.po >/dev/null + cmp $sourcedir/posub/foo-bar-es.mobak $sourcedir/posub/foo-bar-es.mo >/dev/null + + # Check that "make install" updates the POT file, the PO files, and the + # MO files listed in the _LINGUAS variable, regardless whether LINGUAS + # was specified or not. + make install + cat $sourcedir/posub/foo-bar.pot | grep great >/dev/null + cat $sourcedir/posub/foo-bar-de.po | grep great >/dev/null + if cmp $sourcedir/posub/foo-bar-de.mobak $sourcedir/posub/foo-bar-de.mo >/dev/null; then + exit 1 + fi + cat $sourcedir/posub/foo-bar-fr.po | grep great >/dev/null + if cmp $sourcedir/posub/foo-bar-fr.mobak $sourcedir/posub/foo-bar-fr.mo >/dev/null; then + exit 1 + fi + cmp $sourcedir/posub/foo-bar-es.pobak $sourcedir/posub/foo-bar-es.po >/dev/null + cmp $sourcedir/posub/foo-bar-es.mobak $sourcedir/posub/foo-bar-es.mo >/dev/null + + # Check that "make dist" updates the POT file, the PO files, and the + # MO files listed in the _LINGUAS variable, regardless whether LINGUAS + # was specified or not. + cp -p $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot + cp -p $sourcedir/posub/foo-bar-de.pobak $sourcedir/posub/foo-bar-de.po + cp -p $sourcedir/posub/foo-bar-de.mobak $sourcedir/posub/foo-bar-de.mo + cp -p $sourcedir/posub/foo-bar-fr.pobak $sourcedir/posub/foo-bar-fr.po + cp -p $sourcedir/posub/foo-bar-fr.mobak $sourcedir/posub/foo-bar-fr.mo + make dist + cat $sourcedir/posub/foo-bar.pot | grep great >/dev/null + cat $sourcedir/posub/foo-bar-de.po | grep great >/dev/null + if cmp $sourcedir/posub/foo-bar-de.mobak $sourcedir/posub/foo-bar-de.mo >/dev/null; then + exit 1 + fi + cat $sourcedir/posub/foo-bar-fr.po | grep great >/dev/null + if cmp $sourcedir/posub/foo-bar-fr.mobak $sourcedir/posub/foo-bar-fr.mo >/dev/null; then + exit 1 + fi + cmp $sourcedir/posub/foo-bar-es.pobak $sourcedir/posub/foo-bar-es.po >/dev/null + cmp $sourcedir/posub/foo-bar-es.mobak $sourcedir/posub/foo-bar-es.mo >/dev/null + + # Check that the updated PO files contain 'previous msgid' fields. + cat $sourcedir/posub/foo-bar-de.po | grep '^#| msgid "Hello, world\.\\n"$' >/dev/null + cat $sourcedir/posub/foo-bar-fr.po | grep '^#| msgid "Hello, world\.\\n"$' >/dev/null + + # Sanity check. + make distcheck + + # Clean up. + rm -f $sourcedir/posub/foo-bar.potbak $sourcedir/posub/*.pobak $sourcedir/posub/*.mobak + make distclean + rm -rf "$instdir" + cd $sourcedir + done +done diff --git a/tests/pot-macro-warn.test b/tests/pot-macro-warn.test new file mode 100644 index 000000000..41fb35f52 --- /dev/null +++ b/tests/pot-macro-warn.test @@ -0,0 +1,54 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that when the POTS primary is used, AM_POT_TOOLS must be invoked, +# otherwise a warning occurs. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = +END + +cp configure.in configure.in.bak +cat >> configure.in << 'END' +AC_OUTPUT +END + +$ACLOCAL + +# Check that there is a warning about the missing AM_POT_TOOLS invocation. + +AUTOMAKE_fails -Werror +grep 'POTS.*AM_POT_TOOLS.*invoked' stderr + +AUTOMAKE_run 0 -Wno-error +grep 'POTS.*AM_POT_TOOLS.*invoked' stderr + +cp configure.in.bak configure.in +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +$ACLOCAL + +# Check that there is no warning any more. + +AUTOMAKE_run 0 -Werror diff --git a/tests/pot-msgidbugs.test b/tests/pot-msgidbugs.test new file mode 100644 index 000000000..1bf533419 --- /dev/null +++ b/tests/pot-msgidbugs.test @@ -0,0 +1,172 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that the value of the 'Report-Msgid-Bugs-To' field in the POT file's +# header comes from the _MSGID_BUGS_ADDRESS variable if it is specified, or +# from the third argument of AC_INIT otherwise. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/main.c +EXTRA_DIST = src/main.c +END + +# Insert an email address as third argument of the AC_INIT invocation. +mv configure.in configure.in.bak +sed -e '/AC_INIT/{s/)$/, [info@yoyodyne.example.com])/}' < configure.in.bak > configure.in + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/main.c << 'END' +#include +int main () +{ + printf (gettext ("Hello, world.\n")); + return 0; +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-msgidbugs 1.0\n" +"Report-Msgid-Bugs-To: info@yoyodyne.example.com\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/main.c:4 +#, c-format +msgid "Hello, world.\n" +msgstr "" +END + +for builddir in . sub1; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + $sourcedir/configure --prefix="$instdir" + make + + # Check that "make dist" creates the expected .pot file. + # (It is created under $sourcedir, because the .pot file is distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir +done + +cat >> Makefile.am << 'END' +posub_foo_bar_pot_MSGID_BUGS_ADDRESS = bug-maude@yoyodyne.example.com +END + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-msgidbugs 1.0\n" +"Report-Msgid-Bugs-To: bug-maude@yoyodyne.example.com\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/main.c:4 +#, c-format +msgid "Hello, world.\n" +msgstr "" +END + +$AUTOMAKE -a + +for builddir in . sub2; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + $sourcedir/configure --prefix="$instdir" + make + + # Check that "make dist" creates the expected .pot file. + # (It is created under $sourcedir, because the .pot file is distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir +done diff --git a/tests/pot-no-linguas.test b/tests/pot-no-linguas.test new file mode 100644 index 000000000..f64588ade --- /dev/null +++ b/tests/pot-no-linguas.test @@ -0,0 +1,176 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that when no _LINGUAS variable is specified, the POT file gets created +# but no .mo file gets installed. Check that the POT file gets updated by +# "make install" and "make dist" (but not by "make"!) when some of the source +# files is changed. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/main.c src/util.c +EXTRA_DIST = src/main.c src/util.c +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/util.c << 'END' +#include +void usage () +{ + puts (gettext ("See the documentation for details.")); +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +# A .po file not listed among LINGUAS, and a junk .mo file. +mkdir posub +cat > posub/foo-bar-de.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#, c-format +msgid "Hello, world.\n" +msgstr "Tschüss, alle\n" +END +cat > posub/foo-bar-de.mo << 'END' +junk +END + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-no-linguas 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/main.c:4 +#, c-format +msgid "Hello, world.\n" +msgstr "" + +#: src/util.c:4 +msgid "See the documentation for details." +msgstr "" +END + +for builddir in . sub; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + $sourcedir/configure --prefix="$instdir" + make + + cat > $sourcedir/src/main.c << 'END' +#include +int main () +{ + printf (gettext ("Hello, world.\n")); + return 0; +} +END + + # Check that "make dist" creates the expected .pot file. + # (It is created under $sourcedir, because the .pot file is distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + rm -f $sourcedir/posub/foo-bar.pot + + # Check that "make install" creates the expected .pot file. + + make install + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + # Check that no .mo file was installed, although posub/foo-bar-de.po and + # posub/foo-bar-de.mo exist. + test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo + + # Try modifying a source file. + cat > $sourcedir/src/main.c << 'END' +#include +int main () +{ + printf (gettext ("Hello, great world!\n")); + return 0; +} +END + + # Check that "make" does not rebuild the POT file. + cp -p $sourcedir/posub/foo-bar.pot $sourcedir/posub/foo-bar.potbak + make + diff $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot + + # Check that "make dist" updates the POT file. + make dist + cat $sourcedir/posub/foo-bar.pot | grep great >/dev/null + + # Check that "make install" updates the POT file. + cp -p $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot + make install + cat $sourcedir/posub/foo-bar.pot | grep great >/dev/null + + # Sanity check. + make distcheck + + # Clean up. + rm -f $sourcedir/posub/foo-bar.potbak + make distclean + rm -rf "$instdir" + cd $sourcedir +done diff --git a/tests/pot-noinst.test b/tests/pot-noinst.test new file mode 100644 index 000000000..9c1c9225a --- /dev/null +++ b/tests/pot-noinst.test @@ -0,0 +1,258 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that when the installation directory is specified as 'noinst', nothing +# gets installed by "make install". The LINGUAS environment variable at +# configure time has no effect. Otherwise, everything is the same as in the +# pot-linguas test. + +required='gzip' +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +noinst_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/main.c src/util.c +posub_foo_bar_pot_LINGUAS = de fr +EXTRA_DIST = src/main.c src/util.c +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/util.c << 'END' +#include +void usage () +{ + puts (gettext ("See the documentation for details.")); +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +# .po files for _LINGUAS. +mkdir posub +cat > posub/foo-bar-de.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#, c-format +msgid "Hello, world.\n" +msgstr "Hallo, Welt.\n" +END +cat > posub/foo-bar-fr.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#, c-format +msgid "Hello, world.\n" +msgstr "Salut, le monde.\n" +END + +# A .po file not listed among _LINGUAS, and a junk .mo file. +cat > posub/foo-bar-es.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#, c-format +msgid "Hello, world.\n" +msgstr "Adiós, mundo.\n" +END +cat > posub/foo-bar-es.mo << 'END' +junk +END + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-noinst 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/main.c:4 +#, c-format +msgid "Hello, world.\n" +msgstr "" + +#: src/util.c:4 +msgid "See the documentation for details." +msgstr "" +END + +for builddir in . sub; do + for config_options in '' 'LINGUAS="es de"'; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + env $config_options $sourcedir/configure --prefix="$instdir" + make + + cat > $sourcedir/src/main.c << 'END' +#include +int main () +{ + printf (gettext ("Hello, world.\n")); + return 0; +} +END + + # Check that "make install" does not create the .pot file and .mo files. + # (They are not needed for installation.) + + make install + + test ! -f $sourcedir/posub/foo-bar.pot + test ! -f $sourcedir/posub/foo-bar-de.mo + test ! -f $sourcedir/posub/foo-bar-fr.mo + + # Check that "make install" installed none of de.po, fr.po, es.po. + test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo + + # Check that "make dist" creates the expected .pot file, .po files + # and .mo files. + # (They are created under $sourcedir, because the files are distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/posub/foo-bar-de.po + test -f $sourcedir/posub/foo-bar-de.mo + test -f $sourcedir/posub/foo-bar-fr.po + test -f $sourcedir/posub/foo-bar-fr.mo + + # Check that the tarball contains posub/foo-bar-{de,fr}.{po,mo} but not + # the others, regardless whether LINGUAS was specified or not. + gzip -d -c < pot-noinst-1.0.tar.gz | tar tf - > filelist + grep '^pot-noinst-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null + grep '^pot-noinst-1\.0/posub/foo-bar-de\.mo$' filelist >/dev/null + grep '^pot-noinst-1\.0/posub/foo-bar-fr\.po$' filelist >/dev/null + grep '^pot-noinst-1\.0/posub/foo-bar-fr\.mo$' filelist >/dev/null + if grep '^pot-noinst-1\.0/posub/foo-bar-es\.po$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-noinst-1\.0/posub/foo-bar-es\.mo$' filelist >/dev/null; then + exit 1 + fi + rm -f filelist + + # Try modifying a source file. + cat > $sourcedir/src/main.c << 'END' +#include +int main () +{ + printf (gettext ("Hello, great world!\n")); + return 0; +} +END + + # Check that "make" does not rebuild the POT file, the PO files, and the + # MO files. + cp -p $sourcedir/posub/foo-bar.pot $sourcedir/posub/foo-bar.potbak + cp -p $sourcedir/posub/foo-bar-de.po $sourcedir/posub/foo-bar-de.pobak + cp -p $sourcedir/posub/foo-bar-de.mo $sourcedir/posub/foo-bar-de.mobak + cp -p $sourcedir/posub/foo-bar-fr.po $sourcedir/posub/foo-bar-fr.pobak + cp -p $sourcedir/posub/foo-bar-fr.mo $sourcedir/posub/foo-bar-fr.mobak + cp -p $sourcedir/posub/foo-bar-es.po $sourcedir/posub/foo-bar-es.pobak + cp -p $sourcedir/posub/foo-bar-es.mo $sourcedir/posub/foo-bar-es.mobak + make + diff $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot + cmp $sourcedir/posub/foo-bar-de.pobak $sourcedir/posub/foo-bar-de.po >/dev/null + cmp $sourcedir/posub/foo-bar-de.mobak $sourcedir/posub/foo-bar-de.mo >/dev/null + cmp $sourcedir/posub/foo-bar-fr.pobak $sourcedir/posub/foo-bar-fr.po >/dev/null + cmp $sourcedir/posub/foo-bar-fr.mobak $sourcedir/posub/foo-bar-fr.mo >/dev/null + cmp $sourcedir/posub/foo-bar-es.pobak $sourcedir/posub/foo-bar-es.po >/dev/null + cmp $sourcedir/posub/foo-bar-es.mobak $sourcedir/posub/foo-bar-es.mo >/dev/null + + # Check that "make install" does not update the POT file, the PO files, + # and the MO files. + make install + diff $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot + cmp $sourcedir/posub/foo-bar-de.pobak $sourcedir/posub/foo-bar-de.po >/dev/null + cmp $sourcedir/posub/foo-bar-de.mobak $sourcedir/posub/foo-bar-de.mo >/dev/null + cmp $sourcedir/posub/foo-bar-fr.pobak $sourcedir/posub/foo-bar-fr.po >/dev/null + cmp $sourcedir/posub/foo-bar-fr.mobak $sourcedir/posub/foo-bar-fr.mo >/dev/null + cmp $sourcedir/posub/foo-bar-es.pobak $sourcedir/posub/foo-bar-es.po >/dev/null + cmp $sourcedir/posub/foo-bar-es.mobak $sourcedir/posub/foo-bar-es.mo >/dev/null + + # Check that "make dist" updates the POT file, the PO files, and the + # MO files listed in the _LINGUAS variable, regardless whether LINGUAS + # was specified or not. + make dist + cat $sourcedir/posub/foo-bar.pot | grep great >/dev/null + cat $sourcedir/posub/foo-bar-de.po | grep great >/dev/null + if cmp $sourcedir/posub/foo-bar-de.mobak $sourcedir/posub/foo-bar-de.mo >/dev/null; then + exit 1 + fi + cat $sourcedir/posub/foo-bar-fr.po | grep great >/dev/null + if cmp $sourcedir/posub/foo-bar-fr.mobak $sourcedir/posub/foo-bar-fr.mo >/dev/null; then + exit 1 + fi + cmp $sourcedir/posub/foo-bar-es.pobak $sourcedir/posub/foo-bar-es.po >/dev/null + cmp $sourcedir/posub/foo-bar-es.mobak $sourcedir/posub/foo-bar-es.mo >/dev/null + + # Check that the updated PO files contain 'previous msgid' fields. + cat $sourcedir/posub/foo-bar-de.po | grep '^#| msgid "Hello, world\.\\n"$' >/dev/null + cat $sourcedir/posub/foo-bar-fr.po | grep '^#| msgid "Hello, world\.\\n"$' >/dev/null + + # Sanity check. + make distcheck + + # Clean up. + rm -f $sourcedir/posub/foo-bar.potbak $sourcedir/posub/*.pobak $sourcedir/posub/*.mobak + make distclean + rm -rf "$instdir" + cd $sourcedir + done +done diff --git a/tests/pot-override1.test b/tests/pot-override1.test new file mode 100644 index 000000000..6389f545e --- /dev/null +++ b/tests/pot-override1.test @@ -0,0 +1,145 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that the rule for creating the .pot file can be overridden. +# FIXME: Should "make install" really update the PO files and MO files? +# Current po/Makefile.in.in does not do it. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/main.c src/util.c +EXTRA_DIST = src/main.c src/util.c + +# A user-written rule that creates the POT file without xgettext. +$(srcdir)/posub/foo-bar.pot : $(posub_foo_bar_pot_SOURCES) + { echo 'msgid ""'; \ + echo 'msgstr "MIME-Version: 1.0\n"'; \ + echo ' "Content-Type: text/plain; charset=CHARSET\n"'; \ + echo ' "Content-Transfer-Encoding: 8bit\n"'; \ + echo; \ + for file in $(posub_foo_bar_pot_SOURCES); do \ + sed -n -e 's/.*gettext *(\(".*"\)).*/msgid \1 msgstr ""/p' < $$file; \ + done; \ + } > $(srcdir)/posub/foo-bar.pot-t + mv $(srcdir)/posub/foo-bar.pot-t $(srcdir)/posub/foo-bar.pot +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/util.c << 'END' +#include +void usage () +{ + puts (gettext ("See the documentation for details.")); +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +cat > expected << 'END' +msgid "" +msgstr "MIME-Version: 1.0\n" + "Content-Type: text/plain; charset=CHARSET\n" + "Content-Transfer-Encoding: 8bit\n" + +msgid "Hello, world.\n" msgstr "" +msgid "See the documentation for details." msgstr "" +END + +for builddir in . sub; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + $sourcedir/configure --prefix="$instdir" + make + + cat > $sourcedir/src/main.c << 'END' +#include +int main () +{ + printf (gettext ("Hello, world.\n")); + return 0; +} +END + + # Check that "make dist" creates the expected .pot file. + # (It is created under $sourcedir, because the .pot file is distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + diff $sourcedir/posub/foo-bar.pot $sourcedir/expected + + rm -f $sourcedir/posub/foo-bar.pot + + # Check that "make install" creates the expected .pot file. + + make install + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + diff $sourcedir/posub/foo-bar.pot $sourcedir/expected + + # Try modifying a source file. + cat > $sourcedir/src/main.c << 'END' +#include +int main () +{ + printf (gettext ("Hello, great world!\n")); + return 0; +} +END + + # Check that "make" does not rebuild the POT file. + cp -p $sourcedir/posub/foo-bar.pot $sourcedir/posub/foo-bar.potbak + make + diff $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot + + # Check that "make dist" updates the POT file. + make dist + cat $sourcedir/posub/foo-bar.pot | grep great >/dev/null + + # Check that "make install" updates the POT file. + cp -p $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot + make install + cat $sourcedir/posub/foo-bar.pot | grep great >/dev/null + + # Sanity check. + make distcheck + + # Clean up. + rm -f $sourcedir/posub/foo-bar.potbak + make distclean + rm -rf "$instdir" + cd $sourcedir +done diff --git a/tests/pot-samedir.test b/tests/pot-samedir.test new file mode 100644 index 000000000..900be4fe1 --- /dev/null +++ b/tests/pot-samedir.test @@ -0,0 +1,233 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that different .pot files in the same directory don't collide. + +required='gzip' +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = posub/foo-bar.pot posub/foo-baz.pot +posub_foo_bar_pot_SOURCES = src/main.c +posub_foo_bar_pot_LINGUAS = de fr +posub_foo_baz_pot_SOURCES = src/util.c +posub_foo_baz_pot_LINGUAS = de it +EXTRA_DIST = src/main.c src/util.c +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/main.c << 'END' +#include +int main () +{ + printf (gettext ("Hello, world.\n")); + return 0; +} +END +cat > src/util.c << 'END' +#include +void usage () +{ + puts (gettext ("See the documentation for details.")); +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +# .po files for _LINGUAS. +mkdir posub +cat > posub/foo-bar-de.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#, c-format +msgid "Hello, world.\n" +msgstr "Hallo, Welt.\n" +END +cat > posub/foo-bar-fr.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#, c-format +msgid "Hello, world.\n" +msgstr "Salut, le monde.\n" +END +cat > posub/foo-baz-de.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "See the documentation for details." +msgstr "Details entnehmen Sie der Dokumentation." +END +cat > posub/foo-baz-it.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "See the documentation for details." +msgstr "Consultare la documentazione per i dettagli." +END + +cat > expected1 << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-samedir 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/main.c:4 +#, c-format +msgid "Hello, world.\n" +msgstr "" +END + +cat > expected2 << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-samedir 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/util.c:4 +msgid "See the documentation for details." +msgstr "" +END + +for builddir in . sub; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + $sourcedir/configure --prefix="$instdir" + make + + # Check that "make install" creates the expected .pot files and .mo files. + # (They are created under $sourcedir, because the files are distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make install + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected1 + rm -f actual + + test -f $sourcedir/posub/foo-baz.pot + test $builddir = '.' || test ! -f posub/foo-baz.pot + cat $sourcedir/posub/foo-baz.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected2 + rm -f actual + + test -f $sourcedir/posub/foo-bar-de.mo + test -f $sourcedir/posub/foo-bar-fr.mo + test -f $sourcedir/posub/foo-baz-de.mo + test -f $sourcedir/posub/foo-baz-it.mo + + # Check that "make install" installed the .mo files for the specified + # languages. + test -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo + test -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/it/LC_MESSAGES/foo-bar.mo + test -f "$instdir"/share/locale/de/LC_MESSAGES/foo-baz.mo + test -f "$instdir"/share/locale/it/LC_MESSAGES/foo-baz.mo + test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-baz.mo + # Check that the two .mo files for the same language are different. + if cmp "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo "$instdir"/share/locale/de/LC_MESSAGES/foo-baz.mo >/dev/null; then + exit 1 + fi + + make dist + + # Check that the tarball contains the .po files and .mo files for the + # specified languages, but not more. + gzip -d -c < pot-samedir-1.0.tar.gz | tar tf - > filelist + grep '^pot-samedir-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null + grep '^pot-samedir-1\.0/posub/foo-bar-de\.mo$' filelist >/dev/null + grep '^pot-samedir-1\.0/posub/foo-bar-fr\.po$' filelist >/dev/null + grep '^pot-samedir-1\.0/posub/foo-bar-fr\.mo$' filelist >/dev/null + if grep '^pot-samedir-1\.0/posub/foo-bar-it\.po$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-samedir-1\.0/posub/foo-bar-it\.mo$' filelist >/dev/null; then + exit 1 + fi + grep '^pot-samedir-1\.0/posub/foo-baz-de\.po$' filelist >/dev/null + grep '^pot-samedir-1\.0/posub/foo-baz-de\.mo$' filelist >/dev/null + grep '^pot-samedir-1\.0/posub/foo-baz-it\.po$' filelist >/dev/null + grep '^pot-samedir-1\.0/posub/foo-baz-it\.mo$' filelist >/dev/null + if grep '^pot-samedir-1\.0/posub/foo-baz-fr\.po$' filelist >/dev/null; then + exit 1 + fi + if grep '^pot-samedir-1\.0/posub/foo-baz-fr\.mo$' filelist >/dev/null; then + exit 1 + fi + rm -f filelist + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir +done diff --git a/tests/pot-topsrcdir.test b/tests/pot-topsrcdir.test new file mode 100644 index 000000000..7236eb543 --- /dev/null +++ b/tests/pot-topsrcdir.test @@ -0,0 +1,283 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that the POTS primary can be used in the top srcdir, i.e. does not +# require a subdirectory. Everything else is the same as in the pot-linguas +# test. +# FIXME: Should "make install" really update the PO files and MO files? +# Current po/Makefile.in.in does not do it. + +required='gzip' +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = foo-bar.pot +foo_bar_pot_SOURCES = src/main.c src/util.c +foo_bar_pot_LINGUAS = de fr +EXTRA_DIST = src/main.c src/util.c +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/util.c << 'END' +#include +void usage () +{ + puts (gettext ("See the documentation for details.")); +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +# .po files for _LINGUAS. +cat > foo-bar-de.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#, c-format +msgid "Hello, world.\n" +msgstr "Hallo, Welt.\n" +END +cat > foo-bar-fr.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#, c-format +msgid "Hello, world.\n" +msgstr "Salut, le monde.\n" +END + +# A .po file not listed among _LINGUAS, and a junk .mo file. +cat > foo-bar-es.po << 'END' +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#, c-format +msgid "Hello, world.\n" +msgstr "Adiós, mundo.\n" +END +cat > foo-bar-es.mo << 'END' +junk +END + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-linguas 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/main.c:4 +#, c-format +msgid "Hello, world.\n" +msgstr "" + +#: src/util.c:4 +msgid "See the documentation for details." +msgstr "" +END + +for builddir in . sub; do + for config_options in '' 'LINGUAS="es de"'; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + env $config_options $sourcedir/configure --prefix="$instdir" + make + + cat > $sourcedir/src/main.c << 'END' +#include +int main () +{ + printf (gettext ("Hello, world.\n")); + return 0; +} +END + + # Check that "make install" creates the expected .pot file, .po files + # and .mo files. + # (They are created under $sourcedir, because the files are distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make install + + test -f $sourcedir/foo-bar.pot + test $builddir = '.' || test ! -f foo-bar.pot + cat $sourcedir/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/foo-bar-de.po + test -f $sourcedir/foo-bar-de.mo + test -f $sourcedir/foo-bar-fr.po + test -f $sourcedir/foo-bar-fr.mo + + if test -z "$config_options"; then + # Check that "make install" installed de,po and fr.po but not es.po. + test -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo + test -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo + else + # Check that "make install" installed de.po but not fr.po nor es.po. + test -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo + test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo + fi + + # Check that "make dist" creates the expected .pot file. + + rm -f $sourcedir/foo-bar.pot + + make dist + + test -f $sourcedir/foo-bar.pot + test $builddir = '.' || test ! -f foo-bar.pot + cat $sourcedir/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + test -f $sourcedir/foo-bar-de.po + test -f $sourcedir/foo-bar-de.mo + test -f $sourcedir/foo-bar-fr.po + test -f $sourcedir/foo-bar-fr.mo + + # Check that the tarball contains foo-bar-{de,fr}.{po,mo} but not + # the others, regardless whether LINGUAS was specified or not. + gzip -d -c < pot-linguas-1.0.tar.gz | tar tf - > filelist + grep '^foo-bar-de\.po$' filelist >/dev/null + grep '^foo-bar-de\.mo$' filelist >/dev/null + grep '^foo-bar-fr\.po$' filelist >/dev/null + grep '^foo-bar-fr\.mo$' filelist >/dev/null + if grep '^foo-bar-es\.po$' filelist >/dev/null; then + exit 1 + fi + if grep '^foo-bar-es\.mo$' filelist >/dev/null; then + exit 1 + fi + rm -f filelist + + # Try modifying a source file. + cat > $sourcedir/src/main.c << 'END' +#include +int main () +{ + printf (gettext ("Hello, great world!\n")); + return 0; +} +END + + # Check that "make" does not rebuild the POT file, the PO files, and the + # MO files. + cp -p $sourcedir/foo-bar.pot $sourcedir/foo-bar.potbak + cp -p $sourcedir/foo-bar-de.po $sourcedir/foo-bar-de.pobak + cp -p $sourcedir/foo-bar-de.mo $sourcedir/foo-bar-de.mobak + cp -p $sourcedir/foo-bar-fr.po $sourcedir/foo-bar-fr.pobak + cp -p $sourcedir/foo-bar-fr.mo $sourcedir/foo-bar-fr.mobak + cp -p $sourcedir/foo-bar-es.po $sourcedir/foo-bar-es.pobak + cp -p $sourcedir/foo-bar-es.mo $sourcedir/foo-bar-es.mobak + make + diff $sourcedir/foo-bar.potbak $sourcedir/foo-bar.pot + cmp $sourcedir/foo-bar-de.pobak $sourcedir/foo-bar-de.po >/dev/null + cmp $sourcedir/foo-bar-de.mobak $sourcedir/foo-bar-de.mo >/dev/null + cmp $sourcedir/foo-bar-fr.pobak $sourcedir/foo-bar-fr.po >/dev/null + cmp $sourcedir/foo-bar-fr.mobak $sourcedir/foo-bar-fr.mo >/dev/null + cmp $sourcedir/foo-bar-es.pobak $sourcedir/foo-bar-es.po >/dev/null + cmp $sourcedir/foo-bar-es.mobak $sourcedir/foo-bar-es.mo >/dev/null + + # Check that "make install" updates the POT file, the PO files, and the + # MO files listed in the _LINGUAS variable, regardless whether LINGUAS + # was specified or not. + make install + cat $sourcedir/foo-bar.pot | grep great >/dev/null + cat $sourcedir/foo-bar-de.po | grep great >/dev/null + if cmp $sourcedir/foo-bar-de.mobak $sourcedir/foo-bar-de.mo >/dev/null; then + exit 1 + fi + cat $sourcedir/foo-bar-fr.po | grep great >/dev/null + if cmp $sourcedir/foo-bar-fr.mobak $sourcedir/foo-bar-fr.mo >/dev/null; then + exit 1 + fi + cmp $sourcedir/foo-bar-es.pobak $sourcedir/foo-bar-es.po >/dev/null + cmp $sourcedir/foo-bar-es.mobak $sourcedir/foo-bar-es.mo >/dev/null + + # Check that "make dist" updates the POT file, the PO files, and the + # MO files listed in the _LINGUAS variable, regardless whether LINGUAS + # was specified or not. + cp -p $sourcedir/foo-bar.potbak $sourcedir/foo-bar.pot + cp -p $sourcedir/foo-bar-de.pobak $sourcedir/foo-bar-de.po + cp -p $sourcedir/foo-bar-de.mobak $sourcedir/foo-bar-de.mo + cp -p $sourcedir/foo-bar-fr.pobak $sourcedir/foo-bar-fr.po + cp -p $sourcedir/foo-bar-fr.mobak $sourcedir/foo-bar-fr.mo + make dist + cat $sourcedir/foo-bar.pot | grep great >/dev/null + cat $sourcedir/foo-bar-de.po | grep great >/dev/null + if cmp $sourcedir/foo-bar-de.mobak $sourcedir/foo-bar-de.mo >/dev/null; then + exit 1 + fi + cat $sourcedir/foo-bar-fr.po | grep great >/dev/null + if cmp $sourcedir/foo-bar-fr.mobak $sourcedir/foo-bar-fr.mo >/dev/null; then + exit 1 + fi + cmp $sourcedir/foo-bar-es.pobak $sourcedir/foo-bar-es.po >/dev/null + cmp $sourcedir/foo-bar-es.mobak $sourcedir/foo-bar-es.mo >/dev/null + + # Check that the updated PO files contain 'previous msgid' fields. + cat $sourcedir/foo-bar-de.po | grep '^#| msgid "Hello, world\.\\n"$' >/dev/null + cat $sourcedir/foo-bar-fr.po | grep '^#| msgid "Hello, world\.\\n"$' >/dev/null + + # Sanity check. + make distcheck + + # Clean up. + rm -f $sourcedir/foo-bar.potbak $sourcedir/*.pobak $sourcedir/*.mobak + make distclean + rm -rf "$instdir" + cd $sourcedir + done +done diff --git a/tests/pot-warn1.test b/tests/pot-warn1.test new file mode 100644 index 000000000..2c79fb697 --- /dev/null +++ b/tests/pot-warn1.test @@ -0,0 +1,51 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that when the POTS primary is used, its elements must end in '.pot', +# otherwise a warning occurs. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = posub/foo-bar.po +posub_foo_bar_pot_SOURCES = +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +$ACLOCAL + +# Check that there is a warning about the suffix. + +AUTOMAKE_fails -Werror +grep 'POTS.*posub/foo-bar\.po.*\.pot' stderr + +AUTOMAKE_run 0 -Wno-error +grep 'POTS.*posub/foo-bar\.po.*\.pot' stderr + +cat > Makefile.am << 'END' +locale_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = +END + +# Check that there is no warning any more. + +AUTOMAKE_run 0 -Werror diff --git a/tests/pot-warn2.test b/tests/pot-warn2.test new file mode 100644 index 000000000..605655a7e --- /dev/null +++ b/tests/pot-warn2.test @@ -0,0 +1,49 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that when the POTS primary is used, the _SOURCES variable must be +# defined, otherwise a warning occurs. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = posub/foo-bar.pot +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +$ACLOCAL + +# Check that there is a warning about the missing _SOURCES variable. + +AUTOMAKE_fails -Werror +grep 'posub_foo_bar_pot_SOURCES' stderr + +AUTOMAKE_run 0 -Wno-error +grep 'posub_foo_bar_pot_SOURCES' stderr + +cat >> Makefile.am << 'END' +posub_foo_bar_pot_SOURCES = +END + +# Check that there is no warning any more. + +AUTOMAKE_run 0 -Werror diff --git a/tests/pot-xgettext1.test b/tests/pot-xgettext1.test new file mode 100644 index 000000000..d6cffcc46 --- /dev/null +++ b/tests/pot-xgettext1.test @@ -0,0 +1,106 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that additional xgettext options can be specified through the +# _XGETTEXT_OPTIONS variable. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/main.c +posub_foo_bar_pot_XGETTEXT_OPTIONS = --keyword=_ --flag=_:1:pass-c-format +EXTRA_DIST = src/main.c +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +mkdir src +cat > src/main.c << 'END' +#include +#include "gettext.h" +int main () +{ + printf (_ ("Hello, world.\n")); + return 0; +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-xgettext1 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/main.c:5 +#, c-format +msgid "Hello, world.\n" +msgstr "" +END + +for builddir in . sub; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + $sourcedir/configure --prefix="$instdir" + make + + # Check that "make dist" creates the expected .pot file. + # (It is created under $sourcedir, because the .pot file is distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir +done diff --git a/tests/pot-xgettext2.test b/tests/pot-xgettext2.test new file mode 100644 index 000000000..0c6e32651 --- /dev/null +++ b/tests/pot-xgettext2.test @@ -0,0 +1,106 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that additional xgettext options can be specified through an +# AM_XGETTEXT_OPTION invocation. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/main.c +EXTRA_DIST = src/main.c +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AM_XGETTEXT_OPTION([--keyword=_ --flag=_:1:pass-c-format]) +AC_OUTPUT +END + +mkdir src +cat > src/main.c << 'END' +#include +#include "gettext.h" +int main () +{ + printf (_ ("Hello, world.\n")); + return 0; +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-xgettext2 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/main.c:5 +#, c-format +msgid "Hello, world.\n" +msgstr "" +END + +for builddir in . sub; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + $sourcedir/configure --prefix="$instdir" + make + + # Check that "make dist" creates the expected .pot file. + # (It is created under $sourcedir, because the .pot file is distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir +done diff --git a/tests/pot-xgettext3.test b/tests/pot-xgettext3.test new file mode 100644 index 000000000..285646f50 --- /dev/null +++ b/tests/pot-xgettext3.test @@ -0,0 +1,121 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check that multiple specifications of additional xgettext options are +# cumulative. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = posub/foo-bar.pot +posub_foo_bar_pot_SOURCES = src/main.c +posub_foo_bar_pot_XGETTEXT_OPTIONS = --keyword=_ --flag=_:1:pass-c-format +EXTRA_DIST = src/main.c +END + +cat >> configure.in << 'END' +AM_XGETTEXT_OPTION([--flag=error:3:c-format]) +AM_POT_TOOLS +AM_XGETTEXT_OPTION([--keyword=tr --flag=tr:1:pass-c-format]) +AC_OUTPUT +END + +mkdir src +cat > src/main.c << 'END' +#include +#include "error.h" +#include "gettext.h" +int main () +{ + printf (_ ("Hello, world.\n")); + printf (tr ("Nice to meet you.")); + error (0, 0, "greeting succeeded"); + return 0; +} +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-xgettext3 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/main.c:6 +#, c-format +msgid "Hello, world.\n" +msgstr "" + +#: src/main.c:7 +#, c-format +msgid "Nice to meet you." +msgstr "" + +#: src/main.c:8 +#, c-format +msgid "greeting succeeded" +msgstr "" +END + +for builddir in . sub; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + $sourcedir/configure --prefix="$instdir" + make + + # Check that "make dist" creates the expected .pot file. + # (It is created under $sourcedir, because the .pot file is distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make dist + + test -f $sourcedir/posub/foo-bar.pot + test $builddir = '.' || test ! -f posub/foo-bar.pot + cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir +done diff --git a/tests/pot-xgettext4.test b/tests/pot-xgettext4.test new file mode 100644 index 000000000..a170525bd --- /dev/null +++ b/tests/pot-xgettext4.test @@ -0,0 +1,116 @@ +#! /bin/sh +# Copyright (C) 2010 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 2, 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 . + +# Check the example with multiple xgettext invocations, described in the +# manual. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am << 'END' +locale_POTS = maude.pot +noinst_POTS = maude1.pot maude2.pot +maude_pot_SOURCES = maude1.pot maude2.pot +maude1_pot_SOURCES = maude.c +maude2_pot_SOURCES = maude.lisp +EXTRA_DIST = maude.c maude.lisp +END + +cat >> configure.in << 'END' +AM_POT_TOOLS +AC_OUTPUT +END + +cat > maude.c << 'END' +#include +int main () +{ + printf (gettext ("Hello, world.\n")); + return 0; +} +END + +cat > maude.lisp << 'END' +(defun greeting (person) + (format t (i18n:gettext "Hello, ~A!~%") person)) +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +cat > expected << 'END' +# SOME DESCRIPTIVE TITLE. +# This file is put in the public domain. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: pot-xgettext1 1.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: maude.c:4 +#, c-format +msgid "Hello, world.\n" +msgstr "" + +#: maude.lisp:2 +#, lisp-format +msgid "Hello, ~A!~%" +msgstr "" +END + +for builddir in . sub; do + if test $builddir = '.'; then + sourcedir='.' + else + sourcedir='..' + mkdir $builddir + fi + instdir="`pwd`/instdir" + cd $builddir + $sourcedir/configure --prefix="$instdir" + make + + # Check that "make dist" creates the expected .pot file. + # (It is created under $sourcedir, because the .pot file is distributed. + # Cf. the GNU standards, node "Makefile Basics".) + + make dist + + test -f $sourcedir/maude.pot + test $builddir = '.' || test ! -f maude.pot + cat $sourcedir/maude.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > actual + diff actual $sourcedir/expected + rm -f actual + + # Sanity check. + make distcheck + + # Clean up. + make distclean + rm -rf "$instdir" + cd $sourcedir +done