Move TimestampGranularityMonitor to CommandEnvironment.
This is one of the last pieces of state in BlazeRuntime that isn't safe to
share across command invocations.
--
MOS_MIGRATED_REVID=117910631
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java
index 5f46eed..e9f4cf8 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java
@@ -23,7 +23,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.Runnables;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.actions.Artifact;
@@ -41,7 +40,6 @@
import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
import com.google.devtools.build.lib.skyframe.DirtinessCheckerUtils.BasicFilesystemDirtinessChecker;
import com.google.devtools.build.lib.testutil.TestRuleClassProvider;
-import com.google.devtools.build.lib.util.BlazeClock;
import com.google.devtools.build.lib.util.Preconditions;
import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
import com.google.devtools.build.lib.vfs.BatchStat;
@@ -94,7 +92,6 @@
private SequentialBuildDriver driver;
private MockFileSystem fs;
private Path pkgRoot;
- private TimestampGranularityMonitor tsgm;
@Before
public final void setUp() throws Exception {
@@ -105,11 +102,11 @@
FileSystemUtils.createDirectoryAndParents(pkgRoot);
FileSystemUtils.createEmptyFile(pkgRoot.getRelative("WORKSPACE"));
- tsgm = new TimestampGranularityMonitor(BlazeClock.instance());
AtomicReference<PathPackageLocator> pkgLocator = new AtomicReference<>(new PathPackageLocator(
fs.getPath("/output_base"), ImmutableList.of(pkgRoot)));
ExternalFilesHelper externalFilesHelper = new ExternalFilesHelper(pkgLocator, false);
- skyFunctions.put(SkyFunctions.FILE_STATE, new FileStateFunction(tsgm, externalFilesHelper));
+ skyFunctions.put(SkyFunctions.FILE_STATE, new FileStateFunction(
+ new AtomicReference<TimestampGranularityMonitor>(), externalFilesHelper));
skyFunctions.put(SkyFunctions.FILE, new FileFunction(pkgLocator));
skyFunctions.put(
SkyFunctions.FILE_SYMLINK_CYCLE_UNIQUENESS, new FileSymlinkCycleUniquenessFunction());
@@ -137,13 +134,13 @@
@Test
public void testEmpty() throws Exception {
- FilesystemValueChecker checker = new FilesystemValueChecker(tsgm, null);
+ FilesystemValueChecker checker = new FilesystemValueChecker(null, null);
assertEmptyDiff(getDirtyFilesystemKeys(evaluator, checker));
}
@Test
public void testSimple() throws Exception {
- FilesystemValueChecker checker = new FilesystemValueChecker(tsgm, null);
+ FilesystemValueChecker checker = new FilesystemValueChecker(null, null);
Path path = fs.getPath("/foo");
FileSystemUtils.createEmptyFile(path);
@@ -187,7 +184,7 @@
*/
@Test
public void testDirtySymlink() throws Exception {
- FilesystemValueChecker checker = new FilesystemValueChecker(tsgm, null);
+ FilesystemValueChecker checker = new FilesystemValueChecker(null, null);
Path path = fs.getPath("/foo");
FileSystemUtils.writeContentAsLatin1(path, "foo contents");
@@ -259,7 +256,7 @@
@Test
public void testExplicitFiles() throws Exception {
- FilesystemValueChecker checker = new FilesystemValueChecker(tsgm, null);
+ FilesystemValueChecker checker = new FilesystemValueChecker(null, null);
Path path1 = fs.getPath("/foo1");
Path path2 = fs.getPath("/foo2");
@@ -312,7 +309,7 @@
assertTrue(result.hasError());
fs.readlinkThrowsIoException = false;
- FilesystemValueChecker checker = new FilesystemValueChecker(tsgm, null);
+ FilesystemValueChecker checker = new FilesystemValueChecker(null, null);
Diff diff = getDirtyFilesystemKeys(evaluator, checker);
assertThat(diff.changedKeysWithoutNewValues()).isEmpty();
assertThat(diff.changedKeysWithNewValues()).isEmpty();
@@ -336,7 +333,7 @@
NullEventHandler.INSTANCE);
assertTrue(result.hasError());
- FilesystemValueChecker checker = new FilesystemValueChecker(tsgm, null);
+ FilesystemValueChecker checker = new FilesystemValueChecker(null, null);
Diff diff = getDirtyFilesystemKeys(evaluator, checker);
assertThat(diff.changedKeysWithoutNewValues()).isEmpty();
assertThat(diff.changedKeysWithNewValues()).isEmpty();
@@ -363,28 +360,27 @@
driver
.evaluate(ImmutableList.<SkyKey>of(), false, 1, NullEventHandler.INSTANCE)
.hasError());
- assertThat(new FilesystemValueChecker(tsgm, null).getDirtyActionValues(evaluator.getValues(),
+ assertThat(new FilesystemValueChecker(null, null).getDirtyActionValues(evaluator.getValues(),
batchStatter, ModifiedFileSet.EVERYTHING_MODIFIED)).isEmpty();
FileSystemUtils.writeContentAsLatin1(out1.getPath(), "goodbye");
- assertEquals(
- ActionExecutionValue.key(action1),
- Iterables.getOnlyElement(
- new FilesystemValueChecker(tsgm, null).getDirtyActionValues(evaluator.getValues(),
- batchStatter, ModifiedFileSet.EVERYTHING_MODIFIED)));
- assertEquals(
- ActionExecutionValue.key(action1),
- Iterables.getOnlyElement(
- new FilesystemValueChecker(tsgm, null).getDirtyActionValues(evaluator.getValues(),
- batchStatter,
- new ModifiedFileSet.Builder().modify(out1.getExecPath()).build())));
assertThat(
- new FilesystemValueChecker(tsgm, null).getDirtyActionValues(evaluator.getValues(),
+ new FilesystemValueChecker(null, null).getDirtyActionValues(
+ evaluator.getValues(), batchStatter, ModifiedFileSet.EVERYTHING_MODIFIED))
+ .containsExactly(ActionExecutionValue.key(action1));
+ assertThat(
+ new FilesystemValueChecker(null, null).getDirtyActionValues(
+ evaluator.getValues(),
+ batchStatter,
+ new ModifiedFileSet.Builder().modify(out1.getExecPath()).build()))
+ .containsExactly(ActionExecutionValue.key(action1));
+ assertThat(
+ new FilesystemValueChecker(null, null).getDirtyActionValues(evaluator.getValues(),
batchStatter,
new ModifiedFileSet.Builder().modify(
out1.getExecPath().getParentDirectory()).build())).isEmpty();
assertThat(
- new FilesystemValueChecker(tsgm, null).getDirtyActionValues(evaluator.getValues(),
+ new FilesystemValueChecker(null, null).getDirtyActionValues(evaluator.getValues(),
batchStatter, ModifiedFileSet.NOTHING_MODIFIED)).isEmpty();
}
@@ -439,25 +435,25 @@
driver
.evaluate(ImmutableList.<SkyKey>of(), false, 1, NullEventHandler.INSTANCE)
.hasError());
- assertThat(new FilesystemValueChecker(tsgm, null).getDirtyActionValues(evaluator.getValues(),
+ assertThat(new FilesystemValueChecker(null, null).getDirtyActionValues(evaluator.getValues(),
batchStatter, ModifiedFileSet.EVERYTHING_MODIFIED)).isEmpty();
// Touching the TreeArtifact directory should have no effect
FileSystemUtils.touchFile(out1.getPath());
assertThat(
- new FilesystemValueChecker(tsgm, null).getDirtyActionValues(evaluator.getValues(),
+ new FilesystemValueChecker(null, null).getDirtyActionValues(evaluator.getValues(),
batchStatter, ModifiedFileSet.EVERYTHING_MODIFIED)).isEmpty();
// Neither should touching a subdirectory.
FileSystemUtils.touchFile(out2.getPath().getChild("subdir"));
assertThat(
- new FilesystemValueChecker(tsgm, null).getDirtyActionValues(evaluator.getValues(),
+ new FilesystemValueChecker(null, null).getDirtyActionValues(evaluator.getValues(),
batchStatter, ModifiedFileSet.EVERYTHING_MODIFIED)).isEmpty();
/* **** Tests for directories **** */
// Removing a directory (even if empty) should have an effect
outEmpty.getPath().delete();
- assertThat(new FilesystemValueChecker(tsgm, null).getDirtyActionValues(evaluator.getValues(),
+ assertThat(new FilesystemValueChecker(null, null).getDirtyActionValues(evaluator.getValues(),
batchStatter,
new ModifiedFileSet.Builder().modify(outEmpty.getExecPath()).build()))
.containsExactly(ActionExecutionValue.key(actionEmpty));
@@ -465,7 +461,7 @@
Path dummyEmptyDir = fs.getPath("/bin").getRelative("symlink");
FileSystemUtils.createDirectoryAndParents(dummyEmptyDir);
FileSystemUtils.ensureSymbolicLink(outEmpty.getPath(), dummyEmptyDir);
- assertThat(new FilesystemValueChecker(tsgm, null).getDirtyActionValues(evaluator.getValues(),
+ assertThat(new FilesystemValueChecker(null, null).getDirtyActionValues(evaluator.getValues(),
batchStatter,
new ModifiedFileSet.Builder().modify(outEmpty.getExecPath()).build()))
.containsExactly(ActionExecutionValue.key(actionEmpty));
@@ -480,12 +476,12 @@
// Test that file contents matter. This is covered by existing tests already,
// so it's just a sanity check.
FileSystemUtils.writeContentAsLatin1(file11.getPath(), "goodbye");
- assertEquals(
- ActionExecutionValue.key(action1),
- Iterables.getOnlyElement(
- new FilesystemValueChecker(tsgm, null).getDirtyActionValues(evaluator.getValues(),
- batchStatter,
- new ModifiedFileSet.Builder().modify(file11.getExecPath()).build())));
+ assertThat(
+ new FilesystemValueChecker(null, null).getDirtyActionValues(
+ evaluator.getValues(),
+ batchStatter,
+ new ModifiedFileSet.Builder().modify(file11.getExecPath()).build()))
+ .containsExactly(ActionExecutionValue.key(action1));
// Test that directory contents (and nested contents) matter
ArtifactFile out1new = artifactFile(out1, "julius/caesar");
@@ -497,12 +493,12 @@
// so does removing
file21.getPath().delete();
// now, let's test our changes are actually visible
- assertThat(new FilesystemValueChecker(tsgm, null).getDirtyActionValues(evaluator.getValues(),
+ assertThat(new FilesystemValueChecker(null, null).getDirtyActionValues(evaluator.getValues(),
batchStatter, ModifiedFileSet.EVERYTHING_MODIFIED))
.containsExactly(ActionExecutionValue.key(action1), ActionExecutionValue.key(action2),
ActionExecutionValue.key(actionEmpty));
assertThat(
- new FilesystemValueChecker(tsgm, null).getDirtyActionValues(evaluator.getValues(),
+ new FilesystemValueChecker(null, null).getDirtyActionValues(evaluator.getValues(),
batchStatter,
new ModifiedFileSet.Builder()
.modify(file21.getExecPath())
@@ -514,7 +510,7 @@
// We add a test for NOTHING_MODIFIED, because FileSystemValueChecker doesn't
// pay attention to file sets for TreeArtifact directory listings.
assertThat(
- new FilesystemValueChecker(tsgm, null).getDirtyActionValues(evaluator.getValues(),
+ new FilesystemValueChecker(null, null).getDirtyActionValues(evaluator.getValues(),
batchStatter, ModifiedFileSet.NOTHING_MODIFIED)).isEmpty();
}
@@ -628,7 +624,7 @@
FileStatusWithDigest stat =
forceDigest ? statWithDigest(path, path.statIfFound(Symlinks.NOFOLLOW)) : null;
artifactData.put(output,
- ActionMetadataHandler.fileValueFromArtifactFile(output, stat, tsgm));
+ ActionMetadataHandler.fileValueFromArtifactFile(output, stat, null));
} catch (IOException e) {
throw new IllegalStateException(e);
}
@@ -662,7 +658,7 @@
dirDatum = new HashMap<>();
directoryData.put(output.getParent(), dirDatum);
}
- FileValue fileValue = ActionMetadataHandler.fileValueFromArtifactFile(output, null, tsgm);
+ FileValue fileValue = ActionMetadataHandler.fileValueFromArtifactFile(output, null, null);
// Always test with digests. TreeArtifact checking behavior doesn't depend on the
// presence/absence of digests. FileValue checking w/o digests is already tested.
byte[] digest = DigestUtils.getDigestOrFail(output.getPath(), 1);
@@ -695,7 +691,7 @@
ImmutableList.of(FileValue.key(RootedPath.toRootedPath(pkgRoot, new PathFragment("foo"))));
driver.evaluate(
values, false, SkyframeExecutor.DEFAULT_THREAD_COUNT, NullEventHandler.INSTANCE);
- FilesystemValueChecker checker = new FilesystemValueChecker(tsgm, null);
+ FilesystemValueChecker checker = new FilesystemValueChecker(null, null);
assertEmptyDiff(getDirtyFilesystemKeys(evaluator, checker));