From: Jeff King <peff@peff.net>
To: "H.Merijn Brand" <h.m.brand@xs4all.nl>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Do not fail test if '.' is part of $PATH
Date: Sat, 1 Dec 2018 14:38:22 -0500 [thread overview]
Message-ID: <20181201193822.GA28918@sigill.intra.peff.net> (raw)
In-Reply-To: <20181201180757.0b2d3c89@pc09.procura.nl>
On Sat, Dec 01, 2018 at 06:07:57PM +0100, H.Merijn Brand wrote:
> When $PATH contains the current directory as .:PATH, PATH:., PATH:.:PATH,
> or (maybe worse) as :PATH, PATH:, or PATH::PATH - as an empty entry is
> identical to having dot in $PATH - this test used to fail
Good catch. The test cares about Git not accidentally adding "." to the
PATH, but we can't check that if it is already there.
> This patch was tested with PATH=$PATH, PATH=.:$PATH, PATH=$PATH:.,
> PATH=$PATH:.:/bin, PATH=:$PATH, PATH=$PATH:, and PATH=$PATH::/bin
> [...]
> +test_lazy_prereq DOT_IN_PATH '
> + case ":$PATH:" in
> + *:.:*|*::*) true ;;
> + *) false ;;
> + esac
> +'
Since the test is ultimately checking "can we run should-not-run from
the current directory", might it be simpler to actually try that as the
precondition? I.e., something like:
test_expect_success 'create program in current directory' '
write_script should-not-run <<-\EOF &&
echo yikes
EOF
'
test_lazy_prereq DOT_IN_PATH '
should-not-run
'
test_expect_success !DOT_IN_PATH 'run_command is restricted to PATH' '
test_must_fail test-tool run-command run-command should-not-run
'
?
That's more lines, but we don't have to peek into the details of how
$PATH works.
-Peff
next prev parent reply other threads:[~2018-12-01 19:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-01 17:07 [PATCH] Do not fail test if '.' is part of $PATH H.Merijn Brand
2018-12-01 19:38 ` Jeff King [this message]
2018-12-03 0:29 ` Junio C Hamano
2018-12-03 1:00 ` Junio C Hamano
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=20181201193822.GA28918@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=h.m.brand@xs4all.nl \
/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).