diff options
author | 2016-11-02 12:25:33 +0000 | |
---|---|---|
committer | 2016-11-02 15:57:05 +0000 | |
commit | 247ce2cbcabd1b237cf7c6b092f40896fd278977 (patch) | |
tree | 16646047a0c040b9c1ffa5d0615ec7c1b754be38 /src/main/java/com | |
parent | ca2c184affbc6da871b8c71d2dd3d54a2ef5f8d9 (diff) |
Description redacted.
--
MOS_MIGRATED_REVID=137935119
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/test/TestStrategy.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/TestStrategy.java b/src/main/java/com/google/devtools/build/lib/rules/test/TestStrategy.java index 9e26dfd0e2..27597967ad 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/test/TestStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/rules/test/TestStrategy.java @@ -34,6 +34,7 @@ import com.google.devtools.build.lib.util.ShellEscaper; import com.google.devtools.build.lib.util.io.FileWatcher; import com.google.devtools.build.lib.util.io.OutErr; import com.google.devtools.build.lib.vfs.FileStatus; +import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.vfs.SearchPath; @@ -67,6 +68,27 @@ public abstract class TestStrategy implements TestActionContext { } /** + * Ensures that all directories used to run test are in the correct state and + * their content will not result in stale files. + */ + protected void prepareFileSystem(TestRunnerAction testAction, Path tmpDir, + Path coverageDir, Path workingDirectory) throws IOException { + if (isCoverageMode(testAction)) { + recreateDirectory(coverageDir); + } + recreateDirectory(tmpDir); + FileSystemUtils.createDirectoryAndParents(workingDirectory); + } + + /** + * Removes directory if it exists and recreates it. + */ + protected void recreateDirectory(Path directory) throws IOException { + FileSystemUtils.deleteTree(directory); + FileSystemUtils.createDirectoryAndParents(directory); + } + + /** * Converter for the --flaky_test_attempts option. */ public static class TestAttemptsConverter extends RangeConverter { |