@@ -1053,6 +1053,52 @@ final class CachingBuildTests: XCTestCase {
1053
1053
}
1054
1054
}
1055
1055
1056
+ func testCrashReproducer( ) throws {
1057
+ try withTemporaryDirectory { path in
1058
+ try localFileSystem. changeCurrentWorkingDirectory ( to: path)
1059
+ let moduleCachePath = path. appending ( component: " ModuleCache " )
1060
+ let casPath = path. appending ( component: " cas " )
1061
+ try localFileSystem. createDirectory ( moduleCachePath)
1062
+ let main = path. appending ( component: " testCachingBuild.swift " )
1063
+ let mainFileContent = " import C; "
1064
+ try localFileSystem. writeFileContents ( main) {
1065
+ $0. send ( mainFileContent)
1066
+ }
1067
+ let cHeadersPath : AbsolutePath =
1068
+ try testInputsPath. appending ( component: " ExplicitModuleBuilds " )
1069
+ . appending ( component: " CHeaders " )
1070
+ let swiftModuleInterfacesPath : AbsolutePath =
1071
+ try testInputsPath. appending ( component: " ExplicitModuleBuilds " )
1072
+ . appending ( component: " Swift " )
1073
+ let sdkArgumentsForTesting = ( try ? Driver . sdkArgumentsForTesting ( ) ) ?? [ ]
1074
+ var env = ProcessEnv . block
1075
+ env [ " SWIFT_CRASH_DIAGNOSTICS_DIR " ] = path. nativePathString ( escaped: true )
1076
+ var driver = try Driver ( args: [ " swiftc " ,
1077
+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
1078
+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
1079
+ " -explicit-module-build " , " -enable-deterministic-check " ,
1080
+ " -module-cache-path " , moduleCachePath. nativePathString ( escaped: true ) ,
1081
+ " -cache-compile-job " , " -cas-path " , casPath. nativePathString ( escaped: true ) ,
1082
+ " -working-directory " , path. nativePathString ( escaped: true ) ,
1083
+ " -Xfrontend " , " -debug-crash-after-parse " ,
1084
+ main. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting,
1085
+ env: env)
1086
+ guard driver. isFrontendArgSupported ( . genReproducer) else {
1087
+ throw XCTSkip ( " crash reproducer not supported " )
1088
+ }
1089
+ let jobs = try driver. planBuild ( )
1090
+ do {
1091
+ try driver. run ( jobs: jobs)
1092
+ XCTFail ( " Build should fail " )
1093
+ } catch {
1094
+ XCTAssertTrue ( driver. diagnosticEngine. hasErrors)
1095
+ XCTAssertTrue ( driver. diagnosticEngine. diagnostics. contains {
1096
+ $0. message. behavior == . note && $0. message. data. description. starts ( with: " crash reproducer " )
1097
+ } )
1098
+ }
1099
+ }
1100
+ }
1101
+
1056
1102
func testDeterministicCheck( ) throws {
1057
1103
try withTemporaryDirectory { path in
1058
1104
try localFileSystem. changeCurrentWorkingDirectory ( to: path)
0 commit comments