Skip to content

Commit 2543679

Browse files
authored
Merge pull request #12 from groue/dev/Swift-5.10
Bump minimum Swift version to 5.10
2 parents ad48ff5 + b12e9c2 commit 2543679

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

.github/workflows/run_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ jobs:
2323
strategy:
2424
matrix:
2525
os: [macos-latest, ubuntu-latest]
26-
swift-version: ["5.7.0"]
26+
swift-version: ["5.10.0"]
2727
runs-on: ${{ matrix.os }}
2828
steps:
2929
- uses: actions/checkout@v3
3030
- name: Install Swift ${{ matrix.swift-version }}
3131
if: ${{ runner.os != 'Windows' }}
32-
uses: swift-actions/setup-swift@v1
32+
uses: swift-actions/setup-swift@v2
3333
with:
3434
swift-version: ${{ matrix.swift-version }}
3535
- name: Test

Package.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.7
1+
// swift-tools-version: 5.10
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
@@ -25,12 +25,18 @@ let package = Package(
2525
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
2626
// Targets can depend on other targets in this package, and on products in packages this package depends on.
2727
.target(
28-
name: "Semaphore",
29-
swiftSettings: [
30-
// .unsafeFlags(["-Xfrontend", "-warn-concurrency", "-strict-concurrency=complete"]),
31-
]),
28+
name: "Semaphore"),
3229
.testTarget(
3330
name: "SemaphoreTests",
3431
dependencies: ["Semaphore"]),
3532
]
3633
)
34+
35+
for target in package.targets {
36+
var settings = target.swiftSettings ?? []
37+
settings.append(contentsOf: [
38+
// <https://github.com/apple/swift-evolution/blob/main/proposals/0337-support-incremental-migration-to-concurrency-checking.md>
39+
.enableExperimentalFeature("StrictConcurrency"),
40+
])
41+
target.swiftSettings = settings
42+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**A Synchronization Primitive for Swift Concurrency**
44

5-
**Requirements**: iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+ • Swift 5.7+ / Xcode 14+
5+
**Requirements**: iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+ • Swift 5.10+ / Xcode 15.3+
66

77
📖 **[Documentation](https://swiftpackageindex.com/groue/Semaphore/documentation)**
88

Tests/SemaphoreTests/AsyncSemaphoreTests.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ final class AsyncSemaphoreTests: XCTestCase {
7171
}
7272
}
7373

74-
func test_wait_suspends_on_zero_semaphore_until_signal() {
74+
func test_wait_suspends_on_zero_semaphore_until_signal() async {
7575
// Check DispatchSemaphore behavior
7676
do {
7777
// Given a zero semaphore
@@ -88,11 +88,11 @@ final class AsyncSemaphoreTests: XCTestCase {
8888
}.start()
8989

9090
// Then the thread is initially blocked.
91-
wait(for: [ex1], timeout: 0.5)
91+
await fulfillment(of: [ex1], timeout: 0.5)
9292

9393
// When a signal occurs, then the waiting thread is woken.
9494
sem.signal()
95-
wait(for: [ex2], timeout: 1)
95+
await fulfillment(of: [ex2], timeout: 1)
9696
}
9797

9898
// Test that AsyncSemaphore behaves identically
@@ -111,11 +111,11 @@ final class AsyncSemaphoreTests: XCTestCase {
111111
}
112112

113113
// Then the task is initially suspended.
114-
wait(for: [ex1], timeout: 0.5)
114+
await fulfillment(of: [ex1], timeout: 0.5)
115115

116116
// When a signal occurs, then the suspended task is resumed.
117117
sem.signal()
118-
wait(for: [ex2], timeout: 0.5)
118+
await fulfillment(of: [ex2], timeout: 0.5)
119119
}
120120
}
121121

@@ -134,7 +134,7 @@ final class AsyncSemaphoreTests: XCTestCase {
134134
}
135135
try await Task.sleep(nanoseconds: 100_000_000)
136136
task.cancel()
137-
wait(for: [ex], timeout: 1)
137+
await fulfillment(of: [ex], timeout: 1)
138138
}
139139

140140
func test_cancellation_before_suspension_throws_CancellationError() throws {
@@ -180,14 +180,14 @@ final class AsyncSemaphoreTests: XCTestCase {
180180
}
181181

182182
// Then the task is initially suspended.
183-
wait(for: [ex1], timeout: 0.5)
183+
await fulfillment(of: [ex1], timeout: 0.5)
184184

185185
// When a signal occurs, then the suspended task is resumed.
186186
sem.signal()
187-
wait(for: [ex2], timeout: 0.5)
187+
await fulfillment(of: [ex2], timeout: 0.5)
188188
}
189189

190-
func test_that_cancellation_before_suspension_increments_the_semaphore() throws {
190+
func test_that_cancellation_before_suspension_increments_the_semaphore() async throws {
191191
// Given a task cancelled before it waits on a semaphore,
192192
let sem = AsyncSemaphore(value: 0)
193193
let task = Task {
@@ -212,11 +212,11 @@ final class AsyncSemaphoreTests: XCTestCase {
212212
}
213213

214214
// Then the task is initially suspended.
215-
wait(for: [ex1], timeout: 0.5)
215+
await fulfillment(of: [ex1], timeout: 0.5)
216216

217217
// When a signal occurs, then the suspended task is resumed.
218218
sem.signal()
219-
wait(for: [ex2], timeout: 0.5)
219+
await fulfillment(of: [ex2], timeout: 0.5)
220220
}
221221

222222
// Inspired by <https://github.com/groue/Semaphore/pull/3>
@@ -241,7 +241,7 @@ final class AsyncSemaphoreTests: XCTestCase {
241241
}
242242

243243
// Then the second task is not suspended.
244-
wait(for: [ex], timeout: 0.5)
244+
await fulfillment(of: [ex], timeout: 0.5)
245245
}
246246

247247
// Test that semaphore can limit the number of concurrent executions of

0 commit comments

Comments
 (0)