In `SequencedSkyframeExecutorTest`, inject values using `Injectable` instead of `GraphTransformerForTesting`.
This is one of the few tests that rely on the unspecified behavior of `injectGraphTransformerForTesting` applying the transform immediately and only once, which is currently true for `InMemoryMemoizingEvaluator` but not for other `MemoizingEvaluator` implementations.
Switch to `Injectable` which is better suited for injecting values and isn't a test-only channel.
PiperOrigin-RevId: 439870075
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorTest.java
index 4d3d771..4324ffc 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorTest.java
@@ -29,7 +29,6 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
import com.google.common.eventbus.EventBus;
import com.google.common.hash.HashCode;
import com.google.common.testing.GcFinalization;
@@ -130,14 +129,8 @@
import com.google.devtools.build.skyframe.Differencer.Diff;
import com.google.devtools.build.skyframe.EvaluationContext;
import com.google.devtools.build.skyframe.EvaluationResult;
-import com.google.devtools.build.skyframe.InMemoryGraph;
-import com.google.devtools.build.skyframe.InMemoryGraphImpl;
-import com.google.devtools.build.skyframe.InMemoryNodeEntry;
-import com.google.devtools.build.skyframe.MemoizingEvaluator.GraphTransformerForTesting;
import com.google.devtools.build.skyframe.NotifyingHelper;
import com.google.devtools.build.skyframe.NotifyingHelper.EventType;
-import com.google.devtools.build.skyframe.ProcessableGraph;
-import com.google.devtools.build.skyframe.QueryableGraph;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
import com.google.devtools.build.skyframe.TaggedEvents;
@@ -305,10 +298,9 @@
RootedPath file = RootedPath.toRootedPath(externalRoot, scratch.file("/external/file"));
initializeSkyframeExecutor(
/*doPackageLoadingChecks=*/ true, ImmutableList.of(nothingChangedDiffAwarenessFactory()));
- skyframeExecutor.memoizingEvaluator.injectGraphTransformerForTesting(
- inMemoryGraphWithValues(
- ImmutableMap.of(
- file, FileStateValue.create(file, SyscallCache.NO_CACHE, /*tsgm=*/ null))));
+ skyframeExecutor
+ .injectable()
+ .inject(file, FileStateValue.create(file, SyscallCache.NO_CACHE, /*tsgm=*/ null));
skyframeExecutor.externalFilesHelper.getAndNoteFileType(file);
// Initial sync to establish the baseline DiffAwareness.View.
skyframeExecutor.handleDiffsForTesting(NullEventHandler.INSTANCE);
@@ -335,10 +327,9 @@
RootedPath file = RootedPath.toRootedPath(externalRoot, scratch.file("/external/file"));
initializeSkyframeExecutor(
/*doPackageLoadingChecks=*/ true, ImmutableList.of(nothingChangedDiffAwarenessFactory()));
- skyframeExecutor.memoizingEvaluator.injectGraphTransformerForTesting(
- inMemoryGraphWithValues(
- ImmutableMap.of(
- file, FileStateValue.create(file, SyscallCache.NO_CACHE, /*tsgm=*/ null))));
+ skyframeExecutor
+ .injectable()
+ .inject(file, FileStateValue.create(file, SyscallCache.NO_CACHE, /*tsgm=*/ null));
skyframeExecutor.externalFilesHelper.getAndNoteFileType(file);
// Initial sync to establish the baseline DiffAwareness.View.
skyframeExecutor.handleDiffsForTesting(NullEventHandler.INSTANCE);
@@ -368,13 +359,14 @@
DirectoryListingStateValue.Key dirListingKey = DirectoryListingStateValue.key(dir);
initializeSkyframeExecutor(
/*doPackageLoadingChecks=*/ true, ImmutableList.of(nothingChangedDiffAwarenessFactory()));
- skyframeExecutor.memoizingEvaluator.injectGraphTransformerForTesting(
- inMemoryGraphWithValues(
+ skyframeExecutor
+ .injectable()
+ .inject(
ImmutableMap.of(
dir,
FileStateValue.create(dir, SyscallCache.NO_CACHE, /*tsgm=*/ null),
dirListingKey,
- value)));
+ value));
skyframeExecutor.externalFilesHelper.getAndNoteFileType(dir);
// Initial sync to establish the baseline DiffAwareness.View.
skyframeExecutor.handleDiffsForTesting(NullEventHandler.INSTANCE);
@@ -407,13 +399,14 @@
DirectoryListingStateValue.Key dirListingKey = DirectoryListingStateValue.key(dir);
initializeSkyframeExecutor(
/*doPackageLoadingChecks=*/ true, ImmutableList.of(nothingChangedDiffAwarenessFactory()));
- skyframeExecutor.memoizingEvaluator.injectGraphTransformerForTesting(
- inMemoryGraphWithValues(
+ skyframeExecutor
+ .injectable()
+ .inject(
ImmutableMap.of(
dir,
FileStateValue.create(dir, SyscallCache.NO_CACHE, /*tsgm=*/ null),
dirListingKey,
- value)));
+ value));
skyframeExecutor.externalFilesHelper.getAndNoteFileType(dir);
// Initial sync to establish the baseline DiffAwareness.View.
skyframeExecutor.handleDiffsForTesting(NullEventHandler.INSTANCE);
@@ -464,43 +457,6 @@
.getDiff(/*fromGraph=*/ null, ignored -> false, ignored -> false);
}
- private static GraphTransformerForTesting inMemoryGraphWithValues(
- ImmutableMap<SkyKey, SkyValue> values) {
-
- return new GraphTransformerForTesting() {
- @Override
- public InMemoryGraph transform(InMemoryGraph graph) {
- return new InMemoryGraphImpl(values.size()) {
- {
- nodeMap.putAll(Maps.transformValues(values, v -> createNodeEntry(v)));
- }
- };
- }
-
- @Override
- public QueryableGraph transform(QueryableGraph graph) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ProcessableGraph transform(ProcessableGraph graph) {
- throw new UnsupportedOperationException();
- }
-
- private InMemoryNodeEntry createNodeEntry(SkyValue value) {
- InMemoryNodeEntry nodeEntry = new InMemoryNodeEntry();
- nodeEntry.addReverseDepAndCheckIfDone(null);
- nodeEntry.markRebuilding();
- try {
- nodeEntry.setValue(value, ignored -> false, /*maxTransitiveSourceVersion=*/ null);
- } catch (InterruptedException e) {
- throw new RuntimeException();
- }
- return nodeEntry;
- }
- };
- }
-
@Test
public void testSetDeletedPackages() throws Exception {
ExtendedEventHandler eventHandler = NullEventHandler.INSTANCE;