Skip to content

Commit 3f96d75

Browse files
avargitster
authored andcommitted
cache-tree tests: refactor for modern test style
Refactor the cache-tree test file to use our current recommended patterns. This makes a subsequent meaningful change easier to read. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 66e871b commit 3f96d75

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

t/t0090-cache-tree.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ cache-tree extension.
1010
cmp_cache_tree () {
1111
test-tool dump-cache-tree | sed -e '/#(ref)/d' >actual &&
1212
sed "s/$OID_REGEX/SHA/" <actual >filtered &&
13-
test_cmp "$1" filtered
13+
test_cmp "$1" filtered &&
14+
rm filtered
1415
}
1516

1617
# We don't bother with actually checking the SHA1:
@@ -54,7 +55,7 @@ test_invalid_cache_tree () {
5455
}
5556

5657
test_no_cache_tree () {
57-
: >expect &&
58+
>expect &&
5859
cmp_cache_tree expect
5960
}
6061

@@ -83,28 +84,27 @@ test_expect_success 'git-add in subdir invalidates cache-tree' '
8384
test_invalid_cache_tree
8485
'
8586

86-
cat >before <<\EOF
87-
SHA (3 entries, 2 subtrees)
88-
SHA dir1/ (1 entries, 0 subtrees)
89-
SHA dir2/ (1 entries, 0 subtrees)
90-
EOF
91-
92-
cat >expect <<\EOF
93-
invalid (2 subtrees)
94-
invalid dir1/ (0 subtrees)
95-
SHA dir2/ (1 entries, 0 subtrees)
96-
EOF
97-
9887
test_expect_success 'git-add in subdir does not invalidate sibling cache-tree' '
9988
git tag no-children &&
10089
test_when_finished "git reset --hard no-children; git read-tree HEAD" &&
10190
mkdir dir1 dir2 &&
10291
test_commit dir1/a &&
10392
test_commit dir2/b &&
10493
echo "I changed this file" >dir1/a &&
94+
test_when_finished "rm before" &&
95+
cat >before <<-\EOF &&
96+
SHA (3 entries, 2 subtrees)
97+
SHA dir1/ (1 entries, 0 subtrees)
98+
SHA dir2/ (1 entries, 0 subtrees)
99+
EOF
105100
cmp_cache_tree before &&
106101
echo "I changed this file" >dir1/a &&
107102
git add dir1/a &&
103+
cat >expect <<-\EOF &&
104+
invalid (2 subtrees)
105+
invalid dir1/ (0 subtrees)
106+
SHA dir2/ (1 entries, 0 subtrees)
107+
EOF
108108
cmp_cache_tree expect
109109
'
110110

0 commit comments

Comments
 (0)