Merge branch 'ls/filter-process'
authorJunio C Hamano <gitster@pobox.com>
Thu, 10 Nov 2016 21:17:30 +0000 (13:17 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 10 Nov 2016 21:17:30 +0000 (13:17 -0800)
Test portability improvements and optimization for an
already-graduated topic.

* ls/filter-process:
t0021: compute file size with a single process instead of a pipeline
t0021: expect more variations in the output of uniq -c

t/t0021-conversion.sh
index a20b9f58e3fe1de2932046d5d7f692b45e3ac854..cb72fa49deb1bc51acd53e01dc980fbb806c67bd 100755 (executable)
@@ -22,7 +22,7 @@ generate_random_characters () {
 }
 
 file_size () {
-       cat "$1" | wc -c | sed "s/^[ ]*//"
+       perl -e 'print -s $ARGV[0]' "$1"
 }
 
 filter_git () {
@@ -40,10 +40,9 @@ test_cmp_count () {
        actual=$2
        for FILE in "$expect" "$actual"
        do
-               sort "$FILE" | uniq -c | sed "s/^[ ]*//" |
-                       sed "s/^\([0-9]\) IN: clean/x IN: clean/" |
-                       sed "s/^\([0-9]\) IN: smudge/x IN: smudge/" >"$FILE.tmp" &&
-               mv "$FILE.tmp" "$FILE"
+               sort "$FILE" | uniq -c |
+               sed -e "s/^ *[0-9][0-9]*[       ]*IN: /x IN: /" >"$FILE.tmp" &&
+               mv "$FILE.tmp" "$FILE" || return
        done &&
        test_cmp "$expect" "$actual"
 }