Skip to content

Commit e66adca

Browse files
davvidgitster
authored andcommitted
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 <[email protected]> Signed-off-by: David Aguilar <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d81345c commit e66adca

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

t/t7800-difftool.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@ prompt_given ()
2424
}
2525

2626
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 &&
2929
# create a ceiling directory to prevent Git from finding a repo
3030
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
3736
'
3837

3938
# Create a file on master and change it on branch

0 commit comments

Comments
 (0)