{"thread":{"id":"32295","subject":"[PATCH 2/8] t9402: improve check_end_tree() and check_end_full_tree()","startedAt":"2012-12-08T21:33:55Z","lastAt":"2012-12-08T21:33:55Z","messageCount":1,"participants":["Torsten Bögershausen"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"204610","messageId":"201212082233.56082.tboegi@web.de","threadId":"32295","inReplyTo":null,"subject":"[PATCH 2/8] t9402: improve check_end_tree() and check_end_full_tree()","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2012-12-08T21:33:55Z","receivedAt":"2012-12-08T21:33:55Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"check_end_tree():\n- Instead of counting lines using wc in expectCount and cvsCount:\n   Sort and compare the files byte by byte with test_cmp,\n   which is more exact and easier to debug\n- Chain all shell comands together using &&\n\ncheck_end_full_tree()\n- Instead of counting lines using wc in expectCount, cvsCount and gitCount:\n   Sort and compare the files byte by byte with test_cmp,\n   which is more exact and easier to debug\n- Break the test using two conditions anded together with -a\n  into to call to test_cmp\n- Chain all shell comands together using &&\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n t/t9402-git-cvsserver-refs.sh | 31 +++++++++++++------------------\n 1 file changed, 13 insertions(+), 18 deletions(-)\n\ndiff --git a/t/t9402-git-cvsserver-refs.sh b/t/t9402-git-cvsserver-refs.sh\nindex c01748a..f1bea0f 100755\n--- a/t/t9402-git-cvsserver-refs.sh\n+++ b/t/t9402-git-cvsserver-refs.sh\n@@ -28,27 +28,22 @@ check_file() {\n }\n \n check_end_tree() {\n-    sandbox=\"$1\"\n-    expectCount=$(wc -l < \"$WORKDIR/check.list\")\n-    cvsCount=$(find \"$sandbox\" -name CVS -prune -o -type f -print | wc -l)\n-    test x\"$cvsCount\" = x\"$expectCount\"\n-    stat=$?\n-    echo \"check_end $sandbox : $stat cvs=$cvsCount expect=$expectCount\" \\\n-\t>> \"$WORKDIR/check.log\"\n-    return $stat\n+    sandbox=\"$1\" &&\n+    find \"$sandbox\" -name CVS -prune -o -type f -print >\"$WORKDIR/check.cvsCount\" &&\n+\t\tsort <\"$WORKDIR/check.list\" >expected &&\n+\t\tsort <\"$WORKDIR/check.cvsCount\" | sed -e \"s%cvswork/%%\" >actual &&\n+    test_cmp expected actual &&\n+\t\trm expected actual\n }\n \n check_end_full_tree() {\n-    sandbox=\"$1\"\n-    ver=\"$2\"\n-    expectCount=$(wc -l < \"$WORKDIR/check.list\")\n-    cvsCount=$(find \"$sandbox\" -name CVS -prune -o -type f -print | wc -l)\n-    gitCount=$(git ls-tree -r \"$2\" | wc -l)\n-    test x\"$cvsCount\" = x\"$expectCount\" -a x\"$gitCount\" = x\"$expectCount\"\n-    stat=$?\n-    echo \"check_end $sandbox : $stat cvs=$cvsCount git=$gitCount expect=$expectCount\" \\\n-\t>> \"$WORKDIR/check.log\"\n-    return $stat\n+    sandbox=\"$1\" &&\n+    sort <\"$WORKDIR/check.list\" >expected &&\n+    find \"$sandbox\" -name CVS -prune -o -type f -print | sed -e \"s%$sandbox/%%\" | sort >act1 &&\n+\t\ttest_cmp expected act1 &&\n+    git ls-tree -r \"$2\" | sed -e \"s/^.*blob [0-9a-fA-F]*[\t ]*//\" | sort >act2 &&\n+\t\ttest_cmp expected act2 &&\n+    rm expected act1 act2\n }\n \n #########\n-- \n1.8.0.197.g5a90748\n"}]}