aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google
diff options
context:
space:
mode:
authorGravatar Ulf Adams <ulfjack@google.com>2017-02-07 16:06:39 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2017-02-07 18:27:15 +0000
commit43765af888e5b3334e915b696205b835f56ae0ee (patch)
treef7d08fdce0c20119f77270956c8368a4eed1bbcf /src/test/java/com/google
parenta8bc05788acf224c1c91aa614a2ca7d4527d62f5 (diff)
Remove dead code in SkyframeLabelVisitor
Two of the functions are never used, several of the parameter are not used or can be simplified (require callers to convert from Target -> Label). -- PiperOrigin-RevId: 146787380 MOS_MIGRATED_REVID=146787380
Diffstat (limited to 'src/test/java/com/google')
-rw-r--r--src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java17
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java11
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java54
3 files changed, 12 insertions, 70 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java b/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java
index 3925329b4e..d2234c122c 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java
@@ -25,7 +25,6 @@ import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
import com.google.devtools.build.lib.packages.NoSuchPackageException;
import com.google.devtools.build.lib.packages.NoSuchTargetException;
-import com.google.devtools.build.lib.packages.NoSuchThingException;
import com.google.devtools.build.lib.packages.PackageFactory;
import com.google.devtools.build.lib.packages.PackageFactory.EnvironmentExtension;
import com.google.devtools.build.lib.packages.Preprocessor;
@@ -53,8 +52,6 @@ import com.google.devtools.build.skyframe.SkyFunctionName;
import com.google.devtools.common.options.Options;
import com.google.devtools.common.options.OptionsParser;
import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
@@ -262,20 +259,6 @@ public abstract class PackageLoadingTestCase extends FoundationTestCase {
return result;
}
- protected final Set<Target> asTargetSet(String... strLabels)
- throws LabelSyntaxException, NoSuchThingException, InterruptedException {
- return asTargetSet(Arrays.asList(strLabels));
- }
-
- protected Set<Target> asTargetSet(Iterable<String> strLabels)
- throws LabelSyntaxException, NoSuchThingException, InterruptedException {
- Set<Target> targets = new HashSet<>();
- for (String strLabel : strLabels) {
- targets.add(getTarget(strLabel));
- }
- return targets;
- }
-
protected PackageManager getPackageManager() {
return skyframeExecutor.getPackageManager();
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java
index f5c99ee35d..56452fb155 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java
@@ -38,6 +38,7 @@ import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.common.options.Options;
import java.io.IOException;
import java.util.Collection;
+import java.util.Set;
import java.util.UUID;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -535,17 +536,11 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
}
};
fs.stubStat(bazDir, inconsistentParentFileStatus);
- Label fooLabel = Label.parseAbsolute("//foo:foo");
+ Set<Label> labels = ImmutableSet.of(Label.parseAbsolute("//foo:foo"));
getSkyframeExecutor()
.getPackageManager()
.newTransitiveLoader()
- .sync(
- reporter, /*targetsToVisit=*/
- ImmutableSet.of(getTarget(fooLabel)),
- ImmutableSet.<Label>of(), /*keepGoing=*/
- true,
- /*parallelThreads=*/ 100, /*maxDepth=*/
- -1);
+ .sync(reporter, labels, /*keepGoing=*/ true, /*parallelThreads=*/ 100);
assertContainsEvent("Inconsistent filesystem operations");
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java
index 1fd0b74cc6..292a1fa11d 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java
@@ -15,7 +15,6 @@ package com.google.devtools.build.lib.skyframe;
import static com.google.common.truth.Truth.assertThat;
import static com.google.devtools.build.skyframe.WalkableGraphUtils.exists;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import com.google.common.base.Function;
@@ -27,7 +26,6 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
-import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventCollector;
import com.google.devtools.build.lib.events.EventKind;
@@ -43,7 +41,6 @@ import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.ModifiedFileSet;
import com.google.devtools.build.lib.vfs.Path;
-import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import com.google.devtools.build.skyframe.DelegatingWalkableGraph;
import com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator;
@@ -120,27 +117,10 @@ abstract public class SkyframeLabelVisitorTestCase extends PackageLoadingTestCas
* Check that the expected targets were exactly those visited, and that the packages of these
* expected targets were exactly those packages visited.
*/
- protected void assertExpectedTargets(Set<String> expectedLabels, Set<Target> startingTargets)
+ protected void assertExpectedTargets(Set<String> expectedLabels, Set<Label> startingLabels)
throws Exception {
- Set<Label> visitedLabels =
- getVisitedLabels(
- Iterables.transform(
- startingTargets,
- new Function<Target, Label>() {
- @Override
- public Label apply(Target target) {
- return target.getLabel();
- }
- }),
- getSkyframeExecutor());
+ Set<Label> visitedLabels = getVisitedLabels(startingLabels, getSkyframeExecutor());
assertThat(visitedLabels).containsExactlyElementsIn(asLabelSet(expectedLabels));
-
- Set<PathFragment> expectedPkgs = new HashSet<>();
- for (Label label : visitedLabels) {
- expectedPkgs.add(label.getPackageFragment());
- }
-
- assertEquals(expectedPkgs, getVisitedPackageNames(startingTargets));
}
/**
@@ -148,26 +128,24 @@ abstract public class SkyframeLabelVisitorTestCase extends PackageLoadingTestCas
* the dependency trees starting at startingLabels, and no other labels are visited.
*
* @param expectedLabels The expected set of labels visited.
- * @param startingLabels Visit the transitive closure of each of these labels.
+ * @param startingLabelStrings Visit the transitive closure of each of these labels.
* @param expectError Whether the visitation should succeed.
* @param keepGoing Whether the visitation continues after encountering
* errors.
*/
protected void assertLabelsVisited(
Set<String> expectedLabels,
- Set<String> startingLabels,
+ Set<String> startingLabelStrings,
boolean expectError,
boolean keepGoing)
throws Exception {
- Set<Target> startingTargets = asTargetSet(startingLabels);
+ Set<Label> startingLabels = asLabelSet(startingLabelStrings);
// Spawn a lot of threads to help uncover concurrency issues
- boolean result =
- visitor.sync(
- reporter, startingTargets, ImmutableSet.<Label>of(), keepGoing, 200, Integer.MAX_VALUE);
+ boolean result = visitor.sync(reporter, startingLabels, keepGoing, /*parallelThreads=*/ 200);
assertNotSame(expectError, result);
- assertExpectedTargets(expectedLabels, startingTargets);
+ assertExpectedTargets(expectedLabels, startingLabels);
}
/**
@@ -236,12 +214,10 @@ abstract public class SkyframeLabelVisitorTestCase extends PackageLoadingTestCas
boolean expectError,
boolean keepGoing)
throws Exception {
- Set<Target> targets = asTargetSet(startingLabels);
+ Set<Label> labels = asLabelSet(startingLabels);
// Spawn a lot of threads to help uncover concurrency issues
- boolean result =
- visitor.sync(
- reporter, targets, ImmutableSet.<Label>of(), keepGoing, 200, Integer.MAX_VALUE);
+ boolean result = visitor.sync(reporter, labels, keepGoing, 200);
assertNotSame(expectError, result);
assertThat(getVisitedLabels(asLabelSet(startingLabels), skyframeExecutor))
.containsAllIn(asLabelSet(expectedLabels));
@@ -256,7 +232,6 @@ abstract public class SkyframeLabelVisitorTestCase extends PackageLoadingTestCas
.invalidateFilesUnderPathForTesting(reporter, modifiedFileSet, rootDirectory);
}
- @Override
protected Set<Target> asTargetSet(Iterable<String> strLabels)
throws LabelSyntaxException, NoSuchThingException, InterruptedException {
Set<Target> targets = new HashSet<>();
@@ -267,17 +242,6 @@ abstract public class SkyframeLabelVisitorTestCase extends PackageLoadingTestCas
return targets;
}
- protected Set<PathFragment> getVisitedPackageNames(Set<Target> startingTargets) {
- ImmutableSet.Builder<PathFragment> builder = ImmutableSet.builder();
- for (PackageIdentifier packageId : visitor.getVisitedPackageNames()) {
- builder.add(packageId.getPackageFragment());
- }
- for (Target target : startingTargets) {
- builder.add(target.getPackage().getNameFragment());
- }
- return builder.build();
- }
-
@Before
public final void initializeVisitor() throws Exception {
setUpSkyframe(ConstantRuleVisibility.PRIVATE, loadingMock.getDefaultsPackageContent());