Message ID | 20230402113607.2394-1-edwinfernando734@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [GSOC,v3] t3701: don't lose "git" exit codes in test scripts | expand |
On Sun, Apr 2, 2023 at 7:36 AM Edwin Fernando <edwinfernando734@gmail.com> wrote: > Exit codes are lost due to piping and command substitution: > > - "git ... | <command>" > - "<command> $(git ... )" > > Fix these issues using the intermediate step of writing output to file. > > Signed-off-by: Edwin Fernando <edwinfernando734@gmail.com> > --- > Changes from v2: > - use git rebase to squash commit history, > and diff with upstream commit for review > - use present tense for code before the commit. Thanks. The patch is looking a lot better. One comment, though... > diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh > @@ -311,9 +315,11 @@ test_expect_success FILEMODE 'stage mode and hunk' ' > printf "y\\ny\\n" | git add -p && > - git diff --cached file | grep "new mode" && > - git diff --cached file | grep "+content" && > - test -z "$(git diff file)" > + git diff --cached file >diff && > + grep "new mode" diff && > + grep "+content" diff && > + git diff file >diff && > + test_must_be_empty diff > ' The other changes in your patch are worthwhile, but it seems that you have based this patch on an outdated copy of the repository. This particular change had already been made by 9fdc79ecba (tests: don't lose misc "git" exit codes, 2023-02-06) a couple months ago[1]. So, you'll want to update your repository to the latest available from Junio, re-roll using "master" as a base for the patch, and drop this change while keeping the others. [1]: https://github.com/git/git/commit/9fdc79ecba0f4a3ef885f1409d2db5a1dbabd649
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 3a99837d9b..77aad9032a 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -292,8 +292,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' ' @@ -301,8 +303,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 ' @@ -311,9 +315,11 @@ test_expect_success FILEMODE 'stage mode and hunk' ' echo content >>file && chmod +x file && printf "y\\ny\\n" | git add -p && - git diff --cached file | grep "new mode" && - git diff --cached file | grep "+content" && - test -z "$(git diff file)" + git diff --cached file >diff && + grep "new mode" diff && + grep "+content" diff && + git diff file >diff && + test_must_be_empty diff ' # end of tests disabled when filemode is not usable
Exit codes are lost due to piping and command substitution: - "git ... | <command>" - "<command> $(git ... )" Fix these issues using the intermediate step of writing output to file. Signed-off-by: Edwin Fernando <edwinfernando734@gmail.com> --- Changes from v2: - use git rebase to squash commit history, and diff with upstream commit for review - use present tense for code before the commit. t/t3701-add-interactive.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)