Skip to contentSkip to conversation

Add coverage for 'git format-patch --range-diff' single-patch case

PATCH Superseded Derrick Stolee via GitGitGadget 5 participants 11 messages Sep 11, 2018 – Sep 12, 2018

lore
Share & tools
lore
#0 lore raw

cover Add coverage for 'git format-patch --range-diff' single-patch case

In es/format-patch-rangediff, we added a '--range-diff' option to git-format-patch to automatically add a range-diff. We also added an option to write the diff as commentary to a single patch submission. However, this check was not tested.

I discovered this test gap by running 'make coverage-test coverage-report' on 'next' and then comparing the uncovered lines with those in the diff between 'master' and 'next'. I have a script that automates this process, and I'm still working on polishing it. You can see an earlier version at [1].

Based on es/format-patch-rangediff

[1]
https://github.com/derrickstolee/git/blob/coverage/contrib/coverage-diff.shA
bash script to report uncovered lines that were added in a diff.

Derrick Stolee (1):
t3206-range-diff.sh: cover single-patch case

 t/t3206-range-diff.sh | 5 +++++
 1 file changed, 5 insertions(+)

base-commit: 40ce41604daf200cdc85abded0133d40faafc2f8
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-37%2Fderrickstolee%2Frange-diff-test-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-37/derrickstolee/range-diff-test-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/37

Signature · 1 line
gitgitgadget
#1 lore raw

PATCH 1/1 t3206-range-diff.sh: cover single-patch case

From: Derrick Stolee <[email protected]>

The commit 40ce4160 "format-patch: allow --range-diff to apply to a lone-patch" added the ability to see a range-diff as commentary after the commit message of a single patch series (i.e. [PATCH] instead of [PATCH X/N]). However, this functionality was not covered by a test case.

Add a simple test case that checks that a range-diff is written as commentary to the patch.

---
 t/t3206-range-diff.sh | 5 +++++
 1 file changed, 5 insertions(+)
t/t3206-range-diff.sh +5 -0
index 3d7a2d8a4d..05ef3263d2 100755
@@ -154,4 +154,9 @@ do
 	'
 done
 
+test_expect_success 'format-patch --range-diff as commentary' '
+	git format-patch --stdout --range-diff=HEAD~1 HEAD~1 >actual &&
+	grep -A 1 -e "\-\-\-" actual | grep "Range-diff:"
+'
+
 test_done
Signature · 1 line
gitgitgadget
#7 lore raw
In reply to Derrick Stolee via GitGitGadget
Quoted 11 lines · Derrick Stolee via GitGitGadget

In es/format-patch-rangediff, we added a '--range-diff' option to git-format-patch to automatically add a range-diff. We also added an option to write the diff as commentary to a single patch submission. However, this check was not tested.

I discovered this test gap by running 'make coverage-test coverage-report' on 'next' and then comparing the uncovered lines with those in the diff between 'master' and 'next'. I have a script that automates this process, and I'm still working on polishing it. You can see an earlier version at [1].

Quoted 5 lines

Based on es/format-patch-rangediff

Sorry that these Cc's didn't work (again). Adding them manually and investigating the GGG code.

-Stolee

#2 lore raw

Re: [PATCH 1/1] t3206-range-diff.sh: cover single-patch case

In reply to Derrick Stolee via GitGitGadget
Quoted 21 lines · Derrick Stolee via GitGitGadget

From: Derrick Stolee <[email protected]>

The commit 40ce4160 "format-patch: allow --range-diff to apply to a lone-patch" added the ability to see a range-diff as commentary after the commit message of a single patch series (i.e. [PATCH] instead of [PATCH X/N]). However, this functionality was not covered by a test case.

Add a simple test case that checks that a range-diff is written as commentary to the patch.

---
 t/t3206-range-diff.sh | 5 +++++
 1 file changed, 5 insertions(+)
t/t3206-range-diff.sh +0 -0
index 3d7a2d8a4d..05ef3263d2 100755

t/t3206-range-diff.sh do · line 159

Quoted 6 lines
t/t3206-range-diff.sh +3 -0
@@ -154,4 +154,9 @@ do
 	'
 done
 
+test_expect_success 'format-patch --range-diff as commentary' '
+	git format-patch --stdout --range-diff=HEAD~1 HEAD~1 >actual &&
+	grep -A 1 -e "\-\-\-" actual | grep "Range-diff:"

Isn't "grep -A" GNUism?

#4 lore raw

Re: [PATCH 1/1] t3206-range-diff.sh: cover single-patch case

In reply to Derrick Stolee via GitGitGadget
Quoted 22 lines · Derrick Stolee via GitGitGadget

From: Derrick Stolee <[email protected]>

The commit 40ce4160 "format-patch: allow --range-diff to apply to a lone-patch" added the ability to see a range-diff as commentary after the commit message of a single patch series (i.e. [PATCH] instead of [PATCH X/N]). However, this functionality was not covered by a test case.

Add a simple test case that checks that a range-diff is written as commentary to the patch.

---
 t/t3206-range-diff.sh | 5 +++++
 1 file changed, 5 insertions(+)
t/t3206-range-diff.sh +0 -0
index 3d7a2d8a4d..05ef3263d2 100755

t/t3206-range-diff.sh do · line 158

Quoted 5 lines
t/t3206-range-diff.sh +2 -0
@@ -154,4 +154,9 @@ do
        '
 done
 
+test_expect_success 'format-patch --range-diff as commentary' '
+       git format-patch --stdout --range-diff=HEAD~1 HEAD~1 >actual &&

This is an interesting use of range-diff, as it basically tells us "Range-diff: This is a new patch", but it works to make sure there is a range diff section. (I shortly wondered if we would ever omit the range diff for "obvious" cases or word it differently)

t/t3206-range-diff.sh do · line 159

Quoted 1 line
t/t3206-range-diff.sh +1 -0
+       grep -A 1 -e "\-\-\-" actual | grep "Range-diff:"

So the first grep finds the three dashes, presumably those after the commit message/ but others as well, e.g. in

    --- a/<path>
    +++ b/<path>

and then the second grep should find the string "Range-diff". By having the greps chained with a pipe, only one return code can be delivered to the test suite, and as we get the last commands return code, we get reported if we found the string in the preselected part.

I was wondering if we could get away with just one command to check for that multi line pattern

    sed -n -e '/---/,/^Range/p' actual

seems to detect that pattern, and prints from there on to the rest of the file.

Quoted 5 lines
t/t3206-range-diff.sh +2 -1
+'
+
 test_done
--

gitgitgadget

#3 lore raw

Re: [PATCH 1/1] t3206-range-diff.sh: cover single-patch case

In reply to Junio C Hamano
Quoted 5 lines · Junio C Hamano

t/t3206-range-diff.sh do · line 159

Quoted 3 lines
t/t3206-range-diff.sh +3 -0
+test_expect_success 'format-patch --range-diff as commentary' '
+	git format-patch --stdout --range-diff=HEAD~1 HEAD~1 >actual &&
+	grep -A 1 -e "\-\-\-" actual | grep "Range-diff:"

Isn't "grep -A" GNUism?

Sorry for short-write(2) X-<.

Perhaps

	sed -ne "/^---$/,+1/s/^Range-diff:/&/p"

or something along that line.

#8 lore raw
In reply to Derrick Stolee via GitGitGadget
Quoted 4 lines · Derrick Stolee via GitGitGadget

In es/format-patch-rangediff, we added a '--range-diff' option to git-format-patch to automatically add a range-diff. We also added an option to write the diff as commentary to a single patch submission. However, this check was not tested.

It was an intentional (though unjustified) oversight. Thanks for working on this.

Quoted 4 lines

I discovered this test gap by running 'make coverage-test coverage-report' on 'next' and then comparing the uncovered lines with those in the diff between 'master' and 'next'. I have a script that automates this process, and I'm still working on polishing it.

Interesting. Does your script detect that the --creation-factor option added by patch 13/14 [1] also lacks a test? (I'm not necessarily suggesting adding a test at the moment. Even Dscho's git-range-diff series doesn't have a test for "creation factor", so it wouldn't necessarily make sense to add a test only for the git-format-patch case. Instead, we'd want, at some point, to add tests covering both git-range-diff and git-format-patch.)

[1]: https://public-inbox.org/git/[email protected]/

#5 lore raw

Re: [PATCH 1/1] t3206-range-diff.sh: cover single-patch case

In reply to Derrick Stolee via GitGitGadget
Quoted 13 lines · Derrick Stolee via GitGitGadget

The commit 40ce4160 "format-patch: allow --range-diff to apply to a lone-patch" added the ability to see a range-diff as commentary after the commit message of a single patch series (i.e. [PATCH] instead of [PATCH X/N]). However, this functionality was not covered by a test case.

Add a simple test case that checks that a range-diff is written as commentary to the patch.

---

t/t3206-range-diff.sh do · line 157

Quoted 4 lines
t/t3206-range-diff.sh +4 -0
@@ -154,4 +154,9 @@ do
+test_expect_success 'format-patch --range-diff as commentary' '
+       git format-patch --stdout --range-diff=HEAD~1 HEAD~1 >actual &&
+       grep -A 1 -e "\-\-\-" actual | grep "Range-diff:"
+'

Aside from Junio's and Stefan's comments...

Patch 6/14 [1], in addition to checking that a solo patch contains an interdiff, takes the extra step of checking that individual patches _don't_ contain an interdiff when --cover-letter is used. I wonder if the same should be done here, though I don't feel too strongly about it. If you do go that route, it might make sense to move this test to t4014 as neighbor to the --interdiff tests. The reason 10/14 [2] added the "git format-patch --range-diff" test to t3206 instead of t4014 was so it could do a thorough check of the embedded range-diff by re-using the specially crafted test repo set up by t3206. Your new test is much looser, thus could be moved alongside the --interdiff tests. Not a big deal, though. Either way is fine. Thanks for working on this.

[1]: https://public-inbox.org/git/[email protected]/
[2]: https://public-inbox.org/git/[email protected]/

#6 lore raw

Re: [PATCH 1/1] t3206-range-diff.sh: cover single-patch case

Quoted 33 lines · Eric Sunshine
Quoted 13 lines · Derrick Stolee via GitGitGadget

The commit 40ce4160 "format-patch: allow --range-diff to apply to a lone-patch" added the ability to see a range-diff as commentary after the commit message of a single patch series (i.e. [PATCH] instead of [PATCH X/N]). However, this functionality was not covered by a test case.

Add a simple test case that checks that a range-diff is written as commentary to the patch.

---

t/t3206-range-diff.sh do · line 157

Quoted 4 lines
t/t3206-range-diff.sh +4 -0
@@ -154,4 +154,9 @@ do
+test_expect_success 'format-patch --range-diff as commentary' '
+       git format-patch --stdout --range-diff=HEAD~1 HEAD~1 >actual &&
+       grep -A 1 -e "\-\-\-" actual | grep "Range-diff:"
+'

Aside from Junio's and Stefan's comments...

Patch 6/14 [1], in addition to checking that a solo patch contains an interdiff, takes the extra step of checking that individual patches _don't_ contain an interdiff when --cover-letter is used. I wonder if the same should be done here, though I don't feel too strongly about it. If you do go that route, it might make sense to move this test to t4014 as neighbor to the --interdiff tests. The reason 10/14 [2] added the "git format-patch --range-diff" test to t3206 instead of t4014 was so it could do a thorough check of the embedded range-diff by re-using the specially crafted test repo set up by t3206. Your new test is much looser, thus could be moved alongside the --interdiff tests. Not a big deal, though. Either way is fine. Thanks for working on this.

Quoted 2 lines

[1]: https://public-inbox.org/git/[email protected]/
[2]: https://public-inbox.org/git/[email protected]/

Thanks for these links! In particular, [2] uses this line to test the inter-diff appears:

+    test_i18ngrep "^Interdiff:$" 0001-fleep.patch &&

That's a better way to test, especially with the translation. It would be enough for my needs.

Thanks,

-Stolee

P.S. Resending because apparently I had HTML in the last response

#9 lore raw

v2 cover Add coverage for 'git format-patch --range-diff' single-patch case

In reply to Derrick Stolee via GitGitGadget

In es/format-patch-rangediff, we added a '--range-diff' option to git-format-patch to automatically add a range-diff. We also added an option to write the diff as commentary to a single patch submission. However, this check was not tested.

I discovered this test gap by running 'make coverage-test coverage-report' on 'next' and then comparing the uncovered lines with those in the diff between 'master' and 'next'. I have a script that automates this process, and I'm still working on polishing it. You can see an earlier version at [1].

Based on es/format-patch-rangediff

[1]
https://github.com/derrickstolee/git/blob/coverage/contrib/coverage-diff.shA
bash script to report uncovered lines that were added in a diff.

Derrick Stolee (1):
t3206-range-diff.sh: cover single-patch case

 t/t3206-range-diff.sh | 5 +++++
 1 file changed, 5 insertions(+)

base-commit: 40ce41604daf200cdc85abded0133d40faafc2f8
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-37%2Fderrickstolee%2Frange-diff-test-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-37/derrickstolee/range-diff-test-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/37

Range-diff vs v1:

1: 58347a9624 ! 1: 277a4d2bd8 t3206-range-diff.sh: cover single-patch case

     @@ -22,7 +22,7 @@
       
      +test_expect_success 'format-patch --range-diff as commentary' '
      +	git format-patch --stdout --range-diff=HEAD~1 HEAD~1 >actual &&
     -+	grep -A 1 -e "\-\-\-" actual | grep "Range-diff:"
     ++	test_i18ngrep "^Range-diff:$" actual
      +'
      +
       test_done
Signature · 1 line
gitgitgadget
#10 lore raw

PATCH v2 1/1 t3206-range-diff.sh: cover single-patch case

From: Derrick Stolee <[email protected]>

The commit 40ce4160 "format-patch: allow --range-diff to apply to a lone-patch" added the ability to see a range-diff as commentary after the commit message of a single patch series (i.e. [PATCH] instead of [PATCH X/N]). However, this functionality was not covered by a test case.

Add a simple test case that checks that a range-diff is written as commentary to the patch.

---
 t/t3206-range-diff.sh | 5 +++++
 1 file changed, 5 insertions(+)
t/t3206-range-diff.sh +5 -0
index 3d7a2d8a4d..6babc0e276 100755
@@ -154,4 +154,9 @@ do
 	'
 done
 
+test_expect_success 'format-patch --range-diff as commentary' '
+	git format-patch --stdout --range-diff=HEAD~1 HEAD~1 >actual &&
+	test_i18ngrep "^Range-diff:$" actual
+'
+
 test_done
Signature · 1 line
gitgitgadget