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

[GSoC][PATCH v1] t9811: avoid pipe in git commands in test script

From
KAKhalid Ali <khalludi123@gmail.com>
Date
Apr 2, 2019, 01:41 UTC
Message-ID
<20190402014115.22478-1-khalludi123@gmail.com>

The exit code of the upstream in a pipe is ignored thus we should avoid using it. By writing out the output of the git command to a file, we can test the exit codes of both the commands.

Aside from the commit message, I plan to apply for GSoC. Planning to solve the rebase/cherry-pick issue or adding functionality for the rebase interactive command.

Any review on this commit would be appreciated!
Signed-off-by: Khalid Ali <khalludi123@gmail.com>
---
 t/t9811-git-p4-label-import.sh | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/t/t9811-git-p4-label-import.sh b/t/t9811-git-p4-label-import.sh
index 602b0a5d5c..2f4e80ed55 100755
--- a/t/t9811-git-p4-label-import.sh
+++ b/t/t9811-git-p4-label-import.sh
@@ -63,7 +63,8 @@ test_expect_success 'basic p4 labels' '
 		git checkout TAG_WITH\$_SHELL_CHAR &&
 		test -f f1 && test -f f2 && test -f file_with_\$metachar &&
 
-		git show TAG_LONG_LABEL | grep -q "A Label second line"
+		git show TAG_LONG_LABEL >actual &&
+		grep -q "A Label second line" actual
 	)
 '
 # Test some label corner cases:
@@ -92,9 +93,9 @@ test_expect_success 'two labels on the same changelist' '
 		cd "$git" &&
 		git p4 sync --import-labels &&
 
-		git tag | grep TAG_F1 &&
-		git tag | grep -q TAG_F1_1 &&
-		git tag | grep -q TAG_F1_2 &&
+		git tag >actual && grep TAG_F1 actual &&
+		git tag >actual && grep -q TAG_F1_1 actual &&
+		git tag >actual && grep -q TAG_F1_2 actual &&
 
 		cd main &&
 
@@ -205,7 +206,7 @@ test_expect_success 'use git config to enable import/export of tags' '
 		git p4 rebase --verbose &&
 		git p4 submit --verbose &&
 		git tag &&
-		git tag | grep TAG_F1_1
+		git tag >actual && grep TAG_F1_1 actual
 	) &&
 	(
 		cd "$cli" &&
-- 
2.21.0.196.g041f5ea1cf
Next: Junio C Hamano
Message 1 of 3 in “t9811: avoid pipe in git commands in test script”
  1. Khalid AliApr 2, 2019
  2. Junio C HamanoApr 2, 2019
  3. Khalid AliApr 2, 2019

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.