t: use test_must_fail instead of hand-rolled blocks
authorJeff King <peff@peff.net>
Fri, 20 Mar 2015 10:09:22 +0000 (06:09 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Mar 2015 17:20:15 +0000 (10:20 -0700)
These test scripts likely predate test_must_fail, and can be
made simpler by using it (in addition to making them pass
--chain-lint).

The case in t6036 loses some verbosity in the failure case,
but it is so tied to a specific failure mode that it is not
worth keeping around (and the outcome of the test is not
affected at all).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4124-apply-ws-rule.sh
t/t6036-recursive-corner-cases.sh
t/t9300-fast-import.sh
index c6474de4c8c30eba9b5375f6c4e176e67c1fd001..d350065f25c2fb8cd61d9f12f720cf315aa3436d 100755 (executable)
@@ -99,9 +99,8 @@ test_expect_success 'whitespace=warn, default rule' '
 
 test_expect_success 'whitespace=error-all, default rule' '
 
-       apply_patch --whitespace=error-all && return 1
-       test -s target && return 1
-       : happy
+       test_must_fail apply_patch --whitespace=error-all &&
+       ! test -s target
 
 '
 
index 8923b04e60b681d25d874106d8ce223e5349e73d..9d6621c05604e22c258ea21ef0cd549ef4d0d278 100755 (executable)
@@ -195,12 +195,7 @@ test_expect_success 'git detects differently handled merges conflict' '
        git reset --hard &&
        git checkout D^0 &&
 
-       git merge -s recursive E^0 && {
-               echo "BAD: should have conflicted"
-               test "Incorrectly merged content" = "$(cat new_a)" &&
-                       echo "BAD: Silently accepted wrong content"
-               return 1
-       }
+       test_must_fail git merge -s recursive E^0 &&
 
        test 3 = $(git ls-files -s | wc -l) &&
        test 3 = $(git ls-files -u | wc -l) &&
index 584b5383d8eae8692f2e5f7c0b1c61644506f8f4..aac126fd57cc140f90e841e6568152e15d1a90e7 100755 (executable)
@@ -2853,8 +2853,8 @@ test_expect_success 'S: notemodify with garbage after mark commit-ish must fail'
 # from
 #
 test_expect_success 'S: from with garbage after mark must fail' '
-       # no &&
-       git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err
+       test_must_fail \
+       git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err &&
        commit refs/heads/S2
        mark :303
        committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
@@ -2865,9 +2865,6 @@ test_expect_success 'S: from with garbage after mark must fail' '
        M 100644 :403 hello.c
        EOF
 
-       ret=$? &&
-       echo returned $ret &&
-       test $ret -ne 0 && # failed, but it created the commit
 
        # go create the commit, need it for merge test
        git fast-import --import-marks=marks --export-marks=marks <<-EOF &&