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 <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Torsten Bögershausen committed
Dec 8, 2012 at 22:33 UTC
173581412819d5be9035e641bc895d5d4a468d6a
1 file changed
+13
-18
t/t9402-git-cvsserver-refs.sh
+13
-18
@@ -28,27 +28,22 @@ check_file() {
28
}
29
30
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
37
}
38
39
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
47
}
48
49
#########