Skip to content

Commit 2fee46b

Browse files
committed
Add PlatformConformance in tests to ensure platform specifc types follow a uniform shape
1 parent a9085c3 commit 2fee46b

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

Package.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import PackageDescription
66
var dep: [Package.Dependency] = [
77
.package(
88
url: "https://github.com/apple/swift-system",
9-
from: "1.5.0"
9+
// Temporarily pin to 1.5.0 because 1.6.0 has a breaking change for Ubuntu Focal
10+
// https://github.com/apple/swift-system/issues/237
11+
exact: "1.5.0"
1012
)
1113
]
1214
#if !os(Windows)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
//
10+
//===----------------------------------------------------------------------===//
11+
12+
@testable import Subprocess
13+
14+
#if canImport(Darwin)
15+
import Darwin
16+
#elseif canImport(Bionic)
17+
import Bionic
18+
#elseif canImport(Glibc)
19+
import Glibc
20+
#elseif canImport(Musl)
21+
import Musl
22+
#elseif canImport(WinSDK)
23+
import WinSDK
24+
#endif
25+
26+
/// This file defines protocols for platform-specific structs
27+
/// and adds retroactive conformances to them to ensure they all
28+
/// conform to a uniform shape. We opted to keep these protocols
29+
/// in the test target as opposed to making them public APIs
30+
/// because we don't directly use them in public APIs.
31+
32+
protocol ProcessIdentifierProtocol: Sendable, Hashable, CustomStringConvertible, CustomDebugStringConvertible {
33+
#if os(Windows)
34+
var value: DWORD { get }
35+
#else
36+
var value: pid_t { get }
37+
#endif
38+
}
39+
40+
extension ProcessIdentifier : ProcessIdentifierProtocol {}

0 commit comments

Comments
 (0)