t: validate 'test_i18ngrep's parameters
[gitweb.git] / t / test-lib-functions.sh
index 92ed0293712e8875783037a32cb21252087bc589..64f793e3d73e6f7e0ab2d813487efb0b237489d0 100644 (file)
@@ -719,6 +719,18 @@ test_i18ncmp () {
 # under GETTEXT_POISON this pretends that the command produced expected
 # results.
 test_i18ngrep () {
+       eval "last_arg=\${$#}"
+
+       test -f "$last_arg" ||
+       error "bug in the test script: test_i18ngrep requires a file" \
+             "to read as the last parameter"
+
+       if test $# -lt 2 ||
+          { test "x!" = "x$1" && test $# -lt 3 ; }
+       then
+               error "bug in the test script: too few parameters to test_i18ngrep"
+       fi
+
        if test -n "$GETTEXT_POISON"
        then
            : # pretend success