From 677e51f1f245f8d850c56803d1644dad7d472b15 Mon Sep 17 00:00:00 2001 From: Rick Newton-Rogers Date: Mon, 16 Nov 2026 19:13:20 -0500 Subject: [PATCH 1/3] Bump `swiftlang/github-workflows` to 0.0.18 The new workflows use macOS Golden Gate rather than macOS Tahoe by default. --- .github/workflows/automerge_to_main.yml | 2 +- .github/workflows/automerge_to_release.yml | 2 +- .github/workflows/pull_request.yml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/automerge_to_main.yml b/.github/workflows/automerge_to_main.yml index d80a08f..af132fa 100644 --- a/.github/workflows/automerge_to_main.yml +++ b/.github/workflows/automerge_to_main.yml @@ -9,7 +9,7 @@ on: jobs: create_merge_pr: name: Create PR to merge release branch into main branch - uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@0.0.17 + uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@0.0.18 with: base_branch: main head_branch: release/1.9.x diff --git a/.github/workflows/automerge_to_release.yml b/.github/workflows/automerge_to_release.yml index 006fa36..9d8caa9 100644 --- a/.github/workflows/automerge_to_release.yml +++ b/.github/workflows/automerge_to_release.yml @@ -10,7 +10,7 @@ on: jobs: create_merge_pr: name: Create PR to merge previous release branch into current release branch - uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@0.0.17 + uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@0.0.18 with: base_branch: release/1.9.x head_branch: release/1.8.x diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 07505bd..57e2813 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -10,7 +10,7 @@ on: jobs: tests: name: Test - uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.17 + uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.18 with: swift_flags: "-Xbuild-tools-swiftc -DSYSTEM_CI" linux_os_versions: '["noble", "jammy", "focal"]' @@ -52,7 +52,7 @@ jobs: build-abi-stable: name: Build ABI Stable - uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.17 + uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.18 with: enable_linux_checks: false enable_macos_checks: true @@ -102,7 +102,7 @@ jobs: soundness: name: Soundness - uses: swiftlang/github-workflows/.github/workflows/soundness.yml@0.0.17 + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@0.0.18 with: license_header_check_project_name: "Swift.org" # https://github.com/apple/swift-system/issues/224 From 8e71dd3e0dce75964c930d54090876bc74397d4d Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Tue, 17 Nov 2026 14:49:54 -0800 Subject: [PATCH 2/3] Fix tests when testing with an SDK mismatch --- Tests/SystemTests/FileOperationsTest.swift | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Tests/SystemTests/FileOperationsTest.swift b/Tests/SystemTests/FileOperationsTest.swift index 2434bb5..4f295a2 100644 --- a/Tests/SystemTests/FileOperationsTest.swift +++ b/Tests/SystemTests/FileOperationsTest.swift @@ -179,11 +179,12 @@ final class FileOperationsTest: XCTestCase { } func testAdHocPipeWithOptions() throws { +#if !SYSTEM_PACKAGE_DARWIN || canImport(Darwin, _version: 428) guard #available(macOS 27.0, iOS 27.0, watchOS 27.0, tvOS 27.0, visionOS 27.0, *) else { throw XCTSkip("pipe2 and PipeOptions require Darwin 27 or newer") } - // Ad-hoc test testing `Pipe` functionality. - // We cannot test `Pipe` using `MockTestCase` because it calls `pipe` with a pointer to an array local to the `Pipe`, the address of which we do not know prior to invoking `Pipe`. + // Ad-hoc test: `MockTestCase` can't match the pointer to the local array + // that `pipe` receives, because its address isn't known in advance. let options: FileDescriptor.PipeOptions = [.closeOnExec] let pipe: (readEnd: FileDescriptor, writeEnd: FileDescriptor) pipe = try FileDescriptor.pipe(options: options) @@ -194,16 +195,20 @@ final class FileOperationsTest: XCTestCase { _ = try pipe.writeEnd.write(UnsafeRawBufferPointer($0)) } let readLen = 3 - let readBytes = try Array(unsafeUninitializedCapacity: readLen) { buf, count in + let readBytes = try Array(unsafeUninitializedCapacity: readLen) { + buf, count in count = try pipe.readEnd.read(into: UnsafeMutableRawBufferPointer(buf)) } XCTAssertEqual(readBytes, Array(abc.utf8)) } } +#else + throw XCTSkip("pipe2 requires a Darwin SDK for anyAppleOS 27 or newer") +#endif } - #if canImport(Darwin, _version: 428) // The macOS 27 SDK defines O_CLOFORK. func testAdHocPipeCloseOnFork() throws { +#if canImport(Darwin, _version: 428) guard #available(macOS 27.0, iOS 27.0, watchOS 27.0, tvOS 27.0, visionOS 27.0, *) else { throw XCTSkip("pipe2 and PipeOptions require anyAppleOS 27 or newer") } @@ -212,11 +217,14 @@ final class FileOperationsTest: XCTestCase { let pipe = try FileDescriptor.pipe(options: .closeOnFork) try pipe.readEnd.closeAfter { try pipe.writeEnd.closeAfter { - XCTAssertEqual(fcntl(pipe.readEnd.rawValue, F_GETFD) & FD_CLOFORK, FD_CLOFORK) + let selectedFlag = fcntl(pipe.readEnd.rawValue, F_GETFD) & FD_CLOFORK + XCTAssertEqual(selectedFlag, FD_CLOFORK) } } +#else + throw XCTSkip("O_CLOFORK requires a Darwin SDK for anyAppleOS 27 or newer") +#endif } - #endif #endif // !os(WASI) #if !os(Windows) @@ -258,6 +266,7 @@ final class FileOperationsTest: XCTestCase { } func testAdHocDuplicate3() throws { +#if !SYSTEM_PACKAGE_DARWIN || canImport(Darwin, _version: 428) guard #available(macOS 27.0, iOS 27.0, watchOS 27.0, tvOS 27.0, visionOS 27.0, *) else { throw XCTSkip("dup3 and DuplicateOptions require Darwin 27 or newer") } @@ -292,6 +301,9 @@ final class FileOperationsTest: XCTestCase { } } } +#else + throw XCTSkip("dup3 requires a Darwin SDK for anyAppleOS 27 or newer") +#endif } #endif // !os(Windows) From 53b1815f41e73749f19a102d6788b08775942a1f Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Tue, 17 Nov 2026 14:59:25 -0800 Subject: [PATCH 3/3] Test pipe2 with O_CLOFORK on FreeBSD --- Tests/SystemTests/FileOperationsTest.swift | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Tests/SystemTests/FileOperationsTest.swift b/Tests/SystemTests/FileOperationsTest.swift index 4f295a2..2b679b7 100644 --- a/Tests/SystemTests/FileOperationsTest.swift +++ b/Tests/SystemTests/FileOperationsTest.swift @@ -217,8 +217,25 @@ final class FileOperationsTest: XCTestCase { let pipe = try FileDescriptor.pipe(options: .closeOnFork) try pipe.readEnd.closeAfter { try pipe.writeEnd.closeAfter { - let selectedFlag = fcntl(pipe.readEnd.rawValue, F_GETFD) & FD_CLOFORK - XCTAssertEqual(selectedFlag, FD_CLOFORK) + let flags = fcntl(pipe.readEnd.rawValue, F_GETFD) + XCTAssertEqual(flags & FD_CLOFORK, FD_CLOFORK) + } + } +#elseif os(FreeBSD) + let pipe: (readEnd: FileDescriptor, writeEnd: FileDescriptor) + do { + pipe = try FileDescriptor.pipe(options: .closeOnFork) + } catch { + if (error as? Errno) == .invalidArgument { + throw XCTSkip("pipe2 does not support O_CLOFORK before FreeBSD 15") + } + throw error + } + try pipe.readEnd.closeAfter { + try pipe.writeEnd.closeAfter { + let flags = fcntl(pipe.readEnd.rawValue, F_GETFD) + XCTAssertEqual(flags & FD_CLOEXEC, 0) + XCTAssertNotEqual(flags, 0) } } #else