diff --git a/src/main/java/com/google/devtools/build/lib/analysis/test/TestStrategy.java b/src/main/java/com/google/devtools/build/lib/analysis/test/TestStrategy.java index a3b10768902ec2..8c3f20624b6051 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/test/TestStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/test/TestStrategy.java @@ -195,7 +195,7 @@ private static void addRunUnderArgs( TestRunnerAction testAction, List args, boolean executedOnWindows) { TestTargetExecutionSettings execSettings = testAction.getExecutionSettings(); if (execSettings.getRunUnderExecutable() != null) { - args.add(execSettings.getRunUnderExecutable().getRootRelativePath().getCallablePathString()); + args.add(execSettings.getRunUnderExecutable().getRunfilesPath().getCallablePathString()); } else { if (execSettings.needsShell(executedOnWindows)) { // TestActionBuilder constructs TestRunnerAction with a 'null' shell only when none is diff --git a/src/test/shell/bazel/bazel_test_test.sh b/src/test/shell/bazel/bazel_test_test.sh index 2d61777296621e..662b27bdc8e44d 100755 --- a/src/test/shell/bazel/bazel_test_test.sh +++ b/src/test/shell/bazel/bazel_test_test.sh @@ -266,6 +266,52 @@ EOF expect_log 'hello script!!! testing/t1' } +function test_run_under_external_file_with_options() { + # Set up the external repo. + local run_repo=$TEST_TMPDIR/run + mkdir -p $run_repo || fail "mkdir run_repo failed" + touch $run_repo/WORKSPACE + + cat < $run_repo/BUILD +exports_files(["under.sh"]) +EOF + cat < $run_repo/under.sh +#!/bin/sh +echo running under @run//:under "\$*" +EOF + chmod u+x $run_repo/under.sh + + + # Set up the main repo. + cat < WORKSPACE +local_repository( + name = "run", + path = "../run", +) +EOF + + mkdir -p testing || fail "mkdir testing failed" + + cat < testing/BUILD +sh_test( + name = "passing_test" , + srcs = [ "passing_test.sh" ]) +EOF + cat < testing/passing_test.sh +#!/bin/sh +exit 0 +EOF + chmod u+x testing/passing_test.sh + + + bazel test //testing:passing_test -s --run_under='@run//:under.sh -c' \ + --test_output=all >& $TEST_log || fail "Expected success" + + expect_log 'running under @run//:under -c testing/passing_test' + expect_log 'passing_test *PASSED' + expect_log '1 test passes.$' +} + function test_test_timeout() { mkdir -p dir