git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
EFEdwin Fernando <edwinfernando734@gmail.com>
Date
Apr 2, 2023, 19:17 UTC
Message-ID
<20230402191709.19296-1-edwinfernando734@gmail.com>
In-Reply-To
<20230402113607.2394-1-edwinfernando734@gmail.com>

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(-)
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
 '
 
 
-- 
2.40.0
Previous: Eric SunshineNext: Eric Sunshine
Message 9 of 13 in “Avoid suppression of git's exit code in tests”
  1. Edwin FernandoMar 26, 2023
  2. [GSOC][PATCH 1/1] t3701: Avoid suppression of exit status of gitEdwin Fernando, Mar 26, 2023
  3. Andrei RybakMar 26, 2023
  4. Eric SunshineMar 27, 2023
  5. [GSOC][PATCH v2] t3701: don't lose "git" exit codes in test scriptsEdwin Fernando, Apr 1, 2023
  6. Andrei RybakApr 2, 2023
  7. [GSOC][PATCH v3] t3701: don't lose "git" exit codes in test scriptsEdwin Fernando, Apr 2, 2023
  8. Eric SunshineApr 2, 2023
  9. [GSOC][PATCH v4] t3701: don't lose "git" exit codes in test scriptsEdwin Fernando, Apr 2, 2023
  10. Eric SunshineApr 3, 2023
  11. Edwin FernandoApr 3, 2023
  12. Edwin FernandoApr 3, 2023
  13. Eric SunshineApr 3, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.