diff options
author | 2016-08-19 08:53:04 +0000 | |
---|---|---|
committer | 2016-08-19 09:52:57 +0000 | |
commit | f9fa99d0c1a25d0f7c2753043c5f88cce2cac255 (patch) | |
tree | 36a73a370bdcc6358f2d16d5893091e30a6b0099 /src/main/java/com/google/devtools/build | |
parent | 4365be461122eb6e1afbe9bd186dc4164d36b552 (diff) |
Number test directories from one separately from each basename so that we don't litter test directories in the output base.
--
MOS_MIGRATED_REVID=130730383
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/test/TestStrategy.java | 14 |
1 files changed, 10 insertions, 4 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 1bbd5c7d46..ce9e08d8c6 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 @@ -51,7 +51,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; import javax.annotation.Nullable; /** @@ -127,8 +126,9 @@ public abstract class TestStrategy implements TestActionContext { // Used for selecting subset of testcase / testmethods. private static final String TEST_BRIDGE_TEST_FILTER_ENV = "TESTBRIDGE_TEST_ONLY"; - // Used for generating unique temporary directory names. - private final AtomicInteger tmpIndex = new AtomicInteger(0); + // Used for generating unique temporary directory names. Contains the next numeric index for every + // executable base name. + private final Map<String, Integer> tmpIndex = new HashMap<>(); protected final ImmutableMap<String, String> clientEnv; protected final ExecutionOptions executionOptions; protected final BinTools binTools; @@ -296,7 +296,13 @@ public abstract class TestStrategy implements TestActionContext { * <p>This does not create the directory.</p> */ protected String getTmpDirName(PathFragment execPath) { - return execPath.getBaseName() + "_" + tmpIndex.incrementAndGet(); + String basename = execPath.getBaseName(); + + synchronized (tmpIndex) { + int index = tmpIndex.containsKey(basename) ? tmpIndex.get(basename) : 1; + tmpIndex.put(basename, index + 1); + return basename + "_" + index; + } } /** |