diff options
author | Googler <noreply@google.com> | 2016-10-31 14:54:37 +0000 |
---|---|---|
committer | Laszlo Csomor <laszlocsomor@google.com> | 2016-10-31 15:05:43 +0000 |
commit | 2dd4c183294b46a2509aef395596d39a17b7536f (patch) | |
tree | 0bd30facdea92546b41cbd31e56bc17c750aff52 /src/test/java/com/google/devtools/build/skyframe | |
parent | a5b1674d7b237965694217b82c907ac5d64ce053 (diff) |
Add method getCurrentlyAvailableNodes to QueryableGraph and Walkable Graph
It allows all graph implementations to return the list of nodes which are
immediately available to be fetched. NOTE: Not-currently-available here does
not mean the nodes do not exist in the graph. It simply means they are not
ready to be fetched immediately yet.
--
MOS_MIGRATED_REVID=137701432
Diffstat (limited to 'src/test/java/com/google/devtools/build/skyframe')
-rw-r--r-- | src/test/java/com/google/devtools/build/skyframe/GraphTest.java (renamed from src/test/java/com/google/devtools/build/skyframe/GraphConcurrencyTest.java) | 22 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/skyframe/InMemoryGraphTest.java (renamed from src/test/java/com/google/devtools/build/skyframe/InMemoryGraphConcurrencyTest.java) | 5 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/skyframe/NotifyingHelper.java | 5 |
3 files changed, 25 insertions, 7 deletions
diff --git a/src/test/java/com/google/devtools/build/skyframe/GraphConcurrencyTest.java b/src/test/java/com/google/devtools/build/skyframe/GraphTest.java index 649083581b..0510523cbe 100644 --- a/src/test/java/com/google/devtools/build/skyframe/GraphConcurrencyTest.java +++ b/src/test/java/com/google/devtools/build/skyframe/GraphTest.java @@ -43,8 +43,8 @@ import java.util.concurrent.TimeUnit; import org.junit.Before; import org.junit.Test; -/** Base class for concurrency sanity tests on {@link EvaluableGraph} implementations. */ -public abstract class GraphConcurrencyTest { +/** Base class for sanity tests on {@link EvaluableGraph} implementations. */ +public abstract class GraphTest { private static final SkyFunctionName SKY_FUNCTION_NAME = SkyFunctionName.FOR_TESTING; protected ProcessableGraph graph; @@ -154,8 +154,9 @@ public abstract class GraphConcurrencyTest { @Test public void testAddRemoveRdeps() throws Exception { SkyKey key = key("foo"); - final NodeEntry entry = Iterables.getOnlyElement( - graph.createIfAbsentBatch(null, Reason.OTHER, ImmutableList.of(key)).values()); + final NodeEntry entry = + Iterables.getOnlyElement( + graph.createIfAbsentBatch(null, Reason.OTHER, ImmutableList.of(key)).values()); // These numbers are arbitrary. int numThreads = 50; int numKeys = numThreads; @@ -459,6 +460,19 @@ public abstract class GraphConcurrencyTest { } } + @Test + public void testGetCurrentlyAvailableNodes() throws Exception { + SkyKey foo = key("foo"); + SkyKey bar = key("bar"); + SkyKey foobar = key("foobar"); + graph.createIfAbsentBatch(null, Reason.OTHER, ImmutableList.of(foo, bar)); + + Iterable<SkyKey> currentlyAvailable = + graph.getCurrentlyAvailableNodes(ImmutableList.of(foo, bar, foobar), Reason.OTHER); + + assertThat(currentlyAvailable).containsExactly(foo, bar); + } + private static DependencyState startEvaluation(NodeEntry entry) throws InterruptedException { return entry.addReverseDepAndCheckIfDone(null); } diff --git a/src/test/java/com/google/devtools/build/skyframe/InMemoryGraphConcurrencyTest.java b/src/test/java/com/google/devtools/build/skyframe/InMemoryGraphTest.java index 18d6875455..0180391540 100644 --- a/src/test/java/com/google/devtools/build/skyframe/InMemoryGraphConcurrencyTest.java +++ b/src/test/java/com/google/devtools/build/skyframe/InMemoryGraphTest.java @@ -14,13 +14,12 @@ package com.google.devtools.build.skyframe; import com.google.devtools.build.lib.util.Preconditions; - import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** Concurrency tests for {@link InMemoryGraphImpl}. */ +/** Tests for {@link InMemoryGraphImpl}. */ @RunWith(JUnit4.class) -public class InMemoryGraphConcurrencyTest extends GraphConcurrencyTest { +public class InMemoryGraphTest extends GraphTest { private ProcessableGraph graph; @Override diff --git a/src/test/java/com/google/devtools/build/skyframe/NotifyingHelper.java b/src/test/java/com/google/devtools/build/skyframe/NotifyingHelper.java index 6cde57318a..559b3cf252 100644 --- a/src/test/java/com/google/devtools/build/skyframe/NotifyingHelper.java +++ b/src/test/java/com/google/devtools/build/skyframe/NotifyingHelper.java @@ -100,6 +100,11 @@ public class NotifyingHelper { throws InterruptedException { return notifyingHelper.wrapEntry(key, delegate.get(requestor, reason, key)); } + + @Override + public Iterable<SkyKey> getCurrentlyAvailableNodes(Iterable<SkyKey> keys, Reason reason) { + return delegate.getCurrentlyAvailableNodes(keys, reason); + } } static class NotifyingProcessableGraph |