git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Fleischer <lfleischer@lfos.de>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: "Git List" <git@vger.kernel.org>
Subject: Re: [PATCH 4/4] t5509: add basic tests for hideRefs
Date: Mon, 02 Nov 2015 07:25:19 +0100	[thread overview]
Message-ID: <20151102062449.24971.39537@typhoon> (raw)
In-Reply-To: <CAPig+cR7sCqigz=--_d-bW0X=+vpbV-_N9hxriLH9fMjLJUfsA@mail.gmail.com>

On Sun, 01 Nov 2015 at 22:13:51, Eric Sunshine wrote:
> On Sun, Nov 1, 2015 at 2:34 PM, Lukas Fleischer <lfleischer@lfos.de> wrote:
> > Test whether regular and full hideRefs patterns work as expected when
> > namespaces are used.
> >
> > Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
> > ---
> > diff --git a/t/t5509-fetch-push-namespaces.sh b/t/t5509-fetch-push-namespaces.sh
> > @@ -82,4 +82,33 @@ test_expect_success 'mirroring a repository using a ref namespace' '
> >         )
> >  '
> >
> > +test_expect_success "Hide namespaced refs with transfer.hideRefs" '
> 
> None of the other tests in this file capitalize the test description.
> These new test descriptions should probably follow suit by beginning
> with lowercase. It is also typical to use single quotes for the
> description rather than double.
> 

Good catch. I originally put these tests somewhere else and noticed that
adding them to t5509 is much better since we already set up the whole
namespace infrastructure there. Seems like I forgot to adjust the style.
Fixed that locally.

> > +       cd pushee &&
> > +       test_config transfer.hideRefs refs/tags &&
> > +       GIT_NAMESPACE=namespace git ls-remote "ext::git %s ." >actual &&
> > +       printf "$commit1    refs/heads/master\n" >expected &&
> > +       test_cmp expected actual &&
> > +       cd ..
> 
> If any of the commands above "cd .." fail, then "cd .." will never be
> invoked, thus subsequent tests will fail since they won't be executed
> in the expected directory. The typical way to handle this is to place
> the "cd foo" and remaining test body in a subshell, and drop "cd .."
> altogether. When the subshell exits (via success or failure), the
> working directory will be restored automatically.
> 
>     test_expect_success '...' '
>         (
>             cd pushee &&
>             test_config ... &&
>             ...
>         )
>     '
> [...]

I chose the `cd ..` approach because test_config does not work from a
subshell. However, searching the Git log for "test_config", I found
1a9a23e (t7610: don't use test_config in a subshell, 2015-09-05) and
da568b6 (t7800: don't use test_config in a subshell, 2015-09-05) which
suggest to use the -C switch. The test cases now look like this:

    test_expect_success '[...]' '
        test_config -C pushee transfer.hideRefs [...] &&
        (
            cd pushee &&
            [...]
        )
    '

Thanks!

  reply	other threads:[~2015-11-02  6:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-01 19:34 [PATCH 0/4] Improve hideRefs when used with namespaces Lukas Fleischer
2015-11-01 19:34 ` [PATCH 1/4] Document the semantics of hideRefs " Lukas Fleischer
2015-11-01 19:34 ` [PATCH 2/4] upload-pack: strip refs before calling ref_is_hidden() Lukas Fleischer
2015-11-01 19:34 ` [PATCH 3/4] Add support for matching full refs in hideRefs Lukas Fleischer
2015-11-01 20:42   ` Eric Sunshine
2015-11-02  5:47     ` Lukas Fleischer
2015-11-01 19:34 ` [PATCH 4/4] t5509: add basic tests for hideRefs Lukas Fleischer
2015-11-01 21:13   ` Eric Sunshine
2015-11-02  6:25     ` Lukas Fleischer [this message]
2015-11-02  7:30       ` Eric Sunshine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151102062449.24971.39537@typhoon \
    --to=lfleischer@lfos.de \
    --cc=git@vger.kernel.org \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).