Web lists-archives.com

[PATCH] Do not fail test if '.' is part of $PATH




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

This patch was tested with PATH=$PATH, PATH=.:$PATH, PATH=$PATH:.,
PATH=$PATH:.:/bin, PATH=:$PATH, PATH=$PATH:, and PATH=$PATH::/bin

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@xxxxxx>
Tested-by: H.Merijn Brand - Tux <h.m.brand@xxxxxxxxx>

diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh
index cf932c851..557f87442 100755
--- a/t/t0061-run-command.sh
+++ b/t/t0061-run-command.sh
@@ -29,7 +29,14 @@ test_expect_success 'run_command can run a command' '
        test_must_be_empty err
 '

-test_expect_success 'run_command is restricted to PATH' '
+test_lazy_prereq DOT_IN_PATH '
+       case ":$PATH:" in
+       *:.:*|*::*) true  ;;
+       *)          false ;;
+       esac
+'
+
+test_expect_success !DOT_IN_PATH 'run_command is restricted to PATH' '
        write_script should-not-run <<-\EOF &&
        echo yikes
        EOF

-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.29   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

Attachment: pgpMh7EdMFH5f.pgp
Description: OpenPGP digital signature