1212//
1313//===----------------------------------------------------------------------===//
1414
15- import Testing
1615@_spi ( Testing) import SwiftDriver
1716import TSCBasic
17+ import Testing
1818
1919@Suite struct DependencyGraphSerializationTests : ModuleDependencyGraphMocker {
2020 static let maxIndex = 12
@@ -35,23 +35,27 @@ import TSCBasic
3535 to: mockPath,
3636 on: fs,
3737 buildRecord: graph. buildRecord,
38- mockSerializedGraphVersion: alteredVersion)
38+ mockSerializedGraphVersion: alteredVersion
39+ )
3940 }
4041
4142 do {
4243 let outputFileMap = OutputFileMap . mock ( maxIndex: Self . maxIndex)
43- let info = IncrementalCompilationState . IncrementalDependencyAndInputSetup. mock ( outputFileMap: outputFileMap, fileSystem: fs)
44+ let info = IncrementalCompilationState . IncrementalDependencyAndInputSetup. mock (
45+ outputFileMap: outputFileMap,
46+ fileSystem: fs
47+ )
4448 try info. blockingConcurrentAccessOrMutation {
45- _ = try ModuleDependencyGraph . read ( from: mockPath,
46- info: info)
49+ _ = try ModuleDependencyGraph . read (
50+ from: mockPath,
51+ info: info
52+ )
4753 Issue . record ( " Should have thrown an exception " )
4854 }
49- }
50- catch let ModuleDependencyGraph . ReadError . mismatchedSerializedGraphVersion( expected, read) {
55+ } catch let ModuleDependencyGraph . ReadError . mismatchedSerializedGraphVersion( expected, read) {
5156 #expect( expected == currentVersion)
5257 #expect( read == alteredVersion)
53- }
54- catch {
58+ } catch {
5559 Issue . record ( " Threw an unexpected exception: \( error. localizedDescription) " )
5660 }
5761 }
@@ -63,11 +67,16 @@ import TSCBasic
6367
6468 try originalGraph. blockingConcurrentMutation {
6569 try originalGraph. write (
66- to: mockPath, on: fs,
67- buildRecord: originalGraph. buildRecord)
70+ to: mockPath,
71+ on: fs,
72+ buildRecord: originalGraph. buildRecord
73+ )
6874 }
6975
70- let info = IncrementalCompilationState . IncrementalDependencyAndInputSetup. mock ( outputFileMap: outputFileMap, fileSystem: fs)
76+ let info = IncrementalCompilationState . IncrementalDependencyAndInputSetup. mock (
77+ outputFileMap: outputFileMap,
78+ fileSystem: fs
79+ )
7180 let deserializedGraph = try info. blockingConcurrentAccessOrMutation {
7281 try #require( try ModuleDependencyGraph . read ( from: mockPath, info: info) )
7382 }
@@ -78,9 +87,11 @@ import TSCBasic
7887 graph. nodeFinder. forEachNode {
7988 nodes. insert ( $0. description ( in: graph) )
8089 }
81- let uses : [ String : Set < String > ] = graph. nodeFinder. usesByDef. reduce ( into: Dictionary ( ) ) { usesByDef, keyAndNodes in
90+ let uses : [ String : Set < String > ] = graph. nodeFinder. usesByDef. reduce ( into: Dictionary ( ) ) {
91+ usesByDef,
92+ keyAndNodes in
8293 usesByDef [ keyAndNodes. 0 . description ( in: graph) ] =
83- keyAndNodes. 1 . reduce ( into: Set ( ) ) { $0. insert ( $1. description ( in: graph) ) }
94+ keyAndNodes. 1 . reduce ( into: Set ( ) ) { $0. insert ( $1. description ( in: graph) ) }
8495 }
8596 let feds : Set < String > = graph. fingerprintedExternalDependencies. reduce ( into: Set ( ) ) {
8697 $0. insert ( $1. description ( in: graph) )
@@ -89,7 +100,10 @@ import TSCBasic
89100 }
90101 #expect( descsToCompare [ 0 ] . nodes == descsToCompare [ 1 ] . nodes, " Round trip node difference! " )
91102 #expect( descsToCompare [ 0 ] . uses == descsToCompare [ 1 ] . uses, " Round trip def-uses difference! " )
92- #expect( descsToCompare [ 0 ] . feds == descsToCompare [ 1 ] . feds, " Round trip fingerprinted external dependency difference! " )
103+ #expect(
104+ descsToCompare [ 0 ] . feds == descsToCompare [ 1 ] . feds,
105+ " Round trip fingerprinted external dependency difference! "
106+ )
93107 }
94108
95109 @Test func roundTripFixtures( ) throws {
@@ -114,10 +128,13 @@ import TSCBasic
114128 . load( index: 6 , nodes: [ . member: [ " m,mm " , " n,nn " ] ] ) ,
115129 . load( index: 7 , nodes: [ . member: [ " o,oo-> " , " p,pp-> " ] ] ) ,
116130 . load( index: 8 , nodes: [ . externalDepend: [ " /foo-> " , " /bar-> " ] ] ) ,
117- . load( index: 9 , nodes: [
118- . nominal: [ " a " , " b " , " c-> " , " d-> " ] ,
119- . topLevel: [ " b " , " c " , " d-> " , " a-> " ]
120- ] )
131+ . load(
132+ index: 9 ,
133+ nodes: [
134+ . nominal: [ " a " , " b " , " c-> " , " d-> " ] ,
135+ . topLevel: [ " b " , " c " , " d-> " , " a-> " ] ,
136+ ]
137+ ) ,
121138 ] ) ,
122139 GraphFixture ( commands: [
123140 . load( index: 0 , nodes: [ . topLevel: [ " a0 " , " a-> " ] ] ) ,
@@ -173,7 +190,7 @@ import TSCBasic
173190 ] ) ,
174191 GraphFixture ( commands: [
175192 . load( index: 0 , nodes: [ . member: [ " a,aa " , " b,bb " , " c,cc " ] ] ) ,
176- . load( index: 1 , nodes: [ . member: [ " x,xx-> " , " b,bb-> " , " z,zz-> " ] ] )
193+ . load( index: 1 , nodes: [ . member: [ " x,xx-> " , " b,bb-> " , " z,zz-> " ] ] ) ,
177194 ] ) ,
178195 GraphFixture ( commands: [
179196 . load( index: 0 , nodes: [ . nominal: [ " a " , " b " , " c " ] ] ) ,
@@ -217,7 +234,7 @@ import TSCBasic
217234 . load( index: 0 , nodes: [ . nominal: [ " a " ] ] ) ,
218235 . load( index: 1 , nodes: [ . nominal: [ " a-> " ] ] ) ,
219236 . load( index: 2 , nodes: [ . nominal: [ " b-> " ] ] ) ,
220- . reload( index: 0 , nodes: [ . nominal: [ " a " , " b " ] ] )
237+ . reload( index: 0 , nodes: [ . nominal: [ " a " , " b " ] ] ) ,
221238 ] ) ,
222239 GraphFixture ( commands: [
223240 . reload( index: 1 , nodes: [ . nominal: [ " b " , " a-> " ] ] )
@@ -227,7 +244,7 @@ import TSCBasic
227244 . load( index: 1 , nodes: [ . nominal: [ " B1 " , " A1-> " ] ] ) ,
228245 . load( index: 2 , nodes: [ . nominal: [ " C1 " , " A2-> " ] ] ) ,
229246 . load( index: 3 , nodes: [ . nominal: [ " D1 " ] ] ) ,
230- . reload( index: 0 , nodes: [ . nominal: [ " A1 " , " A2 " ] ] , fingerprint: " changed " )
247+ . reload( index: 0 , nodes: [ . nominal: [ " A1 " , " A2 " ] ] , fingerprint: " changed " ) ,
231248 ] ) ,
232249 GraphFixture ( commands: [
233250 . load( index: 0 , nodes: [ . nominal: [ " A " ] ] ) ,
@@ -258,7 +275,7 @@ import TSCBasic
258275 . load( index: 4 , nodes: [ . nominal: [ " B2 " , " C2 " , " A2->B2 " ] ] ) ,
259276 . load( index: 5 , nodes: [ . nominal: [ " B2-> " ] ] ) ,
260277 . load( index: 6 , nodes: [ . nominal: [ " C2-> " ] ] ) ,
261- . reload( index: 0 , nodes: [ . nominal: [ " A1@11 " , " A2@2 " ] ] )
278+ . reload( index: 0 , nodes: [ . nominal: [ " A1@11 " , " A2@2 " ] ] ) ,
262279 ] ) ,
263280 GraphFixture ( commands: [
264281 . load( index: 0 , nodes: [ . externalDepend: [ " /foo-> " , " /bar-> " ] ] , fingerprint: " ABCDEFG " ) ,
@@ -270,9 +287,9 @@ import TSCBasic
270287 let graph = Self . mockGraphCreator. mockUpAGraph ( )
271288 for loadCommand in fixture. commands {
272289 switch loadCommand {
273- case . load( index : let index, nodes : let nodes, fingerprint : let fingerprint) :
290+ case . load( let index, let nodes, let fingerprint) :
274291 graph. simulateLoad ( index, nodes, fingerprint)
275- case . reload( index : let index, nodes : let nodes, fingerprint : let fingerprint) :
292+ case . reload( let index, let nodes, let fingerprint) :
276293 _ = graph. simulateReload ( index, nodes, fingerprint)
277294 }
278295 }
0 commit comments