@@ -190,17 +190,18 @@ final class NonincrementalCompilationTests: XCTestCase {
190
190
191
191
XCTAssertEqual ( try ! buildRecord. inputInfos [ VirtualPath ( path: file2 ) ] !. status,
192
192
. needsCascadingBuild)
193
- XCTAssert ( try ! isCloseEnough ( buildRecord. inputInfos [ VirtualPath ( path: file2 ) ] !
194
- . previousModTime. legacyDriverSecsAndNanos,
195
- [ 1570318778 , 0 ] ) )
196
- XCTAssertEqual ( try ! buildRecord. inputInfos [ VirtualPath ( path: gazorp) ] !. status,
193
+ XCTAssert ( try ! isCloseEnough (
194
+ XCTUnwrap ( buildRecord. inputInfos [ VirtualPath ( path: file2 ) ] )
195
+ . previousModTime. legacyDriverSecsAndNanos,
196
+ [ 1570318778 , 0 ] ) )
197
+ XCTAssertEqual ( try ! XCTUnwrap ( buildRecord. inputInfos [ VirtualPath ( path: gazorp) ] ) . status,
197
198
. needsNonCascadingBuild)
198
- XCTAssertEqual ( try ! buildRecord. inputInfos [ VirtualPath ( path: gazorp) ] !
199
+ XCTAssertEqual ( try ! XCTUnwrap ( buildRecord. inputInfos [ VirtualPath ( path: gazorp) ] )
199
200
. previousModTime. legacyDriverSecsAndNanos,
200
201
[ 0 , 0 ] )
201
- XCTAssertEqual ( try ! buildRecord. inputInfos [ VirtualPath ( path: main ) ] ! . status,
202
+ XCTAssertEqual ( try ! XCTUnwrap ( buildRecord. inputInfos [ VirtualPath ( path: main ) ] ) . status,
202
203
. upToDate)
203
- XCTAssert ( try ! isCloseEnough ( buildRecord. inputInfos [ VirtualPath ( path: main ) ] !
204
+ XCTAssert ( try ! isCloseEnough ( XCTUnwrap ( buildRecord. inputInfos [ VirtualPath ( path: main ) ] )
204
205
. previousModTime. legacyDriverSecsAndNanos,
205
206
[ 1570083660 , 0 ] ) )
206
207
@@ -488,13 +489,13 @@ final class IncrementalCompilationTests: XCTestCase {
488
489
489
490
func touch( _ name: String ) {
490
491
print ( " *** touching \( name) *** " , to: & stderrStream) ; stderrStream. flush ( )
491
- let ( path, contents) = inputPathsAndContents. filter { $0. 0 . pathString. contains ( name) } . first!
492
+ let ( path, contents) = try ! XCTUnwrap ( inputPathsAndContents. filter { $0. 0 . pathString. contains ( name) } . first)
492
493
try ! localFileSystem. writeFileContents ( path) { $0 <<< contents }
493
494
}
494
495
495
496
private func replace( contentsOf name: String , with replacement: String ) {
496
497
print ( " *** replacing \( name) *** " , to: & stderrStream) ; stderrStream. flush ( )
497
- let path = inputPathsAndContents. filter { $0. 0 . pathString. contains ( " / " + name + " .swift " ) } . first! . 0
498
+ let path = try ! XCTUnwrap ( inputPathsAndContents. filter { $0. 0 . pathString. contains ( " / " + name + " .swift " ) } . first) . 0
498
499
let previousContents = try ! localFileSystem. readFileContents ( path) . cString
499
500
try ! localFileSystem. writeFileContents ( path) { $0 <<< replacement }
500
501
let newContents = try ! localFileSystem. readFileContents ( path) . cString
@@ -545,6 +546,31 @@ final class IncrementalCompilationTests: XCTestCase {
545
546
print ( " " , to: & stderrStream) ; stderrStream. flush ( )
546
547
}
547
548
549
+ /// Ensure that autolink output file goes with .o directory, to not prevent incremental omission of
550
+ /// autolink job.
551
+ /// Much of the code below is taking from testLinking(), but uses the output file map code here.
552
+ func testAutolinkOutputPath( ) {
553
+ var env = ProcessEnv . vars
554
+ env [ " SWIFT_DRIVER_TESTS_ENABLE_EXEC_PATH_FALLBACK " ] = " 1 "
555
+ env [ " SWIFT_DRIVER_SWIFT_AUTOLINK_EXTRACT_EXEC " ] = " /garbage/swift-autolink-extract "
556
+ env [ " SWIFT_DRIVER_DSYMUTIL_EXEC " ] = " /garbage/dsymutil "
557
+
558
+ var driver = try ! Driver (
559
+ args: args
560
+ + [ " -emit-library " , " -target " , " x86_64-unknown-linux " ] ,
561
+ env: env)
562
+ let plannedJobs = try ! driver. planBuild ( )
563
+ let autolinkExtractJob = try ! XCTUnwrap (
564
+ plannedJobs
565
+ . filter { $0. kind == . autolinkExtract }
566
+ . first)
567
+ let autoOuts = autolinkExtractJob. outputs. filter { $0. type == . autolink}
568
+ XCTAssertEqual ( autoOuts. count, 1 )
569
+ let autoOut = autoOuts [ 0 ]
570
+ let expected = AbsolutePath ( derivedDataPath, " \( module) .autolink " )
571
+ XCTAssertEqual ( autoOut. file. absolutePath, expected)
572
+ }
573
+
548
574
private func generateOutputFileMapDict( module: String , inputPaths: [ AbsolutePath ] ,
549
575
derivedData: AbsolutePath
550
576
) -> [ String : [ String : String ] ] {
0 commit comments