Skip to content

Commit fbc0f2c

Browse files
committed
Add PlatformConformance in tests to ensure platform specifc types follow a uniform shape
1 parent bbb5432 commit fbc0f2c

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
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)