Skip to content

Commit

Permalink
Add test with Swift 5 enabling upcoming features (#156)
Browse files Browse the repository at this point in the history
* Test upcoming features

* Fix up for concurrency issues with upcoming features in Swift5
  • Loading branch information
ra1028 authored Oct 10, 2024
1 parent 77485a9 commit 90cd87a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ jobs:
- name: Test example tvOS
run: scripts/test.sh example-cross-platform tvos

upcoming_feature:
name: Upcoming features
runs-on: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode_15.4.app
steps:
- uses: actions/checkout@v4
- name: Test with upcoming features
run: ENABLE_UPCOMING_FEATURES=1 scripts/test.sh library ios

benchmark:
name: Benchmark
runs-on: macos-14
Expand Down
20 changes: 18 additions & 2 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

import PackageDescription

let swiftSettings: [SwiftSetting]

if Context.environment["ENABLE_UPCOMING_FEATURES"] != nil {
swiftSettings = [
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("DisableOutwardActorInference"),
]
}
else {
swiftSettings = [
.enableUpcomingFeature("ExistentialAny"),
]
}

let package = Package(
name: "swiftui-atom-properties",
platforms: [
Expand All @@ -15,11 +29,13 @@ let package = Package(
],
targets: [
.target(
name: "Atoms"
name: "Atoms",
swiftSettings: swiftSettings
),
.testTarget(
name: "AtomsTests",
dependencies: ["Atoms"]
dependencies: ["Atoms"],
swiftSettings: swiftSettings
),
],
swiftLanguageVersions: [.v5]
Expand Down
2 changes: 1 addition & 1 deletion Sources/Atoms/AsyncPhase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public enum AsyncPhase<Success, Failure: Error> {
/// returned value as a success, or thrown error as a failure.
///
/// - Parameter body: A async throwing closure to evaluate.
public init(catching body: @Sendable () async throws -> Success) async where Failure == Error {
public init(catching body: @Sendable () async throws -> Success) async where Failure == any Error {
do {
let value = try await body()
self = .success(value)
Expand Down
4 changes: 4 additions & 0 deletions Sources/Atoms/Core/SubscriberState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ internal final class SubscriberState {
_modify { yield &_unsubscribe.value }
}

#if hasFeature(DisableOutwardActorInference)
nonisolated init() {}
#endif

deinit {
if Thread.isMainThread {
_unsubscribe.value?(_subscribing.value)
Expand Down
4 changes: 4 additions & 0 deletions Sources/Atoms/Suspense.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ private extension Suspense {
}
}

#if !compiler(>=6) && hasFeature(DisableOutwardActorInference)
nonisolated init() {}
#endif

deinit {
suspensionTask?.cancel()
}
Expand Down
8 changes: 4 additions & 4 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ esac

case $TARGET in
library)
xcodebuild test -scheme swiftui-atom-properties -destination platform="$platform"
xcodebuild clean test -scheme swiftui-atom-properties -destination platform="$platform"
;;
example-ios)
cd Examples/Packages/iOS
xcodebuild test -scheme iOSExamples -destination platform="$platform"
xcodebuild clean test -scheme iOSExamples -destination platform="$platform"
;;
example-cross-platform)
cd Examples/Packages/CrossPlatform
xcodebuild test -scheme CrossPlatformExamples -destination platform="$platform"
xcodebuild clean test -scheme CrossPlatformExamples -destination platform="$platform"
;;
benchmark)
cd Benchmarks
xcodebuild test -scheme BenchmarkTests -destination platform="$platform"
xcodebuild clean test -scheme BenchmarkTests -destination platform="$platform"
;;
esac

0 comments on commit 90cd87a

Please sign in to comment.