Skip to content

Commit 31ccf4a

Browse files
author
David Ungar
committed
add testUseFingerprintsPingPong2 test
1 parent 923ae3a commit 31ccf4a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Tests/SwiftDriverTests/ModuleDependencyGraphTests.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,36 @@ class ModuleDependencyGraphTests: XCTestCase {
810810
}
811811
}
812812

813+
func testUseFingerprintsPingPong2() {
814+
let graph = ModuleDependencyGraph(mock: de)
815+
// Because of the cross-type dependency, A->B,
816+
// when A changes, only B is dirtied in 1.
817+
818+
graph.simulateLoad(0, [.nominal: ["A@1", "C@3"]])
819+
graph.simulateLoad(1, [.nominal: ["B", "A->B"]])
820+
graph.simulateLoad(2, [.nominal: ["D", "C->D"]])
821+
graph.ensureIsSerializable()
822+
823+
do {
824+
let swiftDeps = graph.simulateReload(0, [.nominal: ["A@2"]]).sorted()
825+
XCTAssertEqual(swiftDeps, [0, 1, 2])
826+
graph.ensureIsSerializable()
827+
}
828+
829+
do {
830+
// In the real world, we would have a graph with untraced nodes from the
831+
// priors, remembering the fingerprints from before.
832+
graph.setUntraced()
833+
// When the driver integrates a node that preexists but has a new fingerprint
834+
// it must change that fingerprint in the node in the graph.
835+
// If it does not, and subsequently integrates the old fingerprint,
836+
// the change will be missed.
837+
let swiftDeps = graph.simulateReload(0, [.nominal: ["A@1"]]).sorted()
838+
XCTAssertEqual(swiftDeps, [0, 1])
839+
graph.ensureIsSerializable()
840+
}
841+
}
842+
813843
func testCrossTypeDependencyBaseline() {
814844
let graph = ModuleDependencyGraph(mock: de)
815845
graph.simulateLoad(0, [.nominal: ["A"]])

0 commit comments

Comments
 (0)