Merge branch 'hb/t0061-dot-in-path-fix'
authorJunio C Hamano <gitster@pobox.com>
Mon, 14 Jan 2019 23:29:29 +0000 (15:29 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 14 Jan 2019 23:29:29 +0000 (15:29 -0800)
Test update.

* hb/t0061-dot-in-path-fix:
t0061: do not fail test if '.' is part of $PATH

1  2 
t/t0061-run-command.sh
diff --combined t/t0061-run-command.sh
index 96bf6d6a7d0145334666fcd15373bad6ac66fd67,e622024cb28b9b8feb9863d0defc6a86b2c49fc9..99a614bc7c45ca792c7bbce7d16f793ab6107896
@@@ -11,32 -11,38 +11,40 @@@ cat >hello-script <<-EO
        #!$SHELL_PATH
        cat hello-script
  EOF
 ->empty
  
  test_expect_success 'start_command reports ENOENT (slash)' '
 -      test-run-command start-command-ENOENT ./does-not-exist
 +      test-tool run-command start-command-ENOENT ./does-not-exist 2>err &&
 +      test_i18ngrep "\./does-not-exist" err
  '
  
  test_expect_success 'start_command reports ENOENT (no slash)' '
 -      test-run-command start-command-ENOENT does-not-exist
 +      test-tool run-command start-command-ENOENT does-not-exist 2>err &&
 +      test_i18ngrep "does-not-exist" err
  '
  
  test_expect_success 'run_command can run a command' '
        cat hello-script >hello.sh &&
        chmod +x hello.sh &&
 -      test-run-command run-command ./hello.sh >actual 2>err &&
 +      test-tool run-command run-command ./hello.sh >actual 2>err &&
  
        test_cmp hello-script actual &&
 -      test_cmp empty err
 +      test_must_be_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
 -      test_must_fail test-run-command run-command should-not-run
 +      test_must_fail test-tool run-command run-command should-not-run 2>err &&
 +      test_i18ngrep "should-not-run" err
  '
  
  test_expect_success !MINGW 'run_command can run a script without a #! line' '
        cat hello-script
        EOF
        chmod +x hello &&
 -      test-run-command run-command ./hello >actual 2>err &&
 +      test-tool run-command run-command ./hello >actual 2>err &&
  
        test_cmp hello-script actual &&
 -      test_cmp empty err
 +      test_must_be_empty err
  '
  
  test_expect_success 'run_command does not try to execute a directory' '
@@@ -58,9 -64,9 +66,9 @@@
        EOF
  
        PATH=$PWD/bin1:$PWD/bin2:$PATH \
 -              test-run-command run-command greet >actual 2>err &&
 +              test-tool run-command run-command greet >actual 2>err &&
        test_cmp bin2/greet actual &&
 -      test_cmp empty err
 +      test_must_be_empty err
  '
  
  test_expect_success POSIXPERM 'run_command passes over non-executable file' '
        EOF
  
        PATH=$PWD/bin1:$PWD/bin2:$PATH \
 -              test-run-command run-command greet >actual 2>err &&
 +              test-tool run-command run-command greet >actual 2>err &&
        test_cmp bin2/greet actual &&
 -      test_cmp empty err
 +      test_must_be_empty err
  '
  
  test_expect_success POSIXPERM 'run_command reports EACCES' '
        cat hello-script >hello.sh &&
        chmod -x hello.sh &&
 -      test_must_fail test-run-command run-command ./hello.sh 2>err &&
 +      test_must_fail test-tool run-command run-command ./hello.sh 2>err &&
  
        grep "fatal: cannot exec.*hello.sh" err
  '
@@@ -117,17 -123,17 +125,17 @@@ Worl
  EOF
  
  test_expect_success 'run_command runs in parallel with more jobs available than tasks' '
 -      test-run-command run-command-parallel 5 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
 +      test-tool run-command run-command-parallel 5 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
        test_cmp expect actual
  '
  
  test_expect_success 'run_command runs in parallel with as many jobs as tasks' '
 -      test-run-command run-command-parallel 4 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
 +      test-tool run-command run-command-parallel 4 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
        test_cmp expect actual
  '
  
  test_expect_success 'run_command runs in parallel with more tasks than jobs available' '
 -      test-run-command run-command-parallel 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
 +      test-tool run-command run-command-parallel 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
        test_cmp expect actual
  '
  
@@@ -141,7 -147,7 +149,7 @@@ asking for a quick sto
  EOF
  
  test_expect_success 'run_command is asked to abort gracefully' '
 -      test-run-command run-command-abort 3 false 2>actual &&
 +      test-tool run-command run-command-abort 3 false 2>actual &&
        test_cmp expect actual
  '
  
@@@ -150,45 -156,8 +158,45 @@@ no further jobs availabl
  EOF
  
  test_expect_success 'run_command outputs ' '
 -      test-run-command run-command-no-jobs 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
 +      test-tool run-command run-command-no-jobs 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
        test_cmp expect actual
  '
  
 +test_trace () {
 +      expect="$1"
 +      shift
 +      GIT_TRACE=1 test-tool run-command "$@" run-command true 2>&1 >/dev/null | \
 +              sed -e 's/.* run_command: //' -e '/trace: .*/d' >actual &&
 +      echo "$expect true" >expect &&
 +      test_cmp expect actual
 +}
 +
 +test_expect_success 'GIT_TRACE with environment variables' '
 +      test_trace "abc=1 def=2" env abc=1 env def=2 &&
 +      test_trace "abc=2" env abc env abc=1 env abc=2 &&
 +      test_trace "abc=2" env abc env abc=2 &&
 +      (
 +              abc=1 && export abc &&
 +              test_trace "def=1" env abc=1 env def=1
 +      ) &&
 +      (
 +              abc=1 && export abc &&
 +              test_trace "def=1" env abc env abc=1 env def=1
 +      ) &&
 +      test_trace "def=1" env non-exist env def=1 &&
 +      test_trace "abc=2" env abc=1 env abc env abc=2 &&
 +      (
 +              abc=1 def=2 && export abc def &&
 +              test_trace "unset abc def;" env abc env def
 +      ) &&
 +      (
 +              abc=1 def=2 && export abc def &&
 +              test_trace "unset def; abc=3" env abc env def env abc=3
 +      ) &&
 +      (
 +              abc=1 && export abc &&
 +              test_trace "unset abc;" env abc=2 env abc
 +      )
 +'
 +
  test_done