Skip to content

Commit

Permalink
Swift Strict Concurrency (#23)
Browse files Browse the repository at this point in the history
# Swift Strict Concurrency

## ♻️ Current situation & Problem
Enable Swift strict concurrency and some concurrency fixes.


## ⚙️ Release Notes 
* Enable Swift strict concurrency and some concurrency fixes.


### Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
Supereg authored Jul 2, 2024
1 parent 69eae1a commit cc2705f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import PackageDescription


#if swift(<6)
let swiftConcurrency: SwiftSetting = .enableExperimentalFeature("SwiftConcurrency")
let swiftConcurrency: SwiftSetting = .enableExperimentalFeature("StrictConcurrency")
#else
let swiftConcurrency: SwiftSetting = .enableUpcomingFeature("SwiftConcurrency")
let swiftConcurrency: SwiftSetting = .enableUpcomingFeature("StrictConcurrency")
#endif


Expand Down
1 change: 1 addition & 0 deletions Sources/XCTestApp/TestAppTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/// A collection of test cases that can be executed in an ``TestAppView``.
public protocol TestAppTestCase: Identifiable {
/// Implement this method to run all the tests that should be executed.
@MainActor
func runTests() async throws
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/XCTestExtensions/XCTAssertThrowsErrorAsync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import XCTest
/// - line: The line number where the failure occurs. The default is the line number where you call this function.
/// - errorHandler: An optional handler for errors that expression throws.
public func XCTAssertThrowsErrorAsync<T>(
_ expression: @autoclosure () async throws -> T,
_ message: @autoclosure () -> String = "",
_ expression: @autoclosure @Sendable () async throws -> T,
_ message: @autoclosure @Sendable () -> String = "",
file: StaticString = #filePath,
line: UInt = #line,
_ errorHandler: (Error) throws -> Void = { _ in }
_ errorHandler: @Sendable (Error) throws -> Void = { _ in }
) async rethrows {
do {
_ = try await expression()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extension XCTestCase {
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(visionOS, unavailable)
@MainActor
public func disablePasswordAutofill() throws {
let settingsApp = XCUIApplication(bundleIdentifier: "com.apple.Preferences")
settingsApp.terminate()
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCTestExtensions/XCUIElement+TextEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import XCTest
/// An internal flag that is used to test the flaky simulator text entry behavior in the iOS simulator.
///
/// Do not use this flag outside of the UI tests in the ``XCTestExtensions`` target!
var simulateFlakySimulatorTextEntry = false
@MainActor var simulateFlakySimulatorTextEntry = false


extension XCUIElement {
Expand Down
2 changes: 2 additions & 0 deletions Tests/UITests/TestAppUITests/XCTestExtensionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class XCTestExtensionsTests: XCTestCase {
XCTAssert(app.staticTexts["No secure text set ..."].waitForExistence(timeout: 5))
}

@MainActor
func testDisablePasswordAutofill() throws {
#if os(iOS)
try disablePasswordAutofill()
Expand All @@ -75,6 +76,7 @@ class XCTestExtensionsTests: XCTestCase {
try app.callTextEntryExtensions()
}

@MainActor
func testFlakyTextEntry() throws {
let app = XCUIApplication()
app.launch()
Expand Down

0 comments on commit cc2705f

Please sign in to comment.