Root: Rather than use @AutoCodec, use a handwritten ObjectCodec that allows us to optimize for the common case of a very popular Root.
Our serialization scheme is: We are magically given a likely-to-be-popular Root instance `p` and then whenever we would serialize a Root `r`, we canonicalize `r` to `p` if they are `r.equals(p)`.
The Root#fromPath and Root#absoluteRoot methods permit creation of Root instances that are equivalent, and these methods are unfortunately very widely used in the codebase. Therefore, a serialization scheme that tries to make use of Object identity is brittle in the face of future changes.
While I'm here, delete Root#getFingerprint. An earlier commit (https://github.com/bazelbuild/bazel/commit/ce6ad29c88084fb327856149a39e2771e544cfa5) made this dead code.
RELNOTES: None
PiperOrigin-RevId: 300826154
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FileValueTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FileValueTest.java
index fad42f0..56e4acc 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/FileValueTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/FileValueTest.java
@@ -19,7 +19,6 @@
import com.google.devtools.build.lib.actions.FileValue;
import com.google.devtools.build.lib.skyframe.serialization.testutils.FsUtils;
import com.google.devtools.build.lib.skyframe.serialization.testutils.SerializationTester;
-import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.PathFragment;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,28 +29,29 @@
public class FileValueTest {
@Test
public void testCodec() throws Exception {
- new SerializationTester(
+ SerializationTester serializationTester =
+ new SerializationTester(
// Assume we have adequate coverage for FileStateValue serialization.
new FileValue.RegularFileValue(
- FsUtils.TEST_ROOT, FileStateValue.NONEXISTENT_FILE_STATE_NODE),
+ FsUtils.TEST_ROOTED_PATH, FileStateValue.NONEXISTENT_FILE_STATE_NODE),
new FileValue.DifferentRealPathFileValueWithStoredChain(
- FsUtils.TEST_ROOT,
+ FsUtils.TEST_ROOTED_PATH,
FileStateValue.DIRECTORY_FILE_STATE_NODE,
- ImmutableList.of(FsUtils.TEST_ROOT)),
+ ImmutableList.of(FsUtils.TEST_ROOTED_PATH)),
new FileValue.DifferentRealPathFileValueWithoutStoredChain(
- FsUtils.TEST_ROOT, FileStateValue.DIRECTORY_FILE_STATE_NODE),
+ FsUtils.TEST_ROOTED_PATH, FileStateValue.DIRECTORY_FILE_STATE_NODE),
new FileValue.SymlinkFileValueWithStoredChain(
- FsUtils.TEST_ROOT,
+ FsUtils.TEST_ROOTED_PATH,
new FileStateValue.RegularFileStateValue(
/*size=*/ 100, /*digest=*/ new byte[] {1, 2, 3, 4, 5}, /*contentsProxy=*/ null),
- ImmutableList.of(FsUtils.TEST_ROOT),
+ ImmutableList.of(FsUtils.TEST_ROOTED_PATH),
PathFragment.create("somewhere/else")),
new FileValue.SymlinkFileValueWithoutStoredChain(
- FsUtils.TEST_ROOT,
+ FsUtils.TEST_ROOTED_PATH,
new FileStateValue.RegularFileStateValue(
/*size=*/ 100, /*digest=*/ new byte[] {1, 2, 3, 4, 5}, /*contentsProxy=*/ null),
- PathFragment.create("somewhere/else")))
- .addDependency(FileSystem.class, FsUtils.TEST_FILESYSTEM)
- .runTests();
+ PathFragment.create("somewhere/else")));
+ FsUtils.addDependencies(serializationTester);
+ serializationTester.runTests();
}
}