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

Re: [PATCH 1/3] t2018: cleanup in current test

From
Denton Liu <liu.denton@gmail.com>
Date
Apr 26, 2019, 00:40 UTC
Message-ID
<20190426004032.GA19743@dev-l>
In-Reply-To
<CAPig+cTdJv9-M+zmp+Jo2bjOrkO3NgsguJ2xM+aXhf38OjjEEw@mail.gmail.com>
On Thu, Apr 25, 2019 at 06:34:07PM -0400, Eric Sunshine wrote:
Show 29 quoted lines
> On Thu, Apr 25, 2019 at 5:10 PM Denton Liu <liu.denton@gmail.com> wrote:
> > Before, in t2018, if do_checkout failed to create `branch2`, the next
> > test-case would run `git branch -D branch2` but then fail because it was
> > expecting `branch2` to exist, even though it doesn't. As a result, an
> > early failure could cause a cascading failure of tests.
> >
> > Make test-case responsible for cleaning up their own branches so that
> > future tests can start with a sane environment.
> >
> > Signed-off-by: Denton Liu <liu.denton@gmail.com>
> > ---
> > diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh
> > @@ -60,38 +60,36 @@ test_expect_success 'setup' '
> >  test_expect_success 'checkout -b to a new branch, set to HEAD' '
> > +       test_when_finished test_might_fail git branch -D branch2 &&
> > +       test_when_finished git checkout branch1 &&
> 
> I'm aware that when-finished actions fire in reverse order but the
> inherent subtlety of ordering of these two invocations still caught me
> off-guard for a moment since they are reverse the order in which one
> logically thinks about the actions which need to be performed. I
> wonder if it would be easier to digest if written like this:
> 
>     test_when_finished '
>         git checkout branch1 &&
>         test_might_fail git branch -D branch2
>     ' &&
> 
> (Probably not worth a re-roll.)

This sounds like a good idea. If Junio doesn't get around to it, I'll send a v1.5 of this patch later. Thanks for the suggestion!

Previous: Eric SunshineNext: Junio C Hamano
Message 4 of 21 in “checkout: allow -b/-B to work on a merge base”
  1. 0/3 checkout: allow -b/-B to work on a merge baseDenton Liu, Apr 25, 2019
  2. 1/3 t2018: cleanup in current testDenton Liu, Apr 25, 2019
  3. Eric SunshineApr 25, 2019
  4. Denton LiuApr 26, 2019
  5. Junio C HamanoApr 26, 2019
  6. Eric SunshineApr 26, 2019
  7. 2/3 t2018: demonstrate checkout -b merge base bugDenton Liu, Apr 25, 2019
  8. 3/3 checkout: allow -b/-B to work on a merge baseDenton Liu, Apr 25, 2019
  9. Junio C HamanoApr 26, 2019
  10. Junio C HamanoApr 26, 2019
  11. 0/3 allow checkout and branch to create branches on a merge baseDenton Liu, Apr 26, 2019
  12. 1/3 t2018: cleanup in current testDenton Liu, Apr 26, 2019
  13. 2/3 t2018: demonstrate checkout -b merge base bugDenton Liu, Apr 26, 2019
  14. 3/3 branch: make create_branch accept a merge base revDenton Liu, Apr 26, 2019
  15. Junio C HamanoApr 26, 2019
  16. Denton LiuApr 26, 2019
  17. Denton LiuApr 26, 2019
  18. Junio C HamanoApr 27, 2019
  19. 0/2 allow checkout and branch to create branches on a merge baseDenton Liu, Apr 27, 2019
  20. 1/2 t2018: cleanup in current testDenton Liu, Apr 27, 2019
  21. 2/2 branch: make create_branch accept a merge base revDenton Liu, Apr 27, 2019

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.