From: "Mark C. Chu-Carroll" <markchucarroll@fastmail.com>
To: git@vger.kernel.org
Cc: "Mark C. Chu-Carroll" <markchucarroll@fastmail.com>
Subject: [PATCH v6 3/3] t4010: modernize
Date: Tue, 22 Sep 2026 16:21:52 -0400 [thread overview]
Message-ID: <20260922202152.842793-4-markchucarroll@fastmail.com> (raw)
In-Reply-To: <20260922202152.842793-1-markchucarroll@fastmail.com>
Old tests were written in a different style than modern
ones; for better readability and test error messages,
update t4010 to the modern style.
* run everything inside of a test_expect_success block.
* write title line on the same line as test_expect_success,
end that line with a single quote that opens the body of the test,
and end the test with a single quote that closes the body.
* write expected output of a test to a file named "expect",
and actual output to a file named "actual".
* write here-docs using "<<-" syntax, so that they're indented
uniformly with the rest of the test.
* make test names more clearly reflect the functionality that
they test.
Signed-off-by: Mark C. Chu-Carroll <markchucarroll@fastmail.com>
---
t/t4010-diff-pathspec.sh | 122 +++++++++++++++++++--------------------
1 file changed, 61 insertions(+), 61 deletions(-)
diff --git a/t/t4010-diff-pathspec.sh b/t/t4010-diff-pathspec.sh
index c84c3fa05b..03b3023bee 100755
--- a/t/t4010-diff-pathspec.sh
+++ b/t/t4010-diff-pathspec.sh
@@ -13,67 +13,67 @@ Prepare:
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
-test_expect_success \
- setup \
- 'echo frotz >file0 &&
- mkdir path1 &&
- echo rezrov >path1/file1 &&
- before0=$(git hash-object file0) &&
- before1=$(git hash-object path1/file1) &&
- git update-index --add file0 path1/file1 &&
- tree=$(git write-tree) &&
- echo "$tree" &&
- echo nitfol >file0 &&
- echo yomin >path1/file1 &&
- after0=$(git hash-object file0) &&
- after1=$(git hash-object path1/file1) &&
- git update-index file0 path1/file1'
-
-cat >expected <<\EOF
-EOF
-test_expect_success \
- 'limit to path should show nothing' \
- 'git diff-index --cached $tree -- path >current &&
- compare_diff_raw current expected'
-
-cat >expected <<EOF
-:100644 100644 $before1 $after1 M path1/file1
-EOF
-test_expect_success \
- 'limit to path1 should show path1/file1' \
- 'git diff-index --cached $tree -- path1 >current &&
- compare_diff_raw current expected'
-
-cat >expected <<EOF
-:100644 100644 $before1 $after1 M path1/file1
-EOF
-test_expect_success \
- 'limit to path1/ should show path1/file1' \
- 'git diff-index --cached $tree -- path1/ >current &&
- compare_diff_raw current expected'
-
-cat >expected <<EOF
-:100644 100644 $before1 $after1 M path1/file1
-EOF
-test_expect_success \
- '"*file1" should show path1/file1' \
- 'git diff-index --cached $tree -- "*file1" >current &&
- compare_diff_raw current expected'
-
-cat >expected <<EOF
-:100644 100644 $before0 $after0 M file0
-EOF
-test_expect_success \
- 'limit to file0 should show file0' \
- 'git diff-index --cached $tree -- file0 >current &&
- compare_diff_raw current expected'
-
-cat >expected <<\EOF
-EOF
-test_expect_success \
- 'limit to file0/ should emit nothing.' \
- 'git diff-index --cached $tree -- file0/ >current &&
- compare_diff_raw current expected'
+test_expect_success 'setup' '
+ echo frotz >file0 &&
+ mkdir path1 &&
+ echo rezrov >path1/file1 &&
+ before0=$(git hash-object file0) &&
+ before1=$(git hash-object path1/file1) &&
+ git update-index --add file0 path1/file1 &&
+ tree=$(git write-tree) &&
+ echo nitfol >file0 &&
+ echo yomin >path1/file1 &&
+ after0=$(git hash-object file0) &&
+ after1=$(git hash-object path1/file1) &&
+ git update-index file0 path1/file1 &&
+ : >expected
+'
+
+test_expect_success 'limit to path should show nothing' '
+ git diff-index --cached $tree -- path >current &&
+ compare_diff_raw current expected
+'
+
+test_expect_success 'limit to path1 should show path1/file1' '
+ cat >expected <<-EOF &&
+ :100644 100644 $before1 $after1 M path1/file1
+ EOF
+
+ git diff-index --cached $tree -- path1 >current &&
+ compare_diff_raw current expected
+'
+
+test_expect_success 'limit to path1/ should show path1/file1' '
+ cat >expected <<-EOF &&
+ :100644 100644 $before1 $after1 M path1/file1
+ EOF
+
+ git diff-index --cached $tree -- path1/ >current &&
+ compare_diff_raw current expected
+'
+test_expect_success '"*file1" should show path1/file1' '
+ cat >expected <<-EOF &&
+ :100644 100644 $before1 $after1 M path1/file1
+ EOF
+
+ git diff-index --cached $tree -- "*file1" >current &&
+ compare_diff_raw current expected
+'
+
+test_expect_success 'limit to file0 should show file0' '
+ cat >expected <<-EOF &&
+ :100644 100644 $before0 $after0 M file0
+ EOF
+
+ git diff-index --cached $tree -- file0 >current &&
+ compare_diff_raw current expected
+'
+
+test_expect_success 'limit to file0/ should emit nothing.' '
+ : >expected &&
+ git diff-index --cached $tree -- file0/ >current &&
+ compare_diff_raw current expected
+'
test_expect_success 'diff-tree pathspec' '
tree2=$(git write-tree) &&
--
2.53.0
next prev parent reply other threads:[~2026-09-22 20:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 20:21 [PATCH v6 0/3] t40*: modernize Mark C. Chu-Carroll
2026-09-22 20:21 ` [PATCH v6 1/3] t4001: modernize Mark C. Chu-Carroll
2026-09-22 20:21 ` [PATCH v6 2/3] t4009: modernize Mark C. Chu-Carroll
2026-09-22 20:21 ` Mark C. Chu-Carroll [this message]
2026-09-24 14:58 ` [PATCH v6 0/3] t40*: modernize Kaartic Sivaraam
2026-09-24 16:13 ` Junio C Hamano
2026-09-24 17:20 ` Mark C. Chu-Carroll
2026-09-25 13:40 ` Kaartic Sivaraam
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=20260922202152.842793-4-markchucarroll@fastmail.com \
--to=markchucarroll@fastmail.com \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.