Merge branch 'ab/dynamic-gettext-poison'
[gitweb.git] / t / test-lib-functions.sh
index 78d8c3783bd301a3dd2bf7061f04e08368d7ca37..4397c01be03b376b7eb942c0e89032190ad82313 100644 (file)
@@ -747,6 +747,29 @@ test_cmp() {
        $GIT_TEST_CMP "$@"
 }
 
+# Check that the given config key has the expected value.
+#
+#    test_cmp_config [-C <dir>] <expected-value>
+#                    [<git-config-options>...] <config-key>
+#
+# for example to check that the value of core.bar is foo
+#
+#    test_cmp_config foo core.bar
+#
+test_cmp_config() {
+       local GD &&
+       if test "$1" = "-C"
+       then
+               shift &&
+               GD="-C $1" &&
+               shift
+       fi &&
+       printf "%s\n" "$1" >expect.config &&
+       shift &&
+       git $GD config "$@" >actual.config &&
+       test_cmp expect.config actual.config
+}
+
 # test_cmp_bin - helper to compare binary files
 
 test_cmp_bin() {
@@ -755,16 +778,16 @@ test_cmp_bin() {
 
 # 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
+# under GIT_TEST_GETTEXT_POISON this pretends that the command produced expected
 # results.
 test_i18ncmp () {
-       test -n "$GETTEXT_POISON" || test_cmp "$@"
+       ! test_have_prereq C_LOCALE_OUTPUT || 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
+# under GIT_TEST_GETTEXT_POISON this pretends that the command produced expected
 # results.
 test_i18ngrep () {
        eval "last_arg=\${$#}"
@@ -779,7 +802,7 @@ test_i18ngrep () {
                error "bug in the test script: too few parameters to test_i18ngrep"
        fi
 
-       if test -n "$GETTEXT_POISON"
+       if test_have_prereq !C_LOCALE_OUTPUT
        then
                # pretend success
                return 0