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

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
 '
 
Previous: chen binNext: Chen Bin
Message 25 of 27 in “add hook pre-p4-submit”
  1. 1/1 add hook pre-p4-submitChen Bin, Jul 23, 2018
  2. Luke DiamandJul 25, 2018
  3. Ævar Arnfjörð BjarmasonJul 25, 2018
  4. chen binJul 25, 2018
  5. 1/1 add hook pre-p4-submitChen Bin, Jul 25, 2018
  6. Eric SunshineJul 25, 2018
  7. Junio C HamanoJul 25, 2018
  8. chen binJul 26, 2018
  9. Eric SunshineJul 26, 2018
  10. Luke DiamandJul 26, 2018
  11. chen binJul 27, 2018
  12. 1/1 add hook pre-p4-submitChen Bin, Jul 26, 2018
  13. Junio C HamanoJul 26, 2018
  14. Eric SunshineJul 26, 2018
  15. 1/1 Add the `p4-pre-submit` hookChen Bin, Jul 27, 2018
  16. Eric SunshineJul 27, 2018
  17. Junio C HamanoJul 30, 2018
  18. Luke DiamandJul 30, 2018
  19. Junio C HamanoJul 30, 2018
  20. SZEDER GáborJul 31, 2018
  21. Luke DiamandJul 31, 2018
  22. Junio C HamanoJul 31, 2018
  23. Luke DiamandJul 31, 2018
  24. chen binAug 1, 2018
  25. Junio C HamanoAug 1, 2018
  26. 1/1 Add the `p4-pre-submit` hookChen Bin, Aug 1, 2018
  27. Junio C HamanoAug 1, 2018

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.