Skip to content

Commit cddf73e

Browse files
committed
[Gardening] Clean Up OS-Test Patterns Across The Codebase
Clean up a few general patterns that are now obviated by canImport This aligns more generally with the cleanup that the Swift Package Manager has already done in their automated XCTest-plumbing tool in swiftlang/swift-package-manager#1826.
1 parent 30ccb52 commit cddf73e

File tree

66 files changed

+161
-157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+161
-157
lines changed

benchmark/single-source/FloatingPointParsing.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public func run_ParseDoubleExp(_ N: Int) {
242242

243243
@inline(never)
244244
public func run_ParseFloat80Exp(_ N: Int) {
245-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(Linux)
245+
#if canImport(Darwin) || os(Linux)
246246
// On Darwin, long double is Float80 on x86, and Double otherwise.
247247
// On Linux, Float80 is at aleast available on x86.
248248
#if arch(x86_64) || arch(i386)
@@ -263,7 +263,7 @@ public func run_ParseDoubleUniform(_ N: Int) {
263263

264264
@inline(never)
265265
public func run_ParseFloat80Uniform(_ N: Int) {
266-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(Linux)
266+
#if canImport(Darwin) || os(Linux)
267267
// On Darwin, long double is Float80 on x86, and Double otherwise.
268268
// On Linux, Float80 is at aleast available on x86.
269269
#if arch(x86_64) || arch(i386)

benchmark/single-source/FloatingPointPrinting.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public func run_FloatingPointPrinting_Double_description_small(_ N: Int) {
106106

107107
@inline(never)
108108
public func run_FloatingPointPrinting_Float80_description_small(_ N: Int) {
109-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(Linux)
109+
#if canImport(Darwin) || os(Linux)
110110
// On Darwin, long double is Float80 on x86, and Double otherwise.
111111
// On Linux, Float80 is at aleast available on x86.
112112
#if arch(x86_64) || arch(i386)
@@ -152,7 +152,7 @@ public func run_FloatingPointPrinting_Double_description_uniform(_ N: Int) {
152152

153153
@inline(never)
154154
public func run_FloatingPointPrinting_Float80_description_uniform(_ N: Int) {
155-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(Linux)
155+
#if canImport(Darwin) || os(Linux)
156156
// On Darwin, long double is Float80 on x86, and Double otherwise.
157157
// On Linux, Float80 is at aleast available on x86.
158158
#if arch(x86_64) || arch(i386)
@@ -202,7 +202,7 @@ public func run_FloatingPointPrinting_Double_interpolated(_ N: Int) {
202202

203203
@inline(never)
204204
public func run_FloatingPointPrinting_Float80_interpolated(_ N: Int) {
205-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(Linux)
205+
#if canImport(Darwin) || os(Linux)
206206
// On Darwin, long double is Float80 on x86, and Double otherwise.
207207
// On Linux, Float80 is at aleast available on x86.
208208
#if arch(x86_64) || arch(i386)

benchmark/single-source/NSStringConversion.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
// <rdar://problem/19003201>
14-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
14+
#if canImport(Darwin)
1515

1616
import TestsUtils
1717
import Foundation

benchmark/utils/main.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ import NibbleSort
103103
import NIOChannelPipeline
104104
import NSDictionaryCastToSwift
105105
import NSError
106-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
106+
#if canImport(Darwin)
107107
import NSStringConversion
108108
#endif
109109
import NopDeinit
110110
import ObjectAllocation
111-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
111+
#if canImport(Darwin)
112112
import ObjectiveCBridging
113113
import ObjectiveCBridgingStubs
114114
#if !(SWIFT_PACKAGE || Xcode)
@@ -287,14 +287,14 @@ registerBenchmark(MonteCarloE)
287287
registerBenchmark(MonteCarloPi)
288288
registerBenchmark(NSDictionaryCastToSwift)
289289
registerBenchmark(NSErrorTest)
290-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
290+
#if canImport(Darwin)
291291
registerBenchmark(NSStringConversion)
292292
#endif
293293
registerBenchmark(NibbleSort)
294294
registerBenchmark(NIOChannelPipeline)
295295
registerBenchmark(NopDeinit)
296296
registerBenchmark(ObjectAllocation)
297-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
297+
#if canImport(Darwin)
298298
registerBenchmark(ObjectiveCBridging)
299299
registerBenchmark(ObjectiveCBridgingStubs)
300300
#if !(SWIFT_PACKAGE || Xcode)

docs/DifferentiableProgramming.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,7 +1949,7 @@ One concrete example is `sinf(_:)` from the C standard library. It can be made
19491949
differentiable by defining a derivative retroactively.
19501950

19511951
```swift
1952-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
1952+
#if canImport(Darwin)
19531953
import func Darwin.sinf
19541954
#else
19551955
import func Glibc.sinf

stdlib/private/StdlibUnittest/RaceTest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
import SwiftPrivate
4040
import SwiftPrivateLibcExtras
4141
import SwiftPrivateThreadExtras
42-
#if os(macOS) || os(iOS)
42+
#if canImport(Darwin)
4343
import Darwin
44-
#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku) || os(WASI)
44+
#elseif canImport(Glibc)
4545
import Glibc
4646
#elseif os(Windows)
4747
import MSVCRT

stdlib/private/StdlibUnittest/StdlibCoreExtras.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
import SwiftPrivate
1414
import SwiftPrivateLibcExtras
15-
#if os(macOS) || os(iOS)
15+
#if canImport(Darwin)
1616
import Darwin
17-
#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku) || os(WASI)
17+
#elseif canImport(Glibc)
1818
import Glibc
1919
#elseif os(Windows)
2020
import MSVCRT

stdlib/private/StdlibUnittest/StdlibUnittest.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import SwiftPrivate
1515
import SwiftPrivateThreadExtras
1616
import SwiftPrivateLibcExtras
1717

18-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
18+
#if canImport(Darwin)
1919
import Foundation
2020
import Darwin
21-
#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku) || os(WASI)
21+
#elseif canImport(Glibc)
2222
import Glibc
2323
#elseif os(Windows)
2424
import MSVCRT
@@ -1728,7 +1728,7 @@ public final class TestSuite {
17281728
var _testNameToIndex: [String : Int] = [:]
17291729
}
17301730

1731-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
1731+
#if canImport(Darwin)
17321732
func _getSystemVersionPlistProperty(_ propertyName: String) -> String? {
17331733
return NSDictionary(contentsOfFile: "/System/Library/CoreServices/SystemVersion.plist")?[propertyName] as? String
17341734
}

stdlib/private/StdlibUnittest/SymbolLookup.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
13+
#if canImport(Darwin)
1414
import Darwin
15-
#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku) || os(WASI)
15+
#elseif canImport(Glibc)
1616
import Glibc
1717
#elseif os(Windows)
1818
import MSVCRT
@@ -21,7 +21,7 @@
2121
#error("Unsupported platform")
2222
#endif
2323

24-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(OpenBSD)
24+
#if canImport(Darwin) || os(OpenBSD)
2525
let RTLD_DEFAULT = UnsafeMutableRawPointer(bitPattern: -2)
2626
#elseif os(Linux)
2727
let RTLD_DEFAULT = UnsafeMutableRawPointer(bitPattern: 0)

stdlib/private/SwiftPrivateLibcExtras/Subprocess.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import SwiftPrivate
14-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
14+
#if canImport(Darwin)
1515
import Darwin
16-
#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku) || os(WASI)
16+
#elseif canImport(Glibc)
1717
import Glibc
1818
#elseif os(Windows)
1919
import MSVCRT

0 commit comments

Comments
 (0)