@@ -875,6 +875,26 @@ final class SwiftDriverTests: XCTestCase {
875875 XCTAssertFalse ( cmd. contains ( . flag( " -shared " ) ) )
876876 }
877877
878+ do {
879+ // Object file inputs
880+ var driver = try Driver ( args: commonArgs + [ " baz.o " , " -emit-library " , " -target " , " x86_64-apple-macosx10.15 " ] , env: env)
881+ let plannedJobs = try driver. planBuild ( )
882+
883+ XCTAssertEqual ( 3 , plannedJobs. count)
884+ XCTAssertFalse ( plannedJobs. contains { $0. kind == . autolinkExtract } )
885+
886+ let linkJob = plannedJobs [ 2 ]
887+ XCTAssertEqual ( linkJob. kind, . link)
888+
889+ let cmd = linkJob. commandLine
890+ XCTAssertTrue ( linkJob. inputs. contains ( . init( file: . temporary( . init( " foo.o " ) ) , type: . object) ) )
891+ XCTAssertTrue ( linkJob. inputs. contains ( . init( file: . temporary( . init( " bar.o " ) ) , type: . object) ) )
892+ XCTAssertTrue ( linkJob. inputs. contains ( . init( file: . relative( . init( " baz.o " ) ) , type: . object) ) )
893+ XCTAssertTrue ( cmd. contains ( . path( . temporary( . init( " foo.o " ) ) ) ) )
894+ XCTAssertTrue ( cmd. contains ( . path( . temporary( . init( " bar.o " ) ) ) ) )
895+ XCTAssertTrue ( cmd. contains ( . path( . relative( . init( " baz.o " ) ) ) ) )
896+ }
897+
878898 do {
879899 // static linking
880900 var driver = try Driver ( args: commonArgs + [ " -emit-library " , " -static " , " -L " , " /tmp " , " -Xlinker " , " -w " , " -target " , " x86_64-apple-macosx10.15 " ] , env: env)
@@ -2389,13 +2409,26 @@ final class SwiftDriverTests: XCTestCase {
23892409 do {
23902410 var driver = try Driver ( args: [ " swiftc " , " -typecheck " ,
23912411 " -emit-loaded-module-trace " ,
2392- " foo.swift, bar.swift " , " baz.swift " ] )
2412+ " foo.swift " , " bar.swift " , " baz.swift " ] )
2413+ let plannedJobs = try driver. planBuild ( )
2414+ let tracedJobs = plannedJobs. filter {
2415+ $0. commandLine. contains ( subsequence: [ " -emit-loaded-module-trace-path " ,
2416+ . path( . relative( . init( " main.trace.json " ) ) ) ] )
2417+ }
2418+ XCTAssertEqual ( tracedJobs. count, 1 )
2419+ }
2420+ do {
2421+ // Make sure the trace is associated with the first frontend job as
2422+ // opposed to the first input.
2423+ var driver = try Driver ( args: [ " swiftc " , " -emit-loaded-module-trace " ,
2424+ " foo.o " , " bar.swift " , " baz.o " ] )
23932425 let plannedJobs = try driver. planBuild ( )
23942426 let tracedJobs = plannedJobs. filter {
23952427 $0. commandLine. contains ( subsequence: [ " -emit-loaded-module-trace-path " ,
23962428 . path( . relative( . init( " main.trace.json " ) ) ) ] )
23972429 }
23982430 XCTAssertEqual ( tracedJobs. count, 1 )
2431+ XCTAssertTrue ( tracedJobs [ 0 ] . inputs. contains ( . init( file: . relative( . init( " bar.swift " ) ) , type: . swift) ) )
23992432 }
24002433 do {
24012434 var env = ProcessEnv . vars
0 commit comments