]> git.draconx.ca Git - dxcommon.git/commitdiff
tests: Add some coverage of the gettext.mk snippet.
authorNick Bowler <nbowler@draconx.ca>
Tue, 21 Nov 2023 03:42:33 +0000 (22:42 -0500)
committerNick Bowler <nbowler@draconx.ca>
Tue, 21 Nov 2023 04:13:28 +0000 (23:13 -0500)
There is zero test coverage of this snippet, add a new test case to
executes these rules in various ways.  As with other test cases, one
can set TEST_SHELL in the environment to test the behaviour with a
particular shell.  The astute reader may notice that the rules do
not work with some shells...

t/msgfmt.sh [new file with mode: 0755]
tests/snippets.at

diff --git a/t/msgfmt.sh b/t/msgfmt.sh
new file mode 100755 (executable)
index 0000000..6cb09ee
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Copyright © 2023 Nick Bowler
+#
+# Fake msgfmt program for testing.
+#
+# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+# This is free software: you are free to do what the fuck you want to.
+# There is NO WARRANTY, to the extent permitted by law.
+
+outfile=messages.mo
+for arg
+do
+  arg=${lastarg:+"$lastarg="}$arg
+  lastarg=
+
+  save_IFS=$IFS; IFS='='
+  set x $arg; shift; shift; optarg=$*
+  IFS=$save_IFS
+
+  case $arg in
+  -o|--output-file) lastarg=--output-file ;;
+  --output-file=*) outfile=$optarg ;;
+  esac
+done
+
+exec 1>"$outfile"
index fe4eb0855a11dcdea87075e921e0de78de42009d..3794c7ee006be0da78a744d15c3edc73e316ae82 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright © 2021-2022 Nick Bowler
+dnl Copyright © 2021-2023 Nick Bowler
 dnl
 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 dnl This is free software: you are free to do what the fuck you want to.
@@ -120,3 +120,67 @@ AT_CHECK([make -s lib/glconfig.h])
 AT_CHECK([test ! -d lib/.deps && test ! -d lib/_deps && cat lib/glconfig.h])
 
 AT_CLEANUP
+
+AT_SETUP([gettext.mk .mo installation])
+
+cp "$srcdir/snippet/gettext.mk" "$srcdir/t/msgfmt.sh" .
+touch a.po b.po
+TEST_CONFIGURE_AC(
+[[AM_INIT_AUTOMAKE([foreign])
+AC_CONFIG_FILES([Makefile])
+]])
+
+AT_DATA([Makefile.am],
+[[MSGFMT = $(SHELL) $(top_srcdir)/msgfmt.sh
+EXTRA_DIST =
+MAINTAINERCLEANFILES =
+POFILES = a.po b.po
+MOFILES = a.mo b.mo
+include $(top_srcdir)/gettext.mk
+]])
+TEST_AUTORECONF
+
+mkdir build
+(cd build && TEST_CONFIGURE([--prefix="$at_group_dir/inst"], [../configure]))
+
+AT_CHECK([cd build &&
+  make DESTDIR="$at_group_dir" localedir=/l0 install],
+  [0], [ignore], [ignore])
+AT_CHECK([test -d inst || { find l0 | LC_ALL=C sort; }], [0],
+[[l0
+l0/a
+l0/a/LC_MESSAGES
+l0/a/LC_MESSAGES/test.mo
+l0/b
+l0/b/LC_MESSAGES
+l0/b/LC_MESSAGES/test.mo
+]])
+
+AT_CHECK([cd build &&
+  make DESTDIR="$at_group_dir" localedir=/l1 installdirs],
+  [0], [ignore], [ignore])
+AT_CHECK([test -d inst || { find l1 | LC_ALL=C sort; }], [0],
+[[l1
+l1/a
+l1/a/LC_MESSAGES
+l1/b
+l1/b/LC_MESSAGES
+]])
+
+AT_CHECK([cd build &&
+  make DESTDIR="$at_group_dir" localedir=/l2 MOFILES= install installdirs],
+  [0], [ignore], [ignore])
+AT_CHECK([test ! -d inst && test ! -d l2])
+
+AT_CHECK([cd build &&
+  make DESTDIR="$at_group_dir" localedir=/l0 MOFILES= uninstall],
+  [0], [ignore], [ignore])
+AT_CHECK([test -d inst || { find l0 | LC_ALL=C sort; }], [0],
+[[l0
+l0/a
+l0/a/LC_MESSAGES
+l0/b
+l0/b/LC_MESSAGES
+]])
+
+AT_CLEANUP