Skip to content

Commit 91bac11

Browse files
authored
Merge pull request #5282 from bk2204/negated-grep
t: avoid incorrect negated commands
2 parents 1a6edaf + a5d20de commit 91bac11

File tree

8 files changed

+16
-11
lines changed

8 files changed

+16
-11
lines changed

t/t-attributes.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ begin_test "macros"
3434

3535
cd dir
3636
git lfs track '*.bin' 2>&1 | tee track.log
37-
! grep '"*.bin" already supported' track.log
37+
grep '"*.bin" already supported' track.log && exit 1
38+
true
3839

3940
# NOTE: At present we do not test that "git lfs track" reports
4041
# "already supported" when it finds a pattern in a subdirectory's

t/t-checkout.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ begin_test "checkout"
4949
[ "$contents" = "$(cat folder2/nested.dat)" ]
5050
grep "Checking out LFS objects: 100% (5/5), 95 B" checkout.log
5151
grep 'accepting "file1.dat"' checkout.log
52-
! grep 'rejecting "file1.dat"' checkout.log
52+
grep 'rejecting "file1.dat"' checkout.log && exit 1
5353

5454
# Remove the working directory
5555
rm -rf file1.dat file2.dat file3.dat folder1/nested.dat folder2/nested.dat
@@ -231,7 +231,7 @@ begin_test "checkout: conflicts"
231231
git commit -m "second"
232232

233233
# This will cause a conflict.
234-
! git merge first
234+
git merge first && exit 1
235235

236236
git lfs checkout --to base.txt --base file1.dat
237237
git lfs checkout --to ours.txt --ours file1.dat

t/t-fetch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ begin_test "fetch (shared repository)"
9595
rm -rf .git/lfs/objects
9696

9797
git lfs fetch 2>&1 | tee fetch.log
98-
! grep "Could not scan" fetch.log
98+
grep "Could not scan" fetch.log && exit 1
9999
assert_local_object "$contents_oid" 1
100100

101101
git lfs fsck 2>&1 | tee fsck.log

t/t-migrate-import.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ begin_test "migrate import (--everything with tag pointing to tag)"
846846
assert_pointer "refs/heads/my-feature" "a.md" "$md_feature_oid" "30"
847847

848848
git tag --points-at refs/tags/abc | grep -q def
849-
! git tag --points-at refs/tags/def | grep -q abc
849+
git tag --points-at refs/tags/def | grep -q abc && exit 1
850850

851851
assert_local_object "$md_main_oid" "140"
852852
assert_local_object "$md_feature_oid" "30"

t/t-post-commit.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ begin_test "post-commit does not enter submodules"
101101

102102
git add *.dat
103103
GIT_TRACE=1 git commit -m "Committed large files" 2>&1 | tee output
104-
! grep -E 'filepathfilter:.*submodule/foo' output
104+
grep -E 'filepathfilter:.*submodule/foo' output && exit 1
105+
true
105106
)
106107
end_test

t/t-pre-push.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,8 @@ begin_test "pre-push with pushDefault and explicit remote"
12161216
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin main 2>&1 | tee push.log
12171217

12181218
assert_server_object "$reponame" 98ea6e4f216f2fb4b69fff9b3a44842c38686ca685f3f55dc48c5d3fb1107be4 "refs/heads/main"
1219-
! grep wrong-url push.log
1219+
grep wrong-url push.log && exit 1
1220+
true
12201221
)
12211222
end_test
12221223

@@ -1280,7 +1281,8 @@ begin_test "pre-push does not traverse Git objects server has"
12801281
# Verify that we haven't tried to push or query for the object we already
12811282
# pushed before; i.e., we didn't see it because we ignored its Git object
12821283
# during traversal.
1283-
! grep $contents_oid push.log
1284+
grep $contents_oid push.log && exit 1
1285+
true
12841286
)
12851287
end_test
12861288

t/t-standalone-file.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ begin_test "standalone-file-lfs.url http URL"
455455
[ ${PIPESTATUS[0]} = "0" ]
456456

457457
# We should not use the custom adapter process here.
458-
! grep "xfer: started custom adapter process" push.log
458+
grep "xfer: started custom adapter process" push.log && exit 1
459459
grep -F "$GITSERVER/$reponame" push.log
460460

461461
# Make sure we didn't write to the wrong repo.
@@ -465,7 +465,7 @@ begin_test "standalone-file-lfs.url http URL"
465465
rm -fr .git/lfs/objects
466466

467467
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git lfs fetch --all 2>&1 | tee fetch.log
468-
! grep "xfer: started custom adapter process" fetch.log
468+
grep "xfer: started custom adapter process" fetch.log && exit 1
469469
grep -F "$GITSERVER/$reponame" fetch.log
470470

471471
git lfs fsck

t/t-track.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ begin_test "track --no-excluded"
7474
echo "*.mov -filter=lfs -text" >> a/b/.gitattributes
7575

7676
git lfs track --no-excluded | tee track.log
77-
! grep "Listing excluded patterns" track.log
77+
grep "Listing excluded patterns" track.log && exit 1
78+
true
7879
)
7980
end_test
8081

0 commit comments

Comments
 (0)