Browse Source

t0061: do not fail test if '.' is part of $PATH

t0061 creates a script with an unlikely name in the current
directory and asks the run_command() API to run it without an
explicit path, expecting that the script does *not* get run.  This
obviously would not work if the $PATH does contain such an element.

Check if the running shell picks up the script without an explicit
path to it, and skip the test when it does, as the run_command() API
should also run the script in such an (insane) environment.

Reported-by: "H.Merijn Brand" <h.m.brand@xs4all.nl>
Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Junio C Hamano 6 years ago
parent
commit
89ba9a79ae
  1. 10
      t/t0061-run-command.sh

10
t/t0061-run-command.sh

@ -30,7 +30,15 @@ test_expect_success 'run_command can run a command' '
test_cmp empty err test_cmp empty err
' '


test_expect_success 'run_command is restricted to PATH' '
test_lazy_prereq RUNS_COMMANDS_FROM_PWD '
write_script runs-commands-from-pwd <<-\EOF &&
true
EOF
runs-commands-from-pwd >/dev/null 2>&1
'

test_expect_success !RUNS_COMMANDS_FROM_PWD 'run_command is restricted to PATH' '
write_script should-not-run <<-\EOF && write_script should-not-run <<-\EOF &&
echo yikes echo yikes
EOF EOF

Loading…
Cancel
Save