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

Re: [PATCH v3 0/2] [Outreachy][Patch v2] t3404: avoid losing exit status to pipes

From
Patrick Steinhardt <ps@pks.im>
Date
Oct 7, 2024, 08:08 UTC
Message-ID
<ZwOW96K1_12Kzefo@pks.im>
In-Reply-To
<CAPSxiM9Z3q5Oz0PkadC72J0cU2F9D8Rh5eAtNz7aZoUZxp6PUA@mail.gmail.com>
On Mon, Oct 07, 2024 at 07:25:44AM +0000, Usman Akinyemi wrote:
Show 65 quoted lines
> On Mon, Oct 7, 2024 at 4:24 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
> >
> > On Sun, Oct 6, 2024 at 12:18 PM Usman Akinyemi
> > <usmanakinyemi202@gmail.com> wrote:
> > > Kindly, help take a look if this is okay now.
> > >
> > > Also, I wanted to change this also to use test_line_count,
> > >  test 0 = $(grep -c "^[^#]" < .git/rebase-merge/git-rebase-todo)
> > >
> > >  But, I tried a different approach and the test kept failing.
> > >
> > > Similar as
> > >
> > > git show >output &&
> > > count=$(grep NEVER output | wc -l) &&
> > > test 0 = $count &&
> >
> > What is the actual error you encountered?
> >
> > By the way, we have a handy function, test_must_be_empty(), which can
> > be used if you expect the output to not contain anything. As an
> > example:
> >
> >     git show >output &&
> >     grep NEVER output >actual &&
> >     test_must_be_empty actual
> 
> Thanks for your review, I really appreciate it. I tried this approach,
> but I was getting this particular error for the testing.
> 
> not ok 32 - multi-fixup does not fire up editor
> #
> # git checkout -b multi-fixup E &&
> # base=$(git rev-parse HEAD~4) &&
> # (
> # set_fake_editor &&
> # FAKE_COMMIT_AMEND="NEVER" \
> # FAKE_LINES="1 fixup 2 fixup 3 fixup 4" \
> # git rebase -i $base
> # ) &&
> # test $base = $(git rev-parse HEAD^) &&
> # git show >output &&
> # grep NEVER output >actual &&
> # test_must_be_empty actual &&
> # git checkout @{-1} &&
> # git branch -D multi-fixup
> #
> Below is the particular test case
> 
> test_expect_success 'multi-fixup does not fire up editor' '
> git checkout -b multi-fixup E &&
> base=$(git rev-parse HEAD~4) &&
> (
> set_fake_editor &&
> FAKE_COMMIT_AMEND="NEVER" \
> FAKE_LINES="1 fixup 2 fixup 3 fixup 4" \
> git rebase -i $base
> ) &&
> test $base = $(git rev-parse HEAD^) &&
> git show >output &&
> grep NEVER output >actual &&
> test_must_be_empty actual &&
> git checkout @{-1} &&
> git branch -D multi-fixup
> '

That makes sense. The expectation here is that `output` shouldn't contain the string "NEVER" at all. And as grep(1) would fail when it doesn't find a match the whole test would fail like this. So the below would likely be the best solution.

Patrick
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index f171af3061..978fdfc2f1 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -410,7 +410,8 @@ test_expect_success 'multi-fixup does not fire up editor' '
 			git rebase -i $base
 	) &&
 	test $base = $(git rev-parse HEAD^) &&
-	test 0 = $(git show | grep NEVER | wc -l) &&
+	git show >output &&
+	! grep NEVER output &&
 	git checkout @{-1} &&
 	git branch -D multi-fixup
 '
Previous: Usman AkinyemiNext: Eric Sunshine
Message 37 of 63 in “t3404: avoid losing exit status to pipes”
  1. 0/2 [Outreachy][Patch v2] t3404: avoid losing exit status to pipesUsman Akinyemi via GitGitGadget, Oct 6, 2024
  2. 1/2 [Outreachy][Patch v1] t3404: avoid losing exit status to pipesUsman Akinyemi via GitGitGadget, Oct 6, 2024
  3. Eric SunshineOct 6, 2024
  4. Usman AkinyemiOct 6, 2024
  5. 2/2 [Outreachy][Patch v2] t3404: avoid losing exit status to pipesUsman Akinyemi via GitGitGadget, Oct 6, 2024
  6. Eric SunshineOct 6, 2024
  7. Usman AkinyemiOct 6, 2024
  8. Eric SunshineOct 6, 2024
  9. Usman AkinyemiOct 6, 2024
  10. [Outreachy][Patch v1] t3404: avoid losing exit status to pipesUsman Akinyemi via GitGitGadget, Oct 6, 2024
  11. Eric SunshineOct 6, 2024
  12. Usman AkinyemiOct 6, 2024
  13. Eric SunshineOct 6, 2024
  14. shejialuoOct 6, 2024
  15. Eric SunshineOct 6, 2024
  16. Usman AkinyemiOct 6, 2024
  17. shejialuoOct 6, 2024
  18. Usman AkinyemiOct 6, 2024
  19. shejialuoOct 6, 2024
  20. shejialuoOct 6, 2024
  21. Usman AkinyemiOct 6, 2024
  22. Eric SunshineOct 7, 2024
  23. 0/2 [Outreachy][Patch v2] t3404: avoid losing exit status to pipesUsman Akinyemi via GitGitGadget, Oct 6, 2024
  24. 1/2 t3404: avoid losing exit status with focus on `git show` and `git cat-files`Usman Akinyemi via GitGitGadget, Oct 6, 2024
  25. Patrick SteinhardtOct 7, 2024
  26. phillip.wood123@gmail.comOct 7, 2024
  27. Usman AkinyemiOct 7, 2024
  28. 2/2 [Outreachy][Patch v1] t3404: employing test_line_count() to replace testUsman Akinyemi via GitGitGadget, Oct 6, 2024
  29. Kristoffer HaugsbakkOct 6, 2024
  30. Eric SunshineOct 7, 2024
  31. Patrick SteinhardtOct 7, 2024
  32. Usman AkinyemiOct 7, 2024
  33. phillip.wood123@gmail.comOct 7, 2024
  34. Usman AkinyemiOct 6, 2024
  35. Eric SunshineOct 7, 2024
  36. Usman AkinyemiOct 7, 2024
  37. Patrick SteinhardtOct 7, 2024
  38. Eric SunshineOct 7, 2024
  39. Usman AkinyemiOct 7, 2024
  40. Kristoffer HaugsbakkOct 6, 2024
  41. Usman AkinyemiOct 6, 2024
  42. Patrick SteinhardtOct 7, 2024
  43. 0/2 [Outreachy][Patch v2] t3404: avoid losing exit status to pipesUsman Akinyemi via GitGitGadget, Oct 7, 2024
  44. 1/2 t3404: avoid losing exit status with focus on `git show` and `git cat-file`Usman Akinyemi via GitGitGadget, Oct 7, 2024
  45. 2/2 [Outreachy][Patch v1] t3404: employing test_line_count() to replace testUsman Akinyemi via GitGitGadget, Oct 7, 2024
  46. Patrick SteinhardtOct 7, 2024
  47. 0/2 [Outreachy][Patch v2] t3404: avoid losing exit status to pipesUsman Akinyemi via GitGitGadget, Oct 7, 2024
  48. 1/2 t3404: avoid losing exit status with focus on `git show` and `git cat-file`Usman Akinyemi via GitGitGadget, Oct 7, 2024
  49. 2/2 t3404: employing test_line_count() to replace testUsman Akinyemi via GitGitGadget, Oct 7, 2024
  50. Patrick SteinhardtOct 7, 2024
  51. Usman AkinyemiOct 7, 2024
  52. 0/2 [Outreachy][Patch v2] t3404: avoid losing exit status to pipesUsman Akinyemi via GitGitGadget, Oct 7, 2024
  53. 1/2 t3404: avoid losing exit status with focus on `git show` and `git cat-file`Usman Akinyemi via GitGitGadget, Oct 7, 2024
  54. 2/2 t3404: employing test_line_count() to replace testUsman Akinyemi via GitGitGadget, Oct 7, 2024
  55. Phillip WoodOct 7, 2024
  56. Usman AkinyemiOct 7, 2024
  57. Patrick SteinhardtOct 7, 2024
  58. Usman AkinyemiOct 7, 2024
  59. Patrick SteinhardtOct 7, 2024
  60. Usman AkinyemiOct 7, 2024
  61. 0/2 [Outreachy][Patch v2] t3404: avoid losing exit status to pipesUsman Akinyemi via GitGitGadget, Oct 7, 2024
  62. 1/2 t3404: avoid losing exit status with focus on `git show` and `git cat-file`Usman Akinyemi via GitGitGadget, Oct 7, 2024
  63. 2/2 t3404: replace test with test_line_count()Usman Akinyemi via GitGitGadget, Oct 7, 2024

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.