t: move 'test_i18ncmp' and 'test_i18ngrep' to 'test-lib-functions.sh'
[gitweb.git] / t / test-lib-functions.sh
index 1701fe2a06057530d845b91b4fd4cce99b4521a2..92ed0293712e8875783037a32cb21252087bc589 100644 (file)
@@ -705,6 +705,32 @@ test_cmp_bin() {
        cmp "$@"
 }
 
+# Use this instead of test_cmp to compare files that contain expected and
+# actual output from git commands that can be translated.  When running
+# under GETTEXT_POISON this pretends that the command produced expected
+# results.
+test_i18ncmp () {
+       test -n "$GETTEXT_POISON" || test_cmp "$@"
+}
+
+# Use this instead of "grep expected-string actual" to see if the
+# output from a git command that can be translated either contains an
+# expected string, or does not contain an unwanted one.  When running
+# under GETTEXT_POISON this pretends that the command produced expected
+# results.
+test_i18ngrep () {
+       if test -n "$GETTEXT_POISON"
+       then
+           : # pretend success
+       elif test "x!" = "x$1"
+       then
+               shift
+               ! grep "$@"
+       else
+               grep "$@"
+       fi
+}
+
 # Call any command "$@" but be more verbose about its
 # failure. This is handy for commands like "test" which do
 # not output anything when they fail.