Skip to content

Commit 2a86cb6

Browse files
peffgitster
authored andcommitted
t9103: modernize test style
The main goal here was to avoid double-quotes for surrounding the test snippet, since it makes the code hard to read (and to grep for common problems). But while we're here, we can fix a few other things: - use test_path_* helpers, which are more robust and give better error messages - only "cd" inside a subshell, which leaves the environment pristine if further tests are added - consistently quote shell arguments. These aren't wrong if we assume find-rev output doesn't have any whitespace, but it doesn't hurt to be careful. - replace the old-style 'test x$foo = x' with 'test -z "$foo"'. Besides the quoting fix, this is the form we generally use in our test suite. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9874576 commit 2a86cb6

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

t/t9103-git-svn-tracked-directory-removed.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@ test_expect_success 'make history for tracking' '
2323

2424
test_expect_success 'clone repo with git' '
2525
git svn clone -s "$svnrepo" x &&
26-
test -f x/FOLLOWME &&
27-
test ! -f x/README
26+
test_path_is_file x/FOLLOWME &&
27+
test_path_is_missing x/README
2828
'
2929

30-
test_expect_success 'make sure r2 still has old file' "
31-
cd x &&
32-
test -n \"\$(git svn find-rev r1)\" &&
33-
git reset --hard \$(git svn find-rev r1) &&
34-
test -f README &&
35-
test ! -f FOLLOWME &&
36-
test x\$(git svn find-rev r2) = x
37-
"
30+
test_expect_success 'make sure r2 still has old file' '
31+
(
32+
cd x &&
33+
test -n "$(git svn find-rev r1)" &&
34+
git reset --hard "$(git svn find-rev r1)" &&
35+
test_path_is_file README &&
36+
test_path_is_missing FOLLOWME &&
37+
test -z "$(git svn find-rev r2)"
38+
)
39+
'
3840

3941
test_done

0 commit comments

Comments
 (0)