t7800: simplify basic usage test

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>

David Aguilar committed Feb 7, 2017 at 01:16 UTC e66adcadfe63508dfd7410c2253116043894d298
1 file changed +7 -8
t/t7800-difftool.sh
+7 -8
@@ -24,16 +24,15 @@ prompt_given ()
24 }
25
26 test_expect_success 'basic usage requires no repo' '
27 - lines=$(git difftool -h | grep ^usage: | wc -l) &&
28 - test "$lines" -eq 1 &&
27 + test_expect_code 129 git difftool -h >output &&
28 + grep ^usage: output &&
29 # create a ceiling directory to prevent Git from finding a repo
30 mkdir -p not/repo &&
31 - ceiling="$PWD/not" &&
32 - lines=$(cd not/repo &&
33 - GIT_CEILING_DIRECTORIES="$ceiling" git difftool -h |
34 - grep ^usage: | wc -l) &&
35 - test "$lines" -eq 1 &&
36 - rmdir -p not/repo
31 + test_when_finished rm -r not &&
32 + test_expect_code 129 \
33 + env GIT_CEILING_DIRECTORIES="$(pwd)/not" \
34 + git -C not/repo difftool -h >output &&
35 + grep ^usage: output
36 '
37
38 # Create a file on master and change it on branch