@@ -88,7 +88,6 @@ extension Trait where Self == ConditionTrait {
8888 atPath: destinationPath. path,
8989 withDestinationPath: linkDestination
9090 )
91- enumerator. skipDescendants ( )
9291 continue
9392 }
9493
@@ -117,8 +116,11 @@ extension Trait where Self == ConditionTrait {
117116 typealias RunProcess = ( _ executableURL: URL , _ args: [ String ] , _ env: [ String : String ] ) throws -> Void
118117 typealias RunSwift = ( _ args: [ String ] , _ env: [ String : String ] ) throws -> Void
119118
120- func withPackage( at path: String , body: ( URL , _ runProcess: RunProcess , _ runSwift: RunSwift ) throws -> Void ) throws
121- {
119+ func withPackage(
120+ at path: String ,
121+ assertTerminationStatus: ( Int32 ) -> Bool = { $0 == 0 } ,
122+ body: @escaping ( URL , _ runProcess: RunProcess , _ runSwift: RunSwift ) throws -> Void
123+ ) throws {
122124 try withTemporaryDirectory { tempDir, retain in
123125 let destination = tempDir. appending ( path: Self . repoPath. lastPathComponent)
124126 try Self . copyRepository ( to: destination)
@@ -139,11 +141,11 @@ extension Trait where Self == ConditionTrait {
139141
140142 try process. run ( )
141143 process. waitUntilExit ( )
142- if process. terminationStatus != 0 {
144+ if !assertTerminationStatus ( process. terminationStatus) {
143145 retain = true
144146 }
145147 try #require(
146- process. terminationStatus == 0 ,
148+ assertTerminationStatus ( process. terminationStatus) ,
147149 """
148150 Swift package should build successfully, check \( destination. appending ( path: path) . path) for details
149151 stdout: \( stdoutPath. path)
@@ -275,4 +277,29 @@ extension Trait where Self == ConditionTrait {
275277 )
276278 }
277279 }
280+
281+ @Test ( . requireSwiftSDK)
282+ func continuationLeakInTest_XCTest( ) throws {
283+ let swiftSDKID = try #require( Self . getSwiftSDKID ( ) )
284+ try withPackage (
285+ at: " Plugins/PackageToJS/Fixtures/ContinuationLeakInTest/XCTest " ,
286+ assertTerminationStatus: { $0 != 0 }
287+ ) { packageDir, _, runSwift in
288+ try runSwift ( [ " package " , " --disable-sandbox " , " --swift-sdk " , swiftSDKID, " js " , " test " ] , [ : ] )
289+ }
290+ }
291+
292+ #if compiler(>=6.1)
293+ // TODO: Remove triple restriction once swift-testing is shipped in p1-threads SDK
294+ @Test ( . requireSwiftSDK( triple: " wasm32-unknown-wasi " ) )
295+ func continuationLeakInTest_SwiftTesting( ) throws {
296+ let swiftSDKID = try #require( Self . getSwiftSDKID ( ) )
297+ try withPackage (
298+ at: " Plugins/PackageToJS/Fixtures/ContinuationLeakInTest/SwiftTesting " ,
299+ assertTerminationStatus: { $0 != 0 }
300+ ) { packageDir, _, runSwift in
301+ try runSwift ( [ " package " , " --disable-sandbox " , " --swift-sdk " , swiftSDKID, " js " , " test " ] , [ : ] )
302+ }
303+ }
304+ #endif
278305}
0 commit comments