@matheusbsbs / matheus-bagliano / commits / 87539416fd
Fork 0

tests: grep portability fixes

We try to avoid using the "-q" or "-e" options, as they are largely useless, as explained in aadbe44f. There is one exception for "-e" here, which is in t7701 used to produce an "or" of patterns. This can be rewritten as an egrep pattern. This patch also removes use of "grep -F" in favor of the more widely available "fgrep". [sp: Tested on AIX 5.3 by Mike Ralphson, Tested on MinGW by Johannes Sixt] Signed-off-by: Jeff King <peff@peff.net> Tested-by: Mike Ralphson <mike@abacus.co.uk> Tested-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Jeff King committed Sep 30, 2008 at 04:03 UTC 87539416fd25bfa62122ddf4f7a7b8794d5d5aa2
8 files changed +11 -11
t/t0002-gitfile.sh
+2 -2
@@ -32,7 +32,7 @@ test_expect_success 'bad setup: invalid .git file format' '
32 echo "git rev-parse accepted an invalid .git file"
33 false
34 fi &&
35 - if ! grep -qe "Invalid gitfile format" .err
35 + if ! grep "Invalid gitfile format" .err
36 then
37 echo "git rev-parse returned wrong error"
38 false
@@ -46,7 +46,7 @@ test_expect_success 'bad setup: invalid .git file path' '
46 echo "git rev-parse accepted an invalid .git file path"
47 false
48 fi &&
49 - if ! grep -qe "Not a git repository" .err
49 + if ! grep "Not a git repository" .err
50 then
51 echo "git rev-parse returned wrong error"
52 false
t/t1501-worktree.sh
+1 -1
@@ -171,7 +171,7 @@ test_expect_success 'git diff' '
171
172 test_expect_success 'git grep' '
173 (cd repo.git/work/sub &&
174 - GIT_DIR=../.. GIT_WORK_TREE=.. git grep -l changed | grep -q dir/tracked)
174 + GIT_DIR=../.. GIT_WORK_TREE=.. git grep -l changed | grep dir/tracked)
175 '
176
177 test_done
t/t3700-add.sh
+1 -1
@@ -226,7 +226,7 @@ test_expect_success 'git add '\''fo\[ou\]bar'\'' ignores foobar' '
226 git reset --hard &&
227 touch fo\[ou\]bar foobar &&
228 git add '\''fo\[ou\]bar'\'' &&
229 - git ls-files fo\[ou\]bar | grep -F fo\[ou\]bar &&
229 + git ls-files fo\[ou\]bar | fgrep fo\[ou\]bar &&
230 ! ( git ls-files foobar | grep foobar )
231 '
232
t/t4150-am.sh
+1 -1
@@ -165,7 +165,7 @@ test_expect_success 'am --keep really keeps the subject' '
165 git am --keep patch4 &&
166 ! test -d .git/rebase-apply &&
167 git cat-file commit HEAD |
168 - grep -q -F "Re: Re: Re: [PATCH 1/5 v2] third"
168 + fgrep "Re: Re: Re: [PATCH 1/5 v2] third"
169 '
170
171 test_expect_success 'am -3 falls back to 3-way merge' '
t/t6040-tracking-info.sh
+2 -2
@@ -53,7 +53,7 @@ test_expect_success 'checkout' '
53 (
54 cd test && git checkout b1
55 ) >actual &&
56 - grep -e "have 1 and 1 different" actual
56 + grep "have 1 and 1 different" actual
57 '
58
59 test_expect_success 'status' '
@@ -63,7 +63,7 @@ test_expect_success 'status' '
63 # reports nothing to commit
64 test_must_fail git status
65 ) >actual &&
66 - grep -e "have 1 and 1 different" actual
66 + grep "have 1 and 1 different" actual
67 '
68
69
t/t7002-grep.sh
+1 -1
@@ -109,7 +109,7 @@ do
109 '
110
111 test_expect_success "grep -c $L (no /dev/null)" '
112 - ! git grep -c test $H | grep -q /dev/null
112 + ! git grep -c test $H | grep /dev/null
113 '
114
115 done
t/t7701-repack-unpack-unreachable.sh
+2 -2
@@ -29,7 +29,7 @@ test_expect_success '-A option leaves unreachable objects unpacked' '
29 git repack -A -d -l &&
30 # verify objects are packed in repository
31 test 3 = $(git verify-pack -v -- .git/objects/pack/*.idx |
32 - grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " |
32 + egrep "^($fsha1|$csha1|$tsha1) " |
33 sort | uniq | wc -l) &&
34 git show $fsha1 &&
35 git show $csha1 &&
@@ -41,7 +41,7 @@ test_expect_success '-A option leaves unreachable objects unpacked' '
41 git repack -A -d -l &&
42 # verify objects are retained unpacked
43 test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
44 - grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " |
44 + egrep "^($fsha1|$csha1|$tsha1) " |
45 sort | uniq | wc -l) &&
46 git show $fsha1 &&
47 git show $csha1 &&
t/t9500-gitweb-standalone-no-errors.sh
+1 -1
@@ -56,7 +56,7 @@ gitweb_run () {
56 rm -f gitweb.log &&
57 perl -- "$TEST_DIRECTORY/../gitweb/gitweb.perl" \
58 >/dev/null 2>gitweb.log &&
59 - if grep -q -s "^[[]" gitweb.log >/dev/null; then false; else true; fi
59 + if grep "^[[]" gitweb.log >/dev/null 2>&1; then false; else true; fi
60
61 # gitweb.log is left for debugging
62 }