aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java
diff options
context:
space:
mode:
authorGravatar Ulf Adams <ulfjack@google.com>2017-01-24 08:58:32 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2017-01-24 10:48:28 +0000
commit697db16687c0d62f1f26859dd34a02848709788e (patch)
treed8e3e25896971dd5c83a8c065e4e09428f509825 /src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java
parent9a7a5944574124afb70a31ddf704e57fa583f68a (diff)
Move the test environment setup to the TestRunnerAction.
This is part of unifying the test strategies; here, I'm working towards sharing the test environment setup. This change moves code from previously closed source code into the open source parts. The internal change is not visible, making this look like an addition rather than a move.. The next change hooks this up to Bazel. I did this in order to reduce the size of the change to make it easier to debug, review, and so that it's smaller in case we have to roll it back. Unfortunately, that requires duplicating some of the code in StandaloneTestStrategy until the next change lands. -- PiperOrigin-RevId: 145387109 MOS_MIGRATED_REVID=145387109
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java
index b6c8443d84..031d6183d0 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java
@@ -250,18 +250,43 @@ public class StandaloneTestStrategy extends TestStrategy {
env.put("TEST_SRCDIR", testSrcDir);
env.put("TEST_TMPDIR", tmpDirString);
env.put("TEST_WORKSPACE", action.getRunfilesPrefix());
+
+ // TODO(ulfjack): Call into TestRunnerAction.setupEnvVariables instead.
TestRunnerAction.ResolvedPaths resolvedPaths = action.resolve(execRoot);
env.put(
"XML_OUTPUT_FILE", resolvedPaths.getXmlOutputPath().relativeTo(execRoot).getPathString());
+ env.put("TEST_SIZE", action.getTestProperties().getSize().toString());
+ env.put("TEST_TIMEOUT", Integer.toString(getTimeout(action)));
+
+ // When we run test multiple times, set different TEST_RANDOM_SEED values for each run.
+ if (action.getConfiguration().getRunsPerTestForLabel(action.getOwner().getLabel()) > 1) {
+ env.put("TEST_RANDOM_SEED", Integer.toString(action.getRunNumber() + 1));
+ }
+
+ String testFilter = action.getExecutionSettings().getTestFilter();
+ if (testFilter != null) {
+ env.put("TESTBRIDGE_TEST_ONLY", testFilter);
+ }
+
+ if (action.isSharded()) {
+ env.put("TEST_SHARD_INDEX", Integer.toString(action.getShardNum()));
+ env.put(
+ "TEST_TOTAL_SHARDS", Integer.toString(action.getExecutionSettings().getTotalShards()));
+ }
if (!action.isEnableRunfiles()) {
env.put("RUNFILES_MANIFEST_ONLY", "1");
}
if (action.isCoverageMode()) {
+ env.put(
+ "COVERAGE_MANIFEST",
+ action.getExecutionSettings().getInstrumentedFileManifest().getExecPathString());
+ // Instruct remote-runtest.sh/local-runtest.sh not to cd into the runfiles directory.
+ env.put("RUNTEST_PRESERVE_CWD", "1");
+ env.put("MICROCOVERAGE_REQUESTED", action.isMicroCoverageMode() ? "true" : "false");
env.put("COVERAGE_DIR", action.getCoverageDirectory().toString());
env.put("COVERAGE_OUTPUT_FILE", action.getCoverageData().getExecPathString());
}
-
return env;
}