diff options
author | 2018-03-09 02:01:18 -0800 | |
---|---|---|
committer | 2018-03-09 02:02:59 -0800 | |
commit | 9dac6736d811895a23b976d0af461cefd09afcd1 (patch) | |
tree | 26a0003792c93898bfbad51cb712ef14bd42374e /src/main/java/com/google/devtools | |
parent | 2ee6dd262bcf5fd890e24d5f185616b8ab259608 (diff) |
tests: fix flaky SkyframeAwareActionTest
Fix testCacheBypassingActionWithMtimeChangingInput
in SkyframeAwareActionTest by ensuring that enough
time elapses between file updates so their effects
are observable on the file's ctime.
Fixes https://github.com/bazelbuild/bazel/issues/4755
Closes #4787.
PiperOrigin-RevId: 188458542
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/util/io/TimestampGranularityMonitor.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/util/io/TimestampGranularityMonitor.java b/src/main/java/com/google/devtools/build/lib/util/io/TimestampGranularityMonitor.java index 12cb4897f9..82479b2078 100644 --- a/src/main/java/com/google/devtools/build/lib/util/io/TimestampGranularityMonitor.java +++ b/src/main/java/com/google/devtools/build/lib/util/io/TimestampGranularityMonitor.java @@ -127,11 +127,15 @@ public class TimestampGranularityMonitor { @ThreadSafe public void notifyDependenceOnFileTime(PathFragment path, long ctimeMillis) { if (!this.waitAMillisecond && ctimeMillis == this.commandStartTimeMillis) { - logger.info("Will have to wait for a millisecond on completion because of " + path); + if (path != null) { + logger.info("Will have to wait for a millisecond on completion because of " + path); + } this.waitAMillisecond = true; } if (!this.waitASecond && ctimeMillis == this.commandStartTimeMillisRounded) { - logger.info("Will have to wait for a second on completion because of " + path); + if (path != null) { + logger.info("Will have to wait for a second on completion because of " + path); + } this.waitASecond = true; } } @@ -195,6 +199,13 @@ public class TimestampGranularityMonitor { } } + /** Wait enough such that changes to a file with the given ctime will have observable effects. */ + public void waitForTimestampGranularity(long ctimeMillis, OutErr outErr) { + setCommandStartTime(); + notifyDependenceOnFileTime(null, ctimeMillis); + waitForTimestampGranularity(outErr); + } + /** * Rounds the specified time, in milliseconds, down to the nearest second, * and returns the result in milliseconds. |