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 diff --git a/Tests/SystemTests/FileOperationsTest.swift b/Tests/SystemTests/FileOperationsTest.swift index 2434bb5..2b679b7 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,31 @@ 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 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 + throw XCTSkip("O_CLOFORK requires a Darwin SDK for anyAppleOS 27 or newer") +#endif } - #endif #endif // !os(WASI) #if !os(Windows) @@ -258,6 +283,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 +318,9 @@ final class FileOperationsTest: XCTestCase { } } } +#else + throw XCTSkip("dup3 requires a Darwin SDK for anyAppleOS 27 or newer") +#endif } #endif // !os(Windows)