aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Mark Schaller <mschaller@google.com>2015-10-07 21:25:19 +0000
committerGravatar Han-Wen Nienhuys <hanwen@google.com>2015-10-08 12:11:46 +0000
commitaff46bc2f0e59cb9b59f6db982ddd490cf1d2b3c (patch)
tree6dfc781b94c40d28af55090873d3aed92fd14a2d /src
parent79be96fcf183d992d8b6347816f8511c8956435d (diff)
Increase visibility of an InMemoryNodeEntry method
For use in alternate graph implementations. Also adds some user-friendly methods to StringValue, a SkyValue implementation used in tests. -- MOS_MIGRATED_REVID=104899226
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java7
-rw-r--r--src/test/java/com/google/devtools/build/skyframe/GraphTester.java22
2 files changed, 25 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java b/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java
index 094d40a2e3..825584e596 100644
--- a/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java
+++ b/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java
@@ -130,8 +130,7 @@ public class InMemoryNodeEntry implements NodeEntry {
* The transient state of this entry, after it has been created but before it is done. It allows
* us to keep the current state of the entry across invalidation and successive evaluations.
*/
- @VisibleForTesting
- protected BuildingState buildingState = new BuildingState();
+ @VisibleForTesting @Nullable protected BuildingState buildingState = new BuildingState();
/**
* Construct a InMemoryNodeEntry. Use ONLY in Skyframe evaluation and graph implementations.
@@ -184,7 +183,7 @@ public class InMemoryNodeEntry implements NodeEntry {
/**
* If {@code isDone()}, returns the ordered list of sets of grouped direct dependencies that were
- * added in {@link addTemporaryDirectDeps}.
+ * added in {@link #addTemporaryDirectDeps}.
*/
public synchronized Iterable<Iterable<SkyKey>> getGroupedDirectDeps() {
assertKeepEdges();
@@ -199,7 +198,7 @@ public class InMemoryNodeEntry implements NodeEntry {
return ValueWithMetadata.getMaybeErrorInfo(value);
}
- private synchronized Set<SkyKey> setStateFinishedAndReturnReverseDeps() {
+ protected synchronized Set<SkyKey> setStateFinishedAndReturnReverseDeps() {
// Get reverse deps that need to be signaled.
ImmutableSet<SkyKey> reverseDepsToSignal = buildingState.getReverseDepsToSignal();
REVERSE_DEPS_UTIL.consolidateData(this);
diff --git a/src/test/java/com/google/devtools/build/skyframe/GraphTester.java b/src/test/java/com/google/devtools/build/skyframe/GraphTester.java
index db686b22ad..04d76db919 100644
--- a/src/test/java/com/google/devtools/build/skyframe/GraphTester.java
+++ b/src/test/java/com/google/devtools/build/skyframe/GraphTester.java
@@ -13,10 +13,13 @@
// limitations under the License.
package com.google.devtools.build.skyframe;
+import static com.google.common.truth.Truth.assertThat;
+
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.util.Pair;
+import com.google.devtools.build.skyframe.SkyFunction.Environment;
import com.google.devtools.build.skyframe.SkyFunctionException.Transience;
import java.util.Collection;
@@ -308,6 +311,15 @@ public class GraphTester {
public String toString() {
return "StringValue: " + getValue();
}
+
+ public static StringValue of(String string) {
+ return new StringValue(string);
+ }
+
+ public static StringValue from(SkyValue skyValue) {
+ assertThat(skyValue).isInstanceOf(StringValue.class);
+ return (StringValue) skyValue;
+ }
}
/**
@@ -336,4 +348,14 @@ public class GraphTester {
return new StringValue(result.toString());
}
};
+
+ public static ValueComputer formatter(final SkyKey key, final String format) {
+ return new ValueComputer() {
+ @Override
+ public SkyValue compute(Map<SkyKey, SkyValue> deps, Environment env)
+ throws InterruptedException {
+ return StringValue.of(String.format(format, StringValue.from(deps.get(key)).getValue()));
+ }
+ };
+ }
}