For standalone tests, cd into the workspace directory before running the test script.
--
MOS_MIGRATED_REVID=101937276
diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java b/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java
index 377e95c..2e29789 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java
@@ -159,6 +159,7 @@
*/
vars.put("TEST_SRCDIR", runfilesDir.getPathString());
vars.put("TEST_TMPDIR", tmpDir.getPathString());
+ vars.put("TEST_WORKSPACE", action.getRunfilesPrefix());
vars.put("XML_OUTPUT_FILE", resolvedPaths.getXmlOutputPath().getPathString());
return vars;
diff --git a/tools/test/test-setup.sh b/tools/test/test-setup.sh
index eab081a..d5ee1ba 100755
--- a/tools/test/test-setup.sh
+++ b/tools/test/test-setup.sh
@@ -22,6 +22,11 @@
DIR="$TEST_SRCDIR"
+if [ ! -z "$TEST_WORKSPACE" ]
+then
+ DIR="$DIR"/"$TEST_WORKSPACE"
+fi
+
# normal commands are run in the exec-root where they have access to
# the entire source tree. By chdir'ing to the runfiles root, tests only
# have direct access to their declared dependencies.