Skip to content

Commit 07d5617

Browse files
authored
Swift Language Support: Drop <5.9, Add 6.0 (#84)
* Swift 6 Language Mode * wip * wip * wip * wip * wip * wip * wip * wip
1 parent 698be41 commit 07d5617

File tree

10 files changed

+78
-70
lines changed

10 files changed

+78
-70
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,31 @@ concurrency:
1414

1515
jobs:
1616
build:
17-
name: MacOS
18-
runs-on: macOS-latest
17+
name: macOS
18+
runs-on: macos-14
1919
steps:
2020
- uses: actions/checkout@v4
21+
- name: Select Xcode
22+
run: sudo xcode-select -s /Applications/Xcode_15.4.app
2123
- name: Run tests
2224
run: make test
2325

24-
ubuntu:
25-
name: Ubuntu
26+
linux:
27+
strategy:
28+
matrix:
29+
swift:
30+
- '5.10'
31+
name: Ubuntu (Swift ${{ matrix.swift }})
2632
runs-on: ubuntu-latest
33+
container: swift:${{ matrix.swift }}
2734
steps:
28-
- uses: actions/checkout@v4
29-
- name: Run tests
30-
run: make test-linux
35+
- uses: actions/checkout@v4
36+
- name: Install dependencies
37+
run: apt-get update && apt-get install -y build-essential libcurl4-openssl-dev
38+
- name: Run tests
39+
run: make test
40+
- name: Build for static-stdlib
41+
run: make build-for-static-stdlib
3142

3243
wasm:
3344
name: Wasm
@@ -54,31 +65,10 @@ jobs:
5465
steps:
5566
- uses: compnerd/gha-setup-swift@main
5667
with:
57-
branch: swift-5.8.1-release
58-
tag: 5.8.1-RELEASE
68+
branch: swift-5.10-release
69+
tag: 5.10-RELEASE
5970
- uses: actions/checkout@v4
6071
- name: Build
6172
run: swift build -c ${{ matrix.config }}
6273
- name: Run tests (debug only)
63-
# There is an issue that exists in the 5.8.1 toolchain
64-
# which fails on release configuration testing, but
65-
# this issue is fixed 5.9 so we can remove the if once
66-
# that is generally available.
67-
if: ${{ matrix.config == 'debug' }}
6874
run: swift test
69-
70-
static-stdlib:
71-
name: Static standard library
72-
strategy:
73-
matrix:
74-
os: [ubuntu-20.04]
75-
runs-on: ${{ matrix.os }}
76-
steps:
77-
- uses: swift-actions/setup-swift@v1
78-
with:
79-
swift-version: '5.8.0'
80-
- name: Install dependencies
81-
run: sudo apt-get install -y libcurl4-openssl-dev
82-
- uses: actions/checkout@v4
83-
- name: Build for static-stdlib
84-
run: make build-for-static-stdlib

Makefile

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,6 @@ test-debug:
1414
test: test-debug
1515
@swift test -c release
1616

17-
test-linux: test-debug
18-
19-
test-linux: test
20-
21-
test-linux-docker:
22-
@docker run \
23-
--rm \
24-
-v "$(PWD):$(PWD)" \
25-
-w "$(PWD)" \
26-
swift:5.6.2-focal \
27-
bash -c "apt-get update && apt-get install make && make test"
28-
29-
test-linux-static-stdlib:
30-
@docker run \
31-
-v "$(PWD):$(PWD)" \
32-
-w "$(PWD)" \
33-
swift:5.6.2-focal \
34-
bash -c "swift build -c debug -Xswiftc -static-stdlib"
35-
@docker run \
36-
-v "$(PWD):$(PWD)" \
37-
-w "$(PWD)" \
38-
swift:5.6.2-focal \
39-
bash -c "swift build -c release -Xswiftc -static-stdlib"
40-
4117
build-for-static-stdlib:
4218
@swift build -c debug --static-swift-stdlib
4319
@swift build -c release --static-swift-stdlib

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.7
1+
// swift-tools-version: 5.9
22

33
import PackageDescription
44

Package@swift-6.0.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// swift-tools-version: 6.0
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "xctest-dynamic-overlay",
7+
platforms: [
8+
.iOS(.v13),
9+
.macOS(.v10_15),
10+
.tvOS(.v13),
11+
.watchOS(.v6),
12+
],
13+
products: [
14+
.library(name: "XCTestDynamicOverlay", targets: ["XCTestDynamicOverlay"])
15+
],
16+
targets: [
17+
.target(name: "XCTestDynamicOverlay"),
18+
.testTarget(
19+
name: "XCTestDynamicOverlayTests",
20+
dependencies: ["XCTestDynamicOverlay"]
21+
),
22+
],
23+
swiftLanguageVersions: [.v6]
24+
)
25+
26+
#if !os(Windows)
27+
// Add the documentation compiler plugin if possible
28+
package.dependencies.append(
29+
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")
30+
)
31+
#endif

Sources/XCTestDynamicOverlay/Internal/RuntimeWarnings.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func runtimeWarn(
1111
#if DEBUG && canImport(os)
1212
os_log(
1313
.fault,
14-
dso: dso,
14+
dso: dso.wrappedValue,
1515
log: OSLog(subsystem: "com.apple.runtime-issues", category: "XCTestDynamicOverlay"),
1616
"%@",
1717
message()
@@ -29,7 +29,7 @@ func runtimeWarn(
2929
//
3030
// Feedback filed: https://gist.github.com/stephencelis/a8d06383ed6ccde3e5ef5d1b3ad52bbc
3131
@usableFromInline
32-
let dso = { () -> UnsafeMutableRawPointer in
32+
let dso = UncheckedSendable({ () -> UnsafeMutableRawPointer in
3333
let count = _dyld_image_count()
3434
for i in 0..<count {
3535
if let name = _dyld_get_image_name(i) {
@@ -42,5 +42,14 @@ func runtimeWarn(
4242
}
4343
}
4444
return UnsafeMutableRawPointer(mutating: #dsohandle)
45-
}()
45+
}())
46+
47+
@usableFromInline
48+
struct UncheckedSendable<Value>: @unchecked Sendable {
49+
@usableFromInline
50+
var wrappedValue: Value
51+
init(_ value: Value) {
52+
self.wrappedValue = value
53+
}
54+
}
4655
#endif

Sources/XCTestDynamicOverlay/Unimplemented.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ func _fail(_ description: String, _ parameters: Any?, fileID: StaticString, line
14871487
Defined at:
14881488
\(fileID):\(line)
14891489
"""
1490-
if let parameters = parameters {
1490+
if let parameters {
14911491
var parametersDescription = ""
14921492
debugPrint(parameters, terminator: "", to: &parametersDescription)
14931493
debugDescription.append(

Sources/XCTestDynamicOverlay/XCTExpectFailure.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import Foundation
4040
return try failingBlock()
4141
}
4242

43-
if let issueMatcher = issueMatcher {
43+
if let issueMatcher {
4444
let issueMatcher: @convention(block) (AnyObject) -> Bool = { issue in
4545
issueMatcher(_XCTIssue(issue))
4646
}
@@ -96,7 +96,7 @@ import Foundation
9696
return
9797
}
9898

99-
if let issueMatcher = issueMatcher {
99+
if let issueMatcher {
100100
let issueMatcher: @convention(block) (AnyObject) -> Bool = { issue in
101101
issueMatcher(_XCTIssue(issue))
102102
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
@_spi(CurrentTestCase) import XCTestDynamicOverlay
22

33
// Make sure XCTCurrentTestCase is visible to SPI.
4-
private let currentTestCase = XCTCurrentTestCase
4+
@MainActor private let currentTestCase = XCTCurrentTestCase

Tests/XCTestDynamicOverlayTests/GeneratePlaceholderTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@
3333
XCTFail("Stream should be finished")
3434
}
3535

36-
let throwingStream: () -> AsyncThrowingStream<Int, Error> = unimplemented("throwingStream")
36+
let throwingStream: @Sendable () -> AsyncThrowingStream<Int, Error> = unimplemented(
37+
"throwingStream"
38+
)
3739
let result = await Task {
38-
try await XCTExpectFailure(failingBlock: throwingStream).first(where: { _ in true })
40+
try await XCTExpectFailure { throwingStream() }.first(where: { _ in true })
3941
}.result
4042
XCTAssertThrowsError(try result.get()) { XCTAssertTrue($0 is CancellationError) }
4143

Tests/XCTestDynamicOverlayTests/TestHelpers.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ struct Client {
9595

9696
struct User { let id: UUID }
9797

98-
let f00: () -> Int = unimplemented("f00", placeholder: 42)
99-
let f01: (String) -> Int = unimplemented("f01", placeholder: 42)
100-
let f02: (String, Int) -> Int = unimplemented("f02", placeholder: 42)
101-
let f03: (String, Int, Double) -> Int = unimplemented("f03", placeholder: 42)
102-
let f04: (String, Int, Double, [Int]) -> Int = unimplemented("f04", placeholder: 42)
103-
let f05: (String, Int, Double, [Int], User) -> Int = unimplemented("f05", placeholder: 42)
98+
@MainActor let f00: () -> Int = unimplemented("f00", placeholder: 42)
99+
@MainActor let f01: (String) -> Int = unimplemented("f01", placeholder: 42)
100+
@MainActor let f02: (String, Int) -> Int = unimplemented("f02", placeholder: 42)
101+
@MainActor let f03: (String, Int, Double) -> Int = unimplemented("f03", placeholder: 42)
102+
@MainActor let f04: (String, Int, Double, [Int]) -> Int = unimplemented("f04", placeholder: 42)
103+
@MainActor let f05: (String, Int, Double, [Int], User) -> Int = unimplemented("f05", placeholder: 42)
104104

105105
private struct Autoclosing {
106106
init(

0 commit comments

Comments
 (0)