From: Brian Gernhardt <brian@gernhardtsoftware.com>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] t6022: Use -eq not = to test output of wc -l
Date: Mon, 8 Nov 2010 16:29:26 -0500 [thread overview]
Message-ID: <1289251766-48316-1-git-send-email-brian@gernhardtsoftware.com> (raw)
When comparing numbers such as "3" to "$(wc -l)", we should check for
numerical equality using -eq instead of string equality using = because
some implementations of wc output extra whitespace.
Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
---
The alternative would be to use 3 = $(wc -l) (sans quotes), but other parts
of the test used the -eq method.
t/t6022-merge-rename.sh | 64 +++++++++++++++++++++++-----------------------
1 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh
index 422092e..66473f0 100755
--- a/t/t6022-merge-rename.sh
+++ b/t/t6022-merge-rename.sh
@@ -404,8 +404,8 @@ test_expect_success 'Rename+D/F conflict; renamed file merges but dir in way' '
grep "Auto-merging dir" output &&
grep "Adding as dir~HEAD instead" output &&
- test 2 = "$(git ls-files -u | wc -l)" &&
- test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
+ test 2 -eq "$(git ls-files -u | wc -l)" &&
+ test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
test_must_fail git diff --quiet &&
test_must_fail git diff --cached --quiet &&
@@ -426,8 +426,8 @@ test_expect_success 'Same as previous, but merged other way' '
grep "Auto-merging dir" output &&
grep "Adding as dir~renamed-file-has-no-conflicts instead" output &&
- test 2 = "$(git ls-files -u | wc -l)" &&
- test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
+ test 2 -eq "$(git ls-files -u | wc -l)" &&
+ test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
test_must_fail git diff --quiet &&
test_must_fail git diff --cached --quiet &&
@@ -461,8 +461,8 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge, dir not in
git checkout -q renamed-file-has-conflicts^0 &&
test_must_fail git merge --strategy=recursive dir-not-in-way &&
- test 3 = "$(git ls-files -u | wc -l)" &&
- test 3 = "$(git ls-files -u dir | wc -l)" &&
+ test 3 -eq "$(git ls-files -u | wc -l)" &&
+ test 3 -eq "$(git ls-files -u dir | wc -l)" &&
test_must_fail git diff --quiet &&
test_must_fail git diff --cached --quiet &&
@@ -479,9 +479,9 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge and dir in t
git checkout -q renamed-file-has-conflicts^0 &&
test_must_fail git merge --strategy=recursive dir-in-way &&
- test 5 = "$(git ls-files -u | wc -l)" &&
- test 3 = "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
- test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
+ test 5 -eq "$(git ls-files -u | wc -l)" &&
+ test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
+ test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
test_must_fail git diff --quiet &&
test_must_fail git diff --cached --quiet &&
@@ -515,9 +515,9 @@ test_expect_success 'Same as previous, but merged other way' '
git checkout -q dir-in-way^0 &&
test_must_fail git merge --strategy=recursive renamed-file-has-conflicts &&
- test 5 = "$(git ls-files -u | wc -l)" &&
- test 3 = "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
- test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
+ test 5 -eq "$(git ls-files -u | wc -l)" &&
+ test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
+ test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
test_must_fail git diff --quiet &&
test_must_fail git diff --cached --quiet &&
@@ -555,7 +555,7 @@ test_expect_success 'both rename source and destination involved in D/F conflict
git checkout -q rename-dest^0 &&
test_must_fail git merge --strategy=recursive source-conflict &&
- test 1 = "$(git ls-files -u | wc -l)" &&
+ test 1 -eq "$(git ls-files -u | wc -l)" &&
test_must_fail git diff --quiet &&
@@ -594,13 +594,13 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ untracked
mkdir one &&
test_must_fail git merge --strategy=recursive rename-two &&
- test 2 = "$(git ls-files -u | wc -l)" &&
- test 1 = "$(git ls-files -u one | wc -l)" &&
- test 1 = "$(git ls-files -u two | wc -l)" &&
+ test 2 -eq "$(git ls-files -u | wc -l)" &&
+ test 1 -eq "$(git ls-files -u one | wc -l)" &&
+ test 1 -eq "$(git ls-files -u two | wc -l)" &&
test_must_fail git diff --quiet &&
- test 4 = $(find . | grep -v .git | wc -l) &&
+ test 4 -eq $(find . | grep -v .git | wc -l) &&
test -d one &&
test -f one~rename-two &&
@@ -614,13 +614,13 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ clean sta
git clean -fdqx &&
test_must_fail git merge --strategy=recursive rename-two &&
- test 2 = "$(git ls-files -u | wc -l)" &&
- test 1 = "$(git ls-files -u one | wc -l)" &&
- test 1 = "$(git ls-files -u two | wc -l)" &&
+ test 2 -eq "$(git ls-files -u | wc -l)" &&
+ test 1 -eq "$(git ls-files -u one | wc -l)" &&
+ test 1 -eq "$(git ls-files -u two | wc -l)" &&
test_must_fail git diff --quiet &&
- test 3 = $(find . | grep -v .git | wc -l) &&
+ test 3 -eq $(find . | grep -v .git | wc -l) &&
test -f one &&
test -f two &&
@@ -656,12 +656,12 @@ test_expect_success 'check handling of differently renamed file with D/F conflic
git checkout -q first-rename^0 &&
test_must_fail git merge --strategy=recursive second-rename &&
- test 5 = "$(git ls-files -s | wc -l)" &&
- test 3 = "$(git ls-files -u | wc -l)" &&
- test 1 = "$(git ls-files -u one | wc -l)" &&
- test 1 = "$(git ls-files -u two | wc -l)" &&
- test 1 = "$(git ls-files -u original | wc -l)" &&
- test 2 = "$(git ls-files -o | wc -l)" &&
+ test 5 -eq "$(git ls-files -s | wc -l)" &&
+ test 3 -eq "$(git ls-files -u | wc -l)" &&
+ test 1 -eq "$(git ls-files -u one | wc -l)" &&
+ test 1 -eq "$(git ls-files -u two | wc -l)" &&
+ test 1 -eq "$(git ls-files -u original | wc -l)" &&
+ test 2 -eq "$(git ls-files -o | wc -l)" &&
test -f one/file &&
test -f two/file &&
@@ -696,11 +696,11 @@ test_expect_success 'check handling of differently renamed file with D/F conflic
git checkout -q first-rename-redo^0 &&
test_must_fail git merge --strategy=recursive second-rename-redo &&
- test 3 = "$(git ls-files -u | wc -l)" &&
- test 1 = "$(git ls-files -u one | wc -l)" &&
- test 1 = "$(git ls-files -u two | wc -l)" &&
- test 1 = "$(git ls-files -u original | wc -l)" &&
- test 0 = "$(git ls-files -o | wc -l)" &&
+ test 3 -eq "$(git ls-files -u | wc -l)" &&
+ test 1 -eq "$(git ls-files -u one | wc -l)" &&
+ test 1 -eq "$(git ls-files -u two | wc -l)" &&
+ test 1 -eq "$(git ls-files -u original | wc -l)" &&
+ test 0 -eq "$(git ls-files -o | wc -l)" &&
test -f one &&
test -f two &&
--
1.7.3.2.333.g23b6d8
next reply other threads:[~2010-11-08 21:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-08 21:29 Brian Gernhardt [this message]
2010-11-08 21:35 ` [PATCH] t6022: Use -eq not = to test output of wc -l Ævar Arnfjörð Bjarmason
2010-11-08 21:38 ` Jonathan Nieder
2010-11-15 22:21 ` Junio C Hamano
2010-11-16 6:46 ` Bert Wesarg
2010-11-16 7:12 ` Johannes Sixt
2010-11-16 17:10 ` Jonathan Nieder
2010-11-16 19:10 ` Junio C Hamano
2010-11-16 19:23 ` Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1289251766-48316-1-git-send-email-brian@gernhardtsoftware.com \
--to=brian@gernhardtsoftware.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).