diff options
author | felly <felly@google.com> | 2018-06-08 10:02:39 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-08 10:03:51 -0700 |
commit | cd751ca2bb3677a15e0187f764415a6659417624 (patch) | |
tree | 9acfc0b57e1c9e937169dc9b7a148f7ae6a530ea /src/main/java/com/google/devtools/build/lib/analysis/test | |
parent | dc3a91aec0a840baa0b897cde81ac2e8f7bb5eff (diff) |
Support basic test functionality in ActionFS.
ActionFS now allows output files to be created that do not correspond to known Artifacts.
Note that tests exercise a greater gamut of filesystem functionality (deleting files, deleting directory trees, moving files, etc.)
RELNOTES: None
PiperOrigin-RevId: 199809069
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/test')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/test/TestResult.java | 2 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/test/TestRunnerAction.java | 25 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/test/TestResult.java b/src/main/java/com/google/devtools/build/lib/analysis/test/TestResult.java index a8ef2acb40..1a386ab847 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/test/TestResult.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/test/TestResult.java @@ -167,6 +167,6 @@ public class TestResult { */ private Collection<Pair<String, Path>> getFiles() { // TODO(ulfjack): Cache the set of generated files in the TestResultData. - return testAction.getTestOutputsMapping(execRoot); + return testAction.getTestOutputsMapping(null, execRoot); } } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/test/TestRunnerAction.java b/src/main/java/com/google/devtools/build/lib/analysis/test/TestRunnerAction.java index 6c4606df51..f03dcaff33 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/test/TestRunnerAction.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/test/TestRunnerAction.java @@ -239,13 +239,15 @@ public class TestRunnerAction extends AbstractAction implements NotifyOnActionCa * file system for existence of these output files, so it must only be used after test execution. */ // TODO(ulfjack): Instead of going to local disk here, use SpawnResult (add list of files there). - public ImmutableList<Pair<String, Path>> getTestOutputsMapping(Path execRoot) { + public ImmutableList<Pair<String, Path>> getTestOutputsMapping( + @Nullable ActionExecutionContext context, Path execRoot) { ImmutableList.Builder<Pair<String, Path>> builder = ImmutableList.builder(); - if (getTestLog().getPath().exists()) { - builder.add(Pair.of(TestFileNameConstants.TEST_LOG, getTestLog().getPath())); + if (convertPath(context, getTestLog()).exists()) { + builder.add(Pair.of(TestFileNameConstants.TEST_LOG, convertPath(context, getTestLog()))); } - if (getCoverageData() != null && getCoverageData().getPath().exists()) { - builder.add(Pair.of(TestFileNameConstants.TEST_COVERAGE, getCoverageData().getPath())); + if (getCoverageData() != null && convertPath(context, getCoverageData()).exists()) { + builder.add(Pair.of(TestFileNameConstants.TEST_COVERAGE, + convertPath(context, getCoverageData()))); } if (execRoot != null) { ResolvedPaths resolvedPaths = resolve(execRoot); @@ -293,6 +295,13 @@ public class TestRunnerAction extends AbstractAction implements NotifyOnActionCa return builder.build(); } + private static Path convertPath(@Nullable ActionExecutionContext actionContext, + Artifact artifact) { + return actionContext == null + ? artifact.getPath() + : actionContext.getInputPath(artifact); + } + @Override protected void computeKey(ActionKeyContext actionKeyContext, Fingerprint fp) throws CommandLineExpansionException { @@ -335,8 +344,10 @@ public class TestRunnerAction extends AbstractAction implements NotifyOnActionCa } /** Saves cache status to disk. */ - public void saveCacheStatus(TestResultData data) throws IOException { - try (OutputStream out = cacheStatus.getPath().getOutputStream()) { + public void saveCacheStatus( + ActionExecutionContext actionExecutionContext, + TestResultData data) throws IOException { + try (OutputStream out = actionExecutionContext.getInputPath(cacheStatus).getOutputStream()) { data.writeTo(out); } } |