swiftlang / swift-sdk-generator

Generate Swift SDKs for cross-compilation
Apache License 2.0
183 stars 15 forks source link

Update `AsyncProcess` with bug fixes #156

Open MaxDesiatov opened 7 hours ago

MaxDesiatov commented 7 hours ago

Namely, this works around the following issues in Foundation.Process:

MaxDesiatov commented 7 hours ago

@swift-ci test

euanh commented 4 hours ago

Swift main run has Swift 6.0 concurrency errors:

/code/Tests/AsyncProcessTests/IntegrationTests.swift:1117:12: error: reference to var 'stdout' is not concurrency-safe because it involves shared mutable state
1115 | 
1116 |   override func setUp() async throws {
1117 |     fflush(stdout)
     |            `- error: reference to var 'stdout' is not concurrency-safe because it involves shared mutable state
1118 |     fflush(stderr)
1119 |     self.group = MultiThreadedEventLoopGroup(numberOfThreads: 3)

/usr/include/stdio.h:144:14: note: var declared here
142 | /* Standard streams.  */
143 | extern FILE *stdin;       /* Standard input stream.  */
144 | extern FILE *stdout;      /* Standard output stream.  */
    |              `- note: var declared here
145 | extern FILE *stderr;      /* Standard error output stream.  */
146 | /* C89/C99 say they're macros.  Make them happy.  */

/code/Tests/AsyncProcessTests/IntegrationTests.swift:1118:12: error: reference to var 'stderr' is not concurrency-safe because it involves shared mutable state
1116 |   override func setUp() async throws {
1117 |     fflush(stdout)
1118 |     fflush(stderr)
     |            `- error: reference to var 'stderr' is not concurrency-safe because it involves shared mutable state
1119 |     self.group = MultiThreadedEventLoopGroup(numberOfThreads: 3)
1120 |     self.logger = Logger(label: "test", factory: { _ in SwiftLogNoOpLogHandler() })

/usr/include/stdio.h:145:14: note: var declared here
143 | extern FILE *stdin;       /* Standard input stream.  */
144 | extern FILE *stdout;      /* Standard output stream.  */
145 | extern FILE *stderr;      /* Standard error output stream.  */
    |              `- note: var declared here
146 | /* C89/C99 say they're macros.  Make them happy.  */
147 | #define stdin stdin
euanh commented 4 hours ago

Swift 5.9 run fails in the runaway child processes test:

Test Case 'IntegrationTests.testCanDealWithRunawayChildProcesses' started at 2024-11-27 14:51:18.741
2024-11-27T14:51:18+0000 error x : [AsyncProcessTests] kill didn't fail on attempt 0, trying again...
2024-11-27T14:51:18+0000 error x : [AsyncProcessTests] kill didn't fail on attempt 1, trying again...
2024-11-27T14:51:18+0000 error x : [AsyncProcessTests] kill didn't fail on attempt 2, trying again...
2024-11-27T14:51:19+0000 error x : [AsyncProcessTests] kill didn't fail on attempt 3, trying again...
2024-11-27T14:51:19+0000 error x : [AsyncProcessTests] kill didn't fail on attempt 4, trying again...
2024-11-27T14:51:19+0000 error x : [AsyncProcessTests] kill didn't fail on attempt 5, trying again...
/code/Tests/AsyncProcessTests/IntegrationTests.swift:1066: error: IntegrationTests.testCanDealWithRunawayChildProcesses : XCTAssertEqual failed: ("-1") is not equal to ("0") -
/code/Tests/AsyncProcessTests/IntegrationTests.swift:1067: error: IntegrationTests.testCanDealWithRunawayChildProcesses : XCTAssertEqual failed: ("3") is not equal to ("2") -
Test Case 'IntegrationTests.testCanDealWithRunawayChildProcesses' failed (0.606 seconds)
MaxDesiatov commented 12 minutes ago

cc @weissi