Skip to content

Commit 1735814

Browse files
tboegigitster
authored andcommitted
t9402: improve check_end_tree() and check_end_full_tree()
check_end_tree(): - Instead of counting lines using wc in expectCount and cvsCount: Sort and compare the files byte by byte with test_cmp, which is more exact and easier to debug - Chain all shell comands together using && check_end_full_tree() - Instead of counting lines using wc in expectCount, cvsCount and gitCount: Sort and compare the files byte by byte with test_cmp, which is more exact and easier to debug - Break the test using two conditions anded together with -a into to call to test_cmp - Chain all shell comands together using && Signed-off-by: Torsten Bögershausen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 76095f6 commit 1735814

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

t/t9402-git-cvsserver-refs.sh

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,22 @@ check_file() {
2828
}
2929

3030
check_end_tree() {
31-
sandbox="$1"
32-
expectCount=$(wc -l < "$WORKDIR/check.list")
33-
cvsCount=$(find "$sandbox" -name CVS -prune -o -type f -print | wc -l)
34-
test x"$cvsCount" = x"$expectCount"
35-
stat=$?
36-
echo "check_end $sandbox : $stat cvs=$cvsCount expect=$expectCount" \
37-
>> "$WORKDIR/check.log"
38-
return $stat
31+
sandbox="$1" &&
32+
find "$sandbox" -name CVS -prune -o -type f -print >"$WORKDIR/check.cvsCount" &&
33+
sort <"$WORKDIR/check.list" >expected &&
34+
sort <"$WORKDIR/check.cvsCount" | sed -e "s%cvswork/%%" >actual &&
35+
test_cmp expected actual &&
36+
rm expected actual
3937
}
4038

4139
check_end_full_tree() {
42-
sandbox="$1"
43-
ver="$2"
44-
expectCount=$(wc -l < "$WORKDIR/check.list")
45-
cvsCount=$(find "$sandbox" -name CVS -prune -o -type f -print | wc -l)
46-
gitCount=$(git ls-tree -r "$2" | wc -l)
47-
test x"$cvsCount" = x"$expectCount" -a x"$gitCount" = x"$expectCount"
48-
stat=$?
49-
echo "check_end $sandbox : $stat cvs=$cvsCount git=$gitCount expect=$expectCount" \
50-
>> "$WORKDIR/check.log"
51-
return $stat
40+
sandbox="$1" &&
41+
sort <"$WORKDIR/check.list" >expected &&
42+
find "$sandbox" -name CVS -prune -o -type f -print | sed -e "s%$sandbox/%%" | sort >act1 &&
43+
test_cmp expected act1 &&
44+
git ls-tree -r "$2" | sed -e "s/^.*blob [0-9a-fA-F]*[ ]*//" | sort >act2 &&
45+
test_cmp expected act2 &&
46+
rm expected act1 act2
5247
}
5348

5449
#########

0 commit comments

Comments
 (0)