Re: [PATCH 1/1] Add the `p4-pre-submit` hook
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 1, 2018, 15:10 UTC
- Message-ID
- <xmqqmuu686mp.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <CAAE-R+8UA5S3Y4iWw=njtVVn8cu+7s8E7L9fS6UY=Q_a5-JwwQ@mail.gmail.com>
chen bin <chenbin.sh@gmail.com> writes:
Show 5 quoted lines
> I updated the patch. But for some reason the test keep failing at this line, > `test_must_fail git p4 submit --dry-run >errs 2>&1 &&`. > > If I change this line to `test_must_fail git-p4 submit --dry-run >errs > 2>&1 &&` the test will pass.
Hmph. I somehow suspect that the test also will pass if you changed it like this:
test_must_fail false >errs 2>&1 &&
IOW, my suspicion is that the shell fails to find "git-p4" [*1*] and that is why your `test_must_fail git-p4 whatever` lets your test pass, which is different from the way you _want_ your test_must_fail succeed, i.e. "git p4 submit" is run with the "--dry-run" option and exit with non-zero status.
Of course, if the shell cannot find "git-p4", `errs` would not have the string "Would apply" in it, so the next test also would pass.
>>>> On 31 July 2018 at 10:46, SZEDER Gábor <szeder.dev@gmail.com> wrote: >>>>>> + test_must_fail git-p4 submit --dry-run >errs 2>&1 &&> >>>>>> + ! grep "Would apply" err
[Footnote]
*1* As I do not use (nor install) p4, I cannot test "'git p4' works
but 'git-p4' should not work" myself, but by running t0001 with
a trial patch like the following, you can see that we do not
find the dashed form `git-init` on $PATH and the test indeed
fails.t/t0001-init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 0681300707..8c598a0d84 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -31,7 +31,7 @@ check_config () { } test_expect_success 'plain' ' - git init plain && + git-init plain && check_config plain/.git false unset '