Skip to content

Commit 32d4c18

Browse files
author
David Ungar
authored
Merge pull request #761 from davidungar/relax-time-2
[Incremental] Relax the priors currency test by what ought to be enough to get through CI
2 parents b4b4814 + 51d3c37 commit 32d4c18

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

Sources/SwiftDriver/IncrementalCompilation/IncrementalDependencyAndInputSetup.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,12 @@ extension IncrementalCompilationState.IncrementalDependencyAndInputSetup {
223223
warning: "Will not do cross-module incremental builds, wrong version of priors; expected \(expected) but read \(read) at '\(dependencyGraphPath)'")
224224
graphIfPresent = nil
225225
}
226-
catch let ModuleDependencyGraph.ReadError.timeTravellingPriors(priorsModTime: priorsModTime, buildRecordModTime: buildRecordModTime) {
226+
catch let ModuleDependencyGraph.ReadError.timeTravellingPriors(priorsModTime: priorsModTime,
227+
buildRecordModTime: buildRecordModTime,
228+
priorsTimeIntervalSinceStart: priorsTimeIntervalSinceStart) {
227229
diagnosticEngine.emit(
228230
warning: "Will not do cross-module incremental builds, priors saved at \(priorsModTime)), " +
229-
"but the previous build started at \(buildRecordModTime) [delta: \(priorsModTime.timeIntervalSince(buildRecordModTime))], at '\(dependencyGraphPath)'")
231+
"but the previous build started at \(buildRecordModTime) [priorsTimeIntervalSinceStart: \(priorsTimeIntervalSinceStart)], at '\(dependencyGraphPath)'")
230232
graphIfPresent = nil
231233
}
232234
catch {

Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraph.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,9 @@ extension ModuleDependencyGraph {
587587
case bogusNameOrContext
588588
case unknownKind
589589
case unknownDependencySourceExtension
590-
case timeTravellingPriors(priorsModTime: Date, buildRecordModTime: Date)
590+
case timeTravellingPriors(priorsModTime: Date,
591+
buildRecordModTime: Date,
592+
priorsTimeIntervalSinceStart: TimeInterval)
591593
}
592594

593595
/// Attempts to read a serialized dependency graph from the given path.
@@ -815,8 +817,12 @@ extension ModuleDependencyGraph {
815817
else {
816818
return
817819
}
818-
guard info.buildStartTime <= priorsModTime else {
819-
throw ReadError.timeTravellingPriors(priorsModTime: priorsModTime, buildRecordModTime: buildRecordModTime)
820+
let priorsTimeIntervalSinceStart = priorsModTime.timeIntervalSince(buildRecordModTime)
821+
// CI seems to emit identical times; I'm not sure why. So compare to -1.
822+
guard -1.0 < priorsTimeIntervalSinceStart else {
823+
throw ReadError.timeTravellingPriors(priorsModTime: priorsModTime,
824+
buildRecordModTime: buildRecordModTime,
825+
priorsTimeIntervalSinceStart: priorsTimeIntervalSinceStart)
820826
}
821827
}
822828
}

Tests/SwiftDriverTests/IncrementalCompilationTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ extension IncrementalCompilationTests {
302302
/// Ensure that a saved prior module dependency graph is rejected if not from the previous build
303303
func testObsoletePriors() throws {
304304
#if !os(Linux)
305-
let before = Date()
305+
let before = Date().advanced(by: -2.0)
306306
let driver = try buildInitialState(checkDiagnostics: true)
307307
let path = try XCTUnwrap(driver.buildRecordInfo?.dependencyGraphPath)
308308
try setModTime(of: path, to: before) // Make priors too old

0 commit comments

Comments
 (0)