intl/tst-gettext: fix failure with newest msgfmt

Message ID 20170826085756.6530-1-aurelien@aurel32.net
State New, archived
Headers

Commit Message

Aurelien Jarno Aug. 26, 2017, 8:57 a.m. UTC
  Since upstream gettext commit d13f165b83 (msgfmt: Remove
POT-Creation-Date field from the header in the output.), msgfmt does not
copy the POT-Creation-Date field in the header entry from the po file to
the mo file anymore. This breaks the assumption that we can test gettext
by comparing each message in the po files with the corresponding string
return by gettext. This makes the intl/tst-gettext to fail.

While it would have been possible to modify the po2test.awk script to
also strip the line POT-Creation-Date field when creating the msgs.h
file, it breaks tst-catgets which also uses it.

Instead create a tst-gettext-de.po file from de.po by removing the
POT-Creation-Date line. Another alternative would be to use a static
tst-gettext-de.po file, but I guess the reason for using de.po is to
also catch issues caused by newly added strings.

Changelog:
	[BZ #21508]
	* catgets/Makefile ($(objpfx)de.msg): Depend on
	$(common-objpfx)intl/tst-gettext-de.po instead of $(..)po/de.po.
	* intl/Makefile ($(objpfx)tst-gettext-de.po): Generate
	intl/tst-gettext-de.po from po/de.po by removing the
	POT-Creation-Date line.
	($(objpfx)msgs.h): Depend on $(objpfx)tst-gettext-de.po instead of
	../po/de.po.
	* intl/tst-gettext.sh: Use ${objpfx}tst-gettext-de.po instead of
	../po/de.po.
---
 ChangeLog           | 13 +++++++++++++
 catgets/Makefile    |  2 +-
 intl/Makefile       |  6 +++++-
 intl/tst-gettext.sh |  4 ++--
 4 files changed, 21 insertions(+), 4 deletions(-)
  

Comments

Szabolcs Nagy Jan. 26, 2018, 12:49 p.m. UTC | #1
On 26/08/17 09:57, Aurelien Jarno wrote:
> Since upstream gettext commit d13f165b83 (msgfmt: Remove
> POT-Creation-Date field from the header in the output.), msgfmt does not
> copy the POT-Creation-Date field in the header entry from the po file to
> the mo file anymore. This breaks the assumption that we can test gettext
> by comparing each message in the po files with the corresponding string
> return by gettext. This makes the intl/tst-gettext to fail.
> 
> While it would have been possible to modify the po2test.awk script to
> also strip the line POT-Creation-Date field when creating the msgs.h
> file, it breaks tst-catgets which also uses it.
> 
> Instead create a tst-gettext-de.po file from de.po by removing the
> POT-Creation-Date line. Another alternative would be to use a static
> tst-gettext-de.po file, but I guess the reason for using de.po is to
> also catch issues caused by newly added strings.
> 

i updated msgfmt on my system and now i get

FAIL: intl/tst-gettext

because of this issue
https://savannah.gnu.org/bugs/?49654

the fix looks reasonable to me.

> Changelog:
> 	[BZ #21508]
> 	* catgets/Makefile ($(objpfx)de.msg): Depend on
> 	$(common-objpfx)intl/tst-gettext-de.po instead of $(..)po/de.po.
> 	* intl/Makefile ($(objpfx)tst-gettext-de.po): Generate
> 	intl/tst-gettext-de.po from po/de.po by removing the
> 	POT-Creation-Date line.
> 	($(objpfx)msgs.h): Depend on $(objpfx)tst-gettext-de.po instead of
> 	../po/de.po.
> 	* intl/tst-gettext.sh: Use ${objpfx}tst-gettext-de.po instead of
> 	../po/de.po.
  

Patch

diff --git a/ChangeLog b/ChangeLog
index bc1cf94dc3..2afa40d1b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@ 
+2017-08-26  Aurelien Jarno  <aurelien@aurel32.net>
+
+	[BZ #21508]
+	* catgets/Makefile ($(objpfx)de.msg): Depend on
+	$(common-objpfx)intl/tst-gettext-de.po instead of $(..)po/de.po.
+	* intl/Makefile ($(objpfx)tst-gettext-de.po): Generate
+	intl/tst-gettext-de.po from po/de.po by removing the
+	POT-Creation-Date line.
+	($(objpfx)msgs.h): Depend on $(objpfx)tst-gettext-de.po instead of
+	../po/de.po.
+	* intl/tst-gettext.sh: Use ${objpfx}tst-gettext-de.po instead of
+	../po/de.po.
+
 2017-08-25  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* sysdeps/x86/cpu-features.h [__ASSEMBLER__]
diff --git a/catgets/Makefile b/catgets/Makefile
index 39aab67c14..a87172ef5e 100644
--- a/catgets/Makefile
+++ b/catgets/Makefile
@@ -78,7 +78,7 @@  $(objpfx)de/libc.cat: $(objpfx)de.msg $(objpfx)gencat
 $(objpfx)tst-catgets.out: $(objpfx)de/libc.cat
 
 # Generate a non-simple input file.
-$(objpfx)de.msg: xopen-msg.awk $(..)po/de.po
+$(objpfx)de.msg: xopen-msg.awk $(common-objpfx)intl/tst-gettext-de.po
 	LC_ALL=C $(AWK) -f $^ $< > $@
 
 $(objpfx)test-gencat.out: test-gencat.sh $(objpfx)test-gencat \
diff --git a/intl/Makefile b/intl/Makefile
index c8bec9b138..752aa9f5f5 100644
--- a/intl/Makefile
+++ b/intl/Makefile
@@ -120,7 +120,11 @@  $(objpfx)tst-gettext6.out: $(gen-locales)
 $(objpfx)tst-translit.out: $(gen-locales)
 endif
 
-$(objpfx)msgs.h: po2test.awk ../po/de.po
+$(objpfx)tst-gettext-de.po: ../po/de.po
+	$(make-target-directory)
+	LC_ALL=C $(AWK) '!/^"POT-Creation-Date: [0-9-]+ [0-9:+-]+\\n"$$/' $^ > $@
+
+$(objpfx)msgs.h: po2test.awk $(objpfx)tst-gettext-de.po
 	$(make-target-directory)
 	LC_ALL=C $(AWK) -f $^ > $@
 
diff --git a/intl/tst-gettext.sh b/intl/tst-gettext.sh
index 5c4775b817..be7ea3a399 100755
--- a/intl/tst-gettext.sh
+++ b/intl/tst-gettext.sh
@@ -42,9 +42,9 @@  mkdir -p ${objpfx}domaindir/existing-locale/LC_MESSAGES
 mkdir -p ${objpfx}domaindir/existing-locale/LC_TIME
 # Populate them.
 msgfmt -o ${objpfx}domaindir/existing-locale/LC_MESSAGES/existing-domain.mo \
-       -f ../po/de.po
+       -f ${objpfx}tst-gettext-de.po
 msgfmt -o ${objpfx}domaindir/existing-locale/LC_TIME/existing-time-domain.mo \
-       -f ../po/de.po
+       -f ${objpfx}tst-gettext-de.po
 
 # Now run the test.
 ${test_program_prefix_before_env} \