From: Junio C Hamano Date: Mon, 3 Dec 2018 01:05:07 +0000 (+0900) Subject: t0061: do not fail test if '.' is part of $PATH X-Git-Tag: v2.21.0-rc0~119^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=89ba9a79ae3a4d828880cdcdc1b5f6aa92be662c;p=git 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" Helped-by: Johannes Schindelin Helped-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh index 0303ddbb64..e622024cb2 100755 --- a/t/t0061-run-command.sh +++ b/t/t0061-run-command.sh @@ -30,7 +30,15 @@ test_expect_success 'run_command can run a command' ' 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 && echo yikes EOF