git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Achu Luma <ach.lumap@gmail.com>
To: git@vger.kernel.org
Cc: christian.couder@gmail.com, gitster@pobox.com,
	Achu Luma <ach.lumap@gmail.com>
Subject: [Outreachy][PATCH v4] t2400: avoid losing exit status to pipes
Date: Sat, 20 Jan 2024 03:15:47 +0100	[thread overview]
Message-ID: <20240120021547.199-1-ach.lumap@gmail.com> (raw)
In-Reply-To: <20231204153740.2992-1-ach.lumap@gmail.com>

The exit code of the preceding command in a pipe is disregarded. So
if that preceding command is a Git command that fails, the test would
not fail. Instead, by saving the output of that Git command to a file,
and removing the pipe, we make sure the test will fail if that Git
command fails.

Signed-off-by: Achu Luma <ach.lumap@gmail.com>
---
 The difference between v3 and v4 is:
 - Changed subject to better reflect what the patch is doing.
 - Updated the commit message.

 t/t2400-worktree-add.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
index 3742971105..b597004adb 100755
--- a/t/t2400-worktree-add.sh
+++ b/t/t2400-worktree-add.sh
@@ -490,7 +490,8 @@ test_expect_success 'put a worktree under rebase' '
 		cd under-rebase &&
 		set_fake_editor &&
 		FAKE_LINES="edit 1" git rebase -i HEAD^ &&
-		git worktree list | grep "under-rebase.*detached HEAD"
+		git worktree list >actual &&
+		grep "under-rebase.*detached HEAD" actual
 	)
 '

@@ -531,7 +532,8 @@ test_expect_success 'checkout a branch under bisect' '
 		git bisect start &&
 		git bisect bad &&
 		git bisect good HEAD~2 &&
-		git worktree list | grep "under-bisect.*detached HEAD" &&
+		git worktree list >actual &&
+		grep "under-bisect.*detached HEAD" actual &&
 		test_must_fail git worktree add new-bisect under-bisect &&
 		! test -d new-bisect
 	)
--
2.43.0.windows.1


      parent reply	other threads:[~2024-01-20  2:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-03 17:48 [PATCH 0/1] *** Avoid using Pipes *** ach.lumap
2023-10-03 17:48 ` [PATCH 1/1] t2400: avoid using pipes ach.lumap
2023-10-03 18:01   ` Eric Sunshine
2023-10-03 18:42     ` Junio C Hamano
2023-11-30 16:54 ` [PATCH v2 0/1] *** Avoid using Pipes *** Achu Luma
2023-11-30 16:54   ` [PATCH v2 1/1] t2400: avoid using pipes Achu Luma
2023-11-30 18:16     ` Christian Couder
2023-12-04 15:37       ` [Outreachy][PATCH v3] " Achu Luma
2023-12-08 21:00         ` Junio C Hamano
2024-01-20  2:15         ` Achu Luma [this message]

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=20240120021547.199-1-ach.lumap@gmail.com \
    --to=ach.lumap@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).