[PATCH v2 0/2] diff --no-index: fix test blind spots
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-03-21 22:39:09
Possibly related (same subject, not in this thread)
- 2021-03-22 · Re: [PATCH v2 0/2] diff --no-index: fix test blind spots · Junio C Hamano <hidden>
Fixes a stupid s/Test/test/ typo in v1. Thanks Ramsey. I also noticed
a failure on one of the Windows CI's (curiously, not all?), so
POSIXPERM for these tests is another thing I forgot.
I've also added a symlink diff test for good measure. I'm testing the
full output, but using the the approprite variables, so it passes
under both GIT_TEST_DEFAULT_HASH=sha1 & sha256.
Ævar Arnfjörð Bjarmason (2):
diff --no-index tests: add test for --exit-code
diff --no-index tests: test mode normalization
t/t4053-diff-no-index.sh | 60 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
Range-diff:
1: a6e4ed6c3f1 ! 1: 2dbc6c253e2 diff --no-index tests: add test for --exit-code
@@ t/t4053-diff-no-index.sh: test_expect_success 'setup' '
echo 1 >non/git/b
'
--test_expect_success 'git diff --no-index directories' '
+test_expect_success 'git diff --no-index --exit-code' '
+ git diff --no-index --exit-code a/1 non/git/a &&
+ test_expect_code 1 git diff --no-index --exit-code a/1 a/2
+'
+
-+Test_expect_success 'git diff --no-index directories' '
+ test_expect_success 'git diff --no-index directories' '
test_expect_code 1 git diff --no-index a b >cnt &&
test_line_count = 14 cnt
- '
2: 2dcc8bccf97 ! 2: a1ab6a323f2 diff --no-index tests: test mode normalization
@@ t/t4053-diff-no-index.sh: test_expect_success 'diff --no-index allows external d
+ test_must_be_empty out
+'
+
-+test_expect_success 'diff --no-index normalizes mode: chmod +x' '
++test_expect_success POSIXPERM 'diff --no-index normalizes mode: chmod +x' '
+ chmod +x y &&
+ cat >expected <<-\EOF &&
+ diff --git a/x b/y
@@ t/t4053-diff-no-index.sh: test_expect_success 'diff --no-index allows external d
+ test_cmp expected actual
+'
+
-+test_expect_success 'diff --no-index normalizes: mode not like git mode' '
++test_expect_success POSIXPERM 'diff --no-index normalizes: mode not like git mode' '
+ chmod 666 x &&
+ chmod 777 y &&
+ cat >expected <<-\EOF &&
@@ t/t4053-diff-no-index.sh: test_expect_success 'diff --no-index allows external d
+ test_expect_code 1 git diff --no-index x y >actual &&
+ test_cmp expected actual
+'
++
++test_expect_success POSIXPERM,SYMLINKS 'diff --no-index normalizes: mode not like git mode (symlink)' '
++ ln -s y z &&
++ X_OID=$(git hash-object --stdin <x) &&
++ Z_OID=$(echo -n y | git hash-object --stdin) &&
++ cat >expected <<-EOF &&
++ diff --git a/x b/x
++ deleted file mode 100644
++ index $X_OID..$ZERO_OID
++ --- a/x
++ +++ /dev/null
++ @@ -1 +0,0 @@
++ -foo
++ diff --git a/z b/z
++ new file mode 120000
++ index $ZERO_OID..$Z_OID
++ --- /dev/null
++ +++ b/z
++ @@ -0,0 +1 @@
++ +y
++ \ No newline at end of file
++ EOF
++ test_expect_code 1 git -c core.abbrev=no diff --no-index x z >actual &&
++ test_cmp expected actual
++'
+
test_done
--
2.31.0.285.gb40d23e604f