* [GSoC][PATCH v1] t9811: avoid pipe in git commands in test script
@ 2019-04-02 1:41 Khalid Ali
2019-04-02 2:39 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Khalid Ali @ 2019-04-02 1:41 UTC (permalink / raw)
To: git; +Cc: Khalid Ali
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [GSoC][PATCH v1] t9811: avoid pipe in git commands in test script
2019-04-02 1:41 [GSoC][PATCH v1] t9811: avoid pipe in git commands in test script Khalid Ali
@ 2019-04-02 2:39 ` Junio C Hamano
2019-04-02 20:52 ` Khalid Ali
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2019-04-02 2:39 UTC (permalink / raw)
To: Khalid Ali; +Cc: git
Khalid Ali <khalludi123@gmail.com> writes:
> 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.
End the log message here by moving the next two paragraphs below the
three-dash line.
>
> 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
There is no mention of file 'actual' before this patch, so we can
reasonably be sure that we are not breaking expectations of existing
test that a file with that name has contents different from what the
above command produces. On the other hand, if later tests have
things like "git add ." or "git status -s" and expects that there is
no such file called 'actual', this change may have broken the
expectation.
I *think* the above is done after going inside $git directory, which
will be removed with "test_when_finished cleanup_git", so it is
fairly clear that leaving an extra file 'actual' behind at this
point is safe.
This is not a problem with this conversion, but we tend to avoid
squelching standard output to help debugging tests. An independent
clean-up patch may want to replace "grep -q" with just "grep".
> @@ -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 &&
Ditto.
>
> 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
> ) &&
I notice that this test piece does not call cleanup_git when it is
done. I think that is a mistake (not introduced by this patch) that
ma want to get fixed independently.
> (
> cd "$cli" &&
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [GSoC][PATCH v1] t9811: avoid pipe in git commands in test script
2019-04-02 2:39 ` Junio C Hamano
@ 2019-04-02 20:52 ` Khalid Ali
0 siblings, 0 replies; 3+ messages in thread
From: Khalid Ali @ 2019-04-02 20:52 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Thanks for the feedback Junio.
I was wondering if I should resubmit the patch without my comments.
Also, I was wondering if I should be adding a call to check the exit codes
of this test and the file called 'actual' at the end of the script.
On Mon, Apr 1, 2019 at 10:39 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Khalid Ali <khalludi123@gmail.com> writes:
>
> > 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.
>
> End the log message here by moving the next two paragraphs below the
> three-dash line.
>
> >
> > 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
>
> There is no mention of file 'actual' before this patch, so we can
> reasonably be sure that we are not breaking expectations of existing
> test that a file with that name has contents different from what the
> above command produces. On the other hand, if later tests have
> things like "git add ." or "git status -s" and expects that there is
> no such file called 'actual', this change may have broken the
> expectation.
>
> I *think* the above is done after going inside $git directory, which
> will be removed with "test_when_finished cleanup_git", so it is
> fairly clear that leaving an extra file 'actual' behind at this
> point is safe.
>
> This is not a problem with this conversion, but we tend to avoid
> squelching standard output to help debugging tests. An independent
> clean-up patch may want to replace "grep -q" with just "grep".
>
> > @@ -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 &&
>
> Ditto.
>
> >
> > 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
> > ) &&
>
> I notice that this test piece does not call cleanup_git when it is
> done. I think that is a mistake (not introduced by this patch) that
> ma want to get fixed independently.
>
> > (
> > cd "$cli" &&
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-04-02 20:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-02 1:41 [GSoC][PATCH v1] t9811: avoid pipe in git commands in test script Khalid Ali
2019-04-02 2:39 ` Junio C Hamano
2019-04-02 20:52 ` Khalid Ali
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).