X-Git-Url: https://git.draconx.ca/gitweb/dxcommon.git/blobdiff_plain/6c607da0ba3527c5454229707261d79d0b6932eb..105453d074078f82f07a08e56e3a53c1477e094d:/tests/scripts.at diff --git a/tests/scripts.at b/tests/scripts.at index c38faba..880bb6c 100644 --- a/tests/scripts.at +++ b/tests/scripts.at @@ -6,10 +6,13 @@ dnl There is NO WARRANTY, to the extent permitted by law. AT_BANNER([Script tests]) -AT_SETUP([gen-options.awk]) -AT_KEYWORDS([gen-options awk script scripts]) +m4_define([TEST_GEN_OPTIONS], +[AT_KEYWORDS([gen-options awk script scripts])dnl +AT_DATA([m4_default([$2], [options.def])], [$1]) +AT_CHECK([$AWK -f "$srcdir/scripts/gen-options.awk" dnl +options.h])]) -AT_DATA([options.def], +m4_define([TEST_GEN_OPTIONS_SAMPLE], [[--option-only --option-with-val (5) --option-with-flagval (&x, 5) @@ -37,7 +40,8 @@ do stuff with ARG --flagval ]]) -AT_CHECK([$AWK -f "$srcdir/scripts/gen-options.awk" options.h]) +AT_SETUP([gen-options.awk]) +TEST_GEN_OPTIONS([TEST_GEN_OPTIONS_SAMPLE]) AT_DATA([context.h], [[struct option { const char *name; int has_arg; int *flag; int val; }; @@ -158,6 +162,11 @@ $AWK -f soptstr.awk options.def >expout AT_CHECK([$CC -o test2$EXEEXT test2.c && ./test2$EXEEXT], [0], [expout], [ignore]) +AT_CLEANUP + +AT_SETUP([gen-options.awk xgettext annotation]) +TEST_GEN_OPTIONS([TEST_GEN_OPTIONS_SAMPLE]) + # Check that all help strings are translatable AT_DATA([messages.awk], [[BEGIN { lines = -1; } @@ -205,8 +214,13 @@ function output(i) } ]]) +dnl Antique versions of xgettext which predate the pgettext/msgctx feature +dnl will produce an output po file with no msgctx lines. So try to spot +dnl that and skip the test with such versions. AT_CHECK([xgettext --keyword=PN_:1c,2 options.h - test -f messages.po || exit 77]) + test -f messages.po || exit 77 + grep msgid messages.po >/dev/null && + { grep msgctx messages.po >/dev/null || exit 77; }]) $AWK -f messages.awk options.def | LC_ALL=C sort >expout AT_CHECK([sed -n '/^msgctxt/{ @@ -225,7 +239,6 @@ p AT_CLEANUP AT_SETUP([gen-options.awk packed format]) -AT_KEYWORDS([gen-options awk script scripts]) AT_DATA([test.c], [[#include struct option { const char *name; int has_arg; int *flag; int val; }; @@ -265,22 +278,18 @@ int main(void) } ]]) -AT_DATA([single.dat], -[[--single-option -]]) -AT_CHECK([$AWK -f "$srcdir/scripts/gen-options.awk" options.h]) +TEST_GEN_OPTIONS([[--single-option +]], [single.dat]) AT_CHECK([$CC -o single$EXEEXT test.c && ./single$EXEEXT], [0], [[0 --single-option, 0, 0 ]]) -AT_DATA([16bit.dat], -[[-a, --the-first-option +TEST_GEN_OPTIONS([[-a, --the-first-option -b, --the-second-option=ARG -c, --the-third-option[=ARG] -d, --the-fourth-option -]]) -AT_CHECK([$AWK -f "$srcdir/scripts/gen-options.awk" <16bit.dat >options.h]) +]], [16bit.dat]) AT_CHECK([$CC -o 16bit$EXEEXT test.c && ./16bit$EXEEXT], [0], [[2 --the-first-option, 0, 'a'