diff mbox series

[GSOC,v4] t3701: don't lose "git" exit codes in test scripts

Message ID 20230402191709.19296-1-edwinfernando734@gmail.com (mailing list archive)
State New, archived
Headers show
Series [GSOC,v4] t3701: don't lose "git" exit codes in test scripts | expand

Commit Message

Edwin Fernando April 2, 2023, 7:17 p.m. UTC
Exit codes are lost due to piping: "git ... | <command>"
Fix these issues using the intermediate step of writing output to file.

Signed-off-by: Edwin Fernando <edwinfernando734@gmail.com>
---
Apply my changes on top of the latest commit in upstream history.
Test 76 in t3701 fails. This commit breaks the test:
a9f4a01760 (Merge branch 'jk/add-p-unmerged-fix', 2023-03-19)
Identified by checking out commits in:
"git log --oneline -- t/t3701-add-interactive.sh"
I don't know if it is normal to have broken tests in the main repository.

 t/t3701-add-interactive.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Eric Sunshine April 3, 2023, 6:24 a.m. UTC | #1
On Sun, Apr 2, 2023 at 3:18 PM Edwin Fernando
<edwinfernando734@gmail.com> wrote:
> Exit codes are lost due to piping: "git ... | <command>"
> Fix these issues using the intermediate step of writing output to file.
>
> Signed-off-by: Edwin Fernando <edwinfernando734@gmail.com>
> ---
> Apply my changes on top of the latest commit in upstream history.
> Test 76 in t3701 fails. This commit breaks the test:
> a9f4a01760 (Merge branch 'jk/add-p-unmerged-fix', 2023-03-19)
> Identified by checking out commits in:
> "git log --oneline -- t/t3701-add-interactive.sh"
> I don't know if it is normal to have broken tests in the main repository.

It's not normal to have broken tests in the repository; they should not exist.

However, it's not clear what breakage you are seeing. In my testing, I
don't see any failures, either in a9f4a01760 or after applying your
patch to "master". Can you provide more information about the failure
you're experiencing?
Edwin Fernando April 3, 2023, 9:34 a.m. UTC | #2
On Mon, 3 Apr 2023 at 07:25, Eric Sunshine <sunshine@sunshineco.com> wrote:
> It's not normal to have broken tests in the repository; they should not exist.

Sorry the test did not break after all.

> However, it's not clear what breakage you are seeing. In my testing, I
> don't see any failures, either in a9f4a01760 or after applying your
> patch to "master". Can you provide more information about the failure
> you're experiencing?

I cloned git again, ran "make" and all the tests in t3701 passed. The
local repository I have been working on so far still gives the same error
though. The error message is not very helpful so I haven't included it. I
ran "make" on the faulty repository and the tests passed this time. So I
think the problem was that whatever "make" does was not up to date.
Also please ignore some mails you may have received because of
misconfiguration.
Eric Sunshine April 3, 2023, 5:03 p.m. UTC | #3
On Mon, Apr 3, 2023 at 5:35 AM Edwin Fernando
<edwinfernando734@gmail.com> wrote:
> On Mon, 3 Apr 2023 at 07:25, Eric Sunshine <sunshine@sunshineco.com> wrote:
> > However, it's not clear what breakage you are seeing. In my testing, I
> > don't see any failures, either in a9f4a01760 or after applying your
> > patch to "master". Can you provide more information about the failure
> > you're experiencing?
>
> I cloned git again, ran "make" and all the tests in t3701 passed. The
> local repository I have been working on so far still gives the same error
> though. The error message is not very helpful so I haven't included it. I
> ran "make" on the faulty repository and the tests passed this time. So I
> think the problem was that whatever "make" does was not up to date.
> Also please ignore some mails you may have received because of
> misconfiguration.

That makes sense. An outdated build could indeed account for an
unexpected test failure.
diff mbox series

Patch

diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 3982b6b49d..b8291206a0 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -286,8 +286,10 @@  test_expect_success FILEMODE 'patch does not affect mode' '
 	echo content >>file &&
 	chmod +x file &&
 	printf "n\\ny\\n" | git add -p &&
-	git show :file | grep content &&
-	git diff file | grep "new mode"
+	git show :file >show &&
+	grep content show &&
+	git diff file >diff &&
+	grep "new mode" diff
 '
 
 test_expect_success FILEMODE 'stage mode but not hunk' '
@@ -295,8 +297,10 @@  test_expect_success FILEMODE 'stage mode but not hunk' '
 	echo content >>file &&
 	chmod +x file &&
 	printf "y\\nn\\n" | git add -p &&
-	git diff --cached file | grep "new mode" &&
-	git diff          file | grep "+content"
+	git diff --cached file >diff &&
+	grep "new mode" diff &&
+	git diff file >diff &&
+	grep "+content" diff
 '