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

Re: [PATCH 1/2] tests: add test case for autocorrect in work tree for bare clone

From
Simon Gerber <gesimu@gmail.com>
Date
Oct 29, 2022, 08:07 UTC
Message-ID
<CAAyHH32vj14Q9B+diFqGBc4db-C-raxp1F+WZEWdhx66_N+MXA@mail.gmail.com>
In-Reply-To
<xmqq4jvniw7q.fsf@gitster.g>
On Fri, 28 Oct 2022 at 21:28, Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
>
> "Simon Gerber via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> >  t/t9005-help-autocorrect-worktree.sh | 29 ++++++++++++++++++++++++++++
>
> Don't we have existing test script for auto-correction?  Is it
> sensible to waste a new fail for this single test?  I doubt it.
>
> Perhaps appending after 9003 a new test instead?

I'll move the test to 9003. I was considering doing so in the beginning, but was hesitant to add an only vaguely related test in 9003 which has the description "help.autocorrect finding a match".

Show 58 quoted lines
>
> > diff --git a/t/t9005-help-autocorrect-worktree.sh b/t/t9005-help-autocorrect-worktree.sh
> > new file mode 100755
> > index 00000000000..4fecc8a8e01
> > --- /dev/null
> > +++ b/t/t9005-help-autocorrect-worktree.sh
> > @@ -0,0 +1,29 @@
> > +#!/bin/sh
> > +
> > +test_description='test autocorrect in work tree based on bare repository'
> > +. ./test-lib.sh
> > +
> > +test_expect_success 'setup non-bare' '
> > +     echo one >file &&
> > +     git add file &&
> > +     git commit -m one &&
> > +     echo two >file &&
> > +     git commit -a -m two
> > +'
>
> Wouldn't "test_commit" be simpler to use than rolling our own here?
> If we piggy-back on set-up in an existing test script, there
> probably is already a history the single test to attempt running
> 'git staut' can use.  After all, that test does not care an iota
> what is in the history.
>
> > +
> > +test_expect_success 'setup bare' '
> > +     git clone --bare . bare.git &&
> > +     cd bare.git
>
> Do not chdir around in a test script, especially in separate steps.
>
> > +'
> > +
> > +test_expect_success 'setup worktree from bare' '
> > +     git worktree add ../bare-wt &&
> > +     cd ../bare-wt
> > +'
>
> Ditto.
>
> Either do it in a subshell in a single step, or
>
>         (
>                 git clone --bare . bare.git &&
>                 cd bare.git &&
>                 git worktree add ../worktree &&
>                 cd ../worktree &&
>                 git -c help.autocorrect=immediate staut
>         )
>
> use "git -C <over-there>" form, e.g.
>
>         git clone --bare . bare.git &&
>         git -C bare.git worktree add ../worktree &&
>         git -C worktree -c help.autocorrect=immediate staut
>

Thanks for taking the time to point out how I'm supposed to use the test framework, I was pretty lost trying to write my test and ended up copying some bits from 7103.

Show 21 quoted lines
> > +test_expect_success 'autocorrect works in work tree created from bare repo' '
>
> When patch 1/2 is applied without 2/2, this test_expect_success will
> not be satisfied, breaking future bisection.
>
> For a small change like this, have the code change *and* test that
> verifies the new behaviour in a single step.  That way
>
>  * you do not break bisection.
>
>  * if somebody wants to cherry-pick the fix to an older maintenance
>    tracks, they can do so by picking a single unit, fix and
>    verification combined together.
>
>  * acceptance or review can be done by checking the end-result and
>    then tentatively reverting only the code change with something
>    like
>
>         $ git show -- ':!t/' | git apply -R
>
>    and see the test that expects success actually fails without the fix.
That makes sense. I'll resubmit this as a single patch.
Previous: Junio C HamanoNext: Simon Gerber via GitGitGadget
Message 5 of 9 in “Fix autocorrect in work tree for bare repository”
  1. 0/2 Fix autocorrect in work tree for bare repositorySimon Gerber via GitGitGadget, Oct 28, 2022
  2. 2/2 help.c: don't call git_default_config in git_unknown_cmd_configSimon Gerber via GitGitGadget, Oct 28, 2022
  3. 1/2 tests: add test case for autocorrect in work tree for bare cloneSimon Gerber via GitGitGadget, Oct 28, 2022
  4. Junio C HamanoOct 28, 2022
  5. Simon GerberOct 29, 2022
  6. help.c: fix autocorrect in work tree for bare repositorySimon Gerber via GitGitGadget, Oct 29, 2022
  7. Simon GerberDec 12, 2022
  8. Junio C HamanoDec 13, 2022
  9. Simon GerberDec 13, 2022

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.