@matheusbsbs / matheus-bagliano / commits / 9f6cea97c9
Fork 0

t6022: Use -eq not = to test output of wc -l

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brian Gernhardt committed Nov 8, 2010 at 16:29 UTC 9f6cea97c97ee505bd6771db7df69f04df9b4fc4
1 file changed +32 -32
t/t6022-merge-rename.sh
+32 -32
@@ -404,8 +404,8 @@ test_expect_success 'Rename+D/F conflict; renamed file merges but dir in way' '
404 grep "Auto-merging dir" output &&
405 grep "Adding as dir~HEAD instead" output &&
406
407 - test 2 = "$(git ls-files -u | wc -l)" &&
408 - test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
407 + test 2 -eq "$(git ls-files -u | wc -l)" &&
408 + test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
409
410 test_must_fail git diff --quiet &&
411 test_must_fail git diff --cached --quiet &&
@@ -426,8 +426,8 @@ test_expect_success 'Same as previous, but merged other way' '
426 grep "Auto-merging dir" output &&
427 grep "Adding as dir~renamed-file-has-no-conflicts instead" output &&
428
429 - test 2 = "$(git ls-files -u | wc -l)" &&
430 - test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
429 + test 2 -eq "$(git ls-files -u | wc -l)" &&
430 + test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
431
432 test_must_fail git diff --quiet &&
433 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
461 git checkout -q renamed-file-has-conflicts^0 &&
462 test_must_fail git merge --strategy=recursive dir-not-in-way &&
463
464 - test 3 = "$(git ls-files -u | wc -l)" &&
465 - test 3 = "$(git ls-files -u dir | wc -l)" &&
464 + test 3 -eq "$(git ls-files -u | wc -l)" &&
465 + test 3 -eq "$(git ls-files -u dir | wc -l)" &&
466
467 test_must_fail git diff --quiet &&
468 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
479 git checkout -q renamed-file-has-conflicts^0 &&
480 test_must_fail git merge --strategy=recursive dir-in-way &&
481
482 - test 5 = "$(git ls-files -u | wc -l)" &&
483 - test 3 = "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
484 - test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
482 + test 5 -eq "$(git ls-files -u | wc -l)" &&
483 + test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
484 + test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
485
486 test_must_fail git diff --quiet &&
487 test_must_fail git diff --cached --quiet &&
@@ -515,9 +515,9 @@ test_expect_success 'Same as previous, but merged other way' '
515 git checkout -q dir-in-way^0 &&
516 test_must_fail git merge --strategy=recursive renamed-file-has-conflicts &&
517
518 - test 5 = "$(git ls-files -u | wc -l)" &&
519 - test 3 = "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
520 - test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
518 + test 5 -eq "$(git ls-files -u | wc -l)" &&
519 + test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
520 + test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
521
522 test_must_fail git diff --quiet &&
523 test_must_fail git diff --cached --quiet &&
@@ -555,7 +555,7 @@ test_expect_success 'both rename source and destination involved in D/F conflict
555 git checkout -q rename-dest^0 &&
556 test_must_fail git merge --strategy=recursive source-conflict &&
557
558 - test 1 = "$(git ls-files -u | wc -l)" &&
558 + test 1 -eq "$(git ls-files -u | wc -l)" &&
559
560 test_must_fail git diff --quiet &&
561
@@ -594,13 +594,13 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ untracked
594 mkdir one &&
595 test_must_fail git merge --strategy=recursive rename-two &&
596
597 - test 2 = "$(git ls-files -u | wc -l)" &&
598 - test 1 = "$(git ls-files -u one | wc -l)" &&
599 - test 1 = "$(git ls-files -u two | wc -l)" &&
597 + test 2 -eq "$(git ls-files -u | wc -l)" &&
598 + test 1 -eq "$(git ls-files -u one | wc -l)" &&
599 + test 1 -eq "$(git ls-files -u two | wc -l)" &&
600
601 test_must_fail git diff --quiet &&
602
603 - test 4 = $(find . | grep -v .git | wc -l) &&
603 + test 4 -eq $(find . | grep -v .git | wc -l) &&
604
605 test -d one &&
606 test -f one~rename-two &&
@@ -614,13 +614,13 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ clean sta
614 git clean -fdqx &&
615 test_must_fail git merge --strategy=recursive rename-two &&
616
617 - test 2 = "$(git ls-files -u | wc -l)" &&
618 - test 1 = "$(git ls-files -u one | wc -l)" &&
619 - test 1 = "$(git ls-files -u two | wc -l)" &&
617 + test 2 -eq "$(git ls-files -u | wc -l)" &&
618 + test 1 -eq "$(git ls-files -u one | wc -l)" &&
619 + test 1 -eq "$(git ls-files -u two | wc -l)" &&
620
621 test_must_fail git diff --quiet &&
622
623 - test 3 = $(find . | grep -v .git | wc -l) &&
623 + test 3 -eq $(find . | grep -v .git | wc -l) &&
624
625 test -f one &&
626 test -f two &&
@@ -656,12 +656,12 @@ test_expect_success 'check handling of differently renamed file with D/F conflic
656 git checkout -q first-rename^0 &&
657 test_must_fail git merge --strategy=recursive second-rename &&
658
659 - test 5 = "$(git ls-files -s | wc -l)" &&
660 - test 3 = "$(git ls-files -u | wc -l)" &&
661 - test 1 = "$(git ls-files -u one | wc -l)" &&
662 - test 1 = "$(git ls-files -u two | wc -l)" &&
663 - test 1 = "$(git ls-files -u original | wc -l)" &&
664 - test 2 = "$(git ls-files -o | wc -l)" &&
659 + test 5 -eq "$(git ls-files -s | wc -l)" &&
660 + test 3 -eq "$(git ls-files -u | wc -l)" &&
661 + test 1 -eq "$(git ls-files -u one | wc -l)" &&
662 + test 1 -eq "$(git ls-files -u two | wc -l)" &&
663 + test 1 -eq "$(git ls-files -u original | wc -l)" &&
664 + test 2 -eq "$(git ls-files -o | wc -l)" &&
665
666 test -f one/file &&
667 test -f two/file &&
@@ -696,11 +696,11 @@ test_expect_success 'check handling of differently renamed file with D/F conflic
696 git checkout -q first-rename-redo^0 &&
697 test_must_fail git merge --strategy=recursive second-rename-redo &&
698
699 - test 3 = "$(git ls-files -u | wc -l)" &&
700 - test 1 = "$(git ls-files -u one | wc -l)" &&
701 - test 1 = "$(git ls-files -u two | wc -l)" &&
702 - test 1 = "$(git ls-files -u original | wc -l)" &&
703 - test 0 = "$(git ls-files -o | wc -l)" &&
699 + test 3 -eq "$(git ls-files -u | wc -l)" &&
700 + test 1 -eq "$(git ls-files -u one | wc -l)" &&
701 + test 1 -eq "$(git ls-files -u two | wc -l)" &&
702 + test 1 -eq "$(git ls-files -u original | wc -l)" &&
703 + test 0 -eq "$(git ls-files -o | wc -l)" &&
704
705 test -f one &&
706 test -f two &&