From: Junio C Hamano Date: Mon, 31 Mar 2014 23:31:17 +0000 (-0700) Subject: Merge branch 'jk/tests-cleanup' X-Git-Tag: v2.0.0-rc0~39 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/ad4d8911f8d680ea3948760ba025351ff031736d?ds=inline;hp=-c Merge branch 'jk/tests-cleanup' * jk/tests-cleanup: t0001: drop subshells just for "cd" t0001: drop useless subshells t0001: use test_must_fail t0001: use test_config_global t0001: use test_path_is_* t0001: make symlink reinit test more careful t: prefer "git config --file" to GIT_CONFIG t: prefer "git config --file" to GIT_CONFIG with test_must_fail t: stop using GIT_CONFIG to cross repo boundaries t: drop useless sane_unset GIT_* calls t/test-lib: drop redundant unset of GIT_CONFIG t/Makefile: stop setting GIT_CONFIG --- ad4d8911f8d680ea3948760ba025351ff031736d diff --combined t/t1300-repo-config.sh index 3e3f77b59b,85c6637008..58cd5435be --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@@ -461,7 -461,7 +461,7 @@@ test_expect_success 'new variable inser test_cmp expect .git/config ' - test_expect_success 'alternative GIT_CONFIG (non-existing file should fail)' ' + test_expect_success 'alternative --file (non-existing file should fail)' ' test_must_fail git config --file non-existing-config -l ' @@@ -475,28 -475,15 +475,28 @@@ ein.bahn=strass EOF test_expect_success 'alternative GIT_CONFIG' ' - GIT_CONFIG=other-config git config -l >output && + GIT_CONFIG=other-config git config --list >output && test_cmp expect output ' test_expect_success 'alternative GIT_CONFIG (--file)' ' - git config --file other-config -l > output && + git config --file other-config --list >output && test_cmp expect output ' +test_expect_success 'alternative GIT_CONFIG (--file=-)' ' + git config --file - --list output && + test_cmp expect output +' + +test_expect_success 'setting a value in stdin is an error' ' + test_must_fail git config --file - some.value foo +' + +test_expect_success 'editing stdin is an error' ' + test_must_fail git config --file - --edit +' + test_expect_success 'refer config from subdirectory' ' mkdir x && ( @@@ -508,10 -495,10 +508,10 @@@ ' - test_expect_success 'refer config from subdirectory via GIT_CONFIG' ' + test_expect_success 'refer config from subdirectory via --file' ' ( cd x && - GIT_CONFIG=../other-config git config --get ein.bahn >actual && + git config --file=../other-config --get ein.bahn >actual && test_cmp expect actual ) ' @@@ -523,8 -510,8 +523,8 @@@ cat > expect << EO park = ausweis EOF - test_expect_success '--set in alternative GIT_CONFIG' ' - GIT_CONFIG=other-config git config anwohner.park ausweis && + test_expect_success '--set in alternative file' ' + git config --file=other-config anwohner.park ausweis && test_cmp expect other-config ' @@@ -955,11 -942,11 +955,11 @@@ test_expect_success 'inner whitespace k test_expect_success SYMLINKS 'symlinked configuration' ' ln -s notyet myconfig && - GIT_CONFIG=myconfig git config test.frotz nitfol && + git config --file=myconfig test.frotz nitfol && test -h myconfig && test -f notyet && - test "z$(GIT_CONFIG=notyet git config test.frotz)" = znitfol && - GIT_CONFIG=myconfig git config test.xyzzy rezrov && + test "z$(git config --file=notyet test.frotz)" = znitfol && + git config --file=myconfig test.xyzzy rezrov && test -h myconfig && test -f notyet && cat >expect <<-\EOF && @@@ -967,22 -954,22 +967,22 @@@ rezrov EOF { - GIT_CONFIG=notyet git config test.frotz && - GIT_CONFIG=notyet git config test.xyzzy + git config --file=notyet test.frotz && + git config --file=notyet test.xyzzy } >actual && test_cmp expect actual ' test_expect_success 'nonexistent configuration' ' - test_must_fail env GIT_CONFIG=doesnotexist git config --list && - test_must_fail env GIT_CONFIG=doesnotexist git config test.xyzzy + test_must_fail git config --file=doesnotexist --list && + test_must_fail git config --file=doesnotexist test.xyzzy ' test_expect_success SYMLINKS 'symlink to nonexistent configuration' ' ln -s doesnotexist linktonada && ln -s linktonada linktolinktonada && - test_must_fail env GIT_CONFIG=linktonada git config --list && - test_must_fail env GIT_CONFIG=linktolinktonada git config --list + test_must_fail git config --file=linktonada --list && + test_must_fail git config --file=linktolinktonada --list ' test_expect_success 'check split_cmdline return' " diff --combined t/test-lib.sh index 87f327ff8b,625f06e5e5..c081668dfe --- a/t/test-lib.sh +++ b/t/test-lib.sh @@@ -108,12 -108,6 +108,12 @@@ export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAM export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME export EDITOR +if test -n "${TEST_GIT_INDEX_VERSION:+isset}" +then + GIT_INDEX_VERSION="$TEST_GIT_INDEX_VERSION" + export GIT_INDEX_VERSION +fi + # Add libc MALLOC and MALLOC_PERTURB test # only if we are not executing the test with valgrind if expr " $GIT_TEST_OPTS " : ".* --valgrind " >/dev/null || @@@ -283,7 -277,7 +283,7 @@@ error "Test script did not set test_des if test "$help" = "t" then - echo "$test_description" + printf '%s\n' "$test_description" exit 0 fi @@@ -334,7 -328,7 +334,7 @@@ test_failure_ () test_failure=$(($test_failure + 1)) say_color error "not ok $test_count - $1" shift - echo "$@" | sed -e 's/^/# /' + printf '%s\n' "$*" | sed -e 's/^/# /' test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; } } @@@ -655,7 -649,6 +655,6 @@@ else # normal case, use ../bin-wrapper fi fi GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt - unset GIT_CONFIG GIT_CONFIG_NOSYSTEM=1 GIT_ATTR_NOSYSTEM=1 export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM