]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t7800: simplify basic usage test
authorDavid Aguilar <davvid@gmail.com>
Tue, 7 Feb 2017 09:16:59 +0000 (01:16 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Feb 2017 21:31:20 +0000 (13:31 -0800)
Use "test_line_count" instead of "wc -l", use "git -C" instead of a
subshell, and use test_expect_code when calling difftool.  Ease
debugging by capturing output into temporary files.

Suggested-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7800-difftool.sh

index 1c81f46cbf3b9a229c285afd13dfe627c95b7460..3d728e296d3e3b76cbde00960e12f1731cabd887 100755 (executable)
@@ -24,16 +24,15 @@ prompt_given ()
 }
 
 test_expect_success 'basic usage requires no repo' '
-       lines=$(git difftool -h | grep ^usage: | wc -l) &&
-       test "$lines" -eq 1 &&
+       test_expect_code 129 git difftool -h >output &&
+       grep ^usage: output &&
        # create a ceiling directory to prevent Git from finding a repo
        mkdir -p not/repo &&
-       ceiling="$PWD/not" &&
-       lines=$(cd not/repo &&
-               GIT_CEILING_DIRECTORIES="$ceiling" git difftool -h |
-               grep ^usage: | wc -l) &&
-       test "$lines" -eq 1 &&
-       rmdir -p not/repo
+       test_when_finished rm -r not &&
+       test_expect_code 129 \
+       env GIT_CEILING_DIRECTORIES="$(pwd)/not" \
+       git -C not/repo difftool -h >output &&
+       grep ^usage: output
 '
 
 # Create a file on master and change it on branch