-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
687 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[*] | ||
insert_final_newline = true | ||
indent_size = 4 # We can remove this line if anyone has strong opinions. | ||
|
||
# swift | ||
[*.swift] | ||
indent_style = tab | ||
|
||
# sh | ||
[*.sh] | ||
indent_style = tab | ||
|
||
# graphql | ||
[*.graphql] | ||
indent_style = tab | ||
|
||
# documentation, utils | ||
[*.{md,mdx,diff}] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
github: dfed | ||
buy_me_a_coffee: dfed | ||
custom: https://cash.app/$dan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: enhancement | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Goals** | ||
What do you want this feature to accomplish? What are the effects of your change? | ||
|
||
**Non-Goals** | ||
What aren’t you trying to accomplish? What are the boundaries of the proposed work? | ||
|
||
**Investigations** | ||
What other solutions (if any) did you investigate? Why didn’t you choose them? | ||
|
||
**Design** | ||
What are you proposing? What are the details of your chosen design? Include an API overview, technical details, and (potentially) some example headers, along with anything else you think will be useful. This is where you sell the design to yourself and project maintainers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
spm-16: | ||
name: Build Xcode 16 | ||
runs-on: macos-14 | ||
strategy: | ||
matrix: | ||
platforms: [ | ||
'iOS_18,watchOS_11', | ||
'macOS_15,tvOS_18', | ||
'visionOS_2' | ||
] | ||
fail-fast: false | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.3.5' | ||
bundler-cache: true | ||
- name: Select Xcode Version | ||
run: sudo xcode-select --switch /Applications/Xcode_16.app/Contents/Developer | ||
- name: Download visionOS | ||
if: matrix.platforms == 'visionOS_2' | ||
run: | | ||
sudo xcodebuild -runFirstLaunch | ||
sudo xcrun simctl list | ||
sudo xcodebuild -downloadPlatform visionOS | ||
sudo xcodebuild -runFirstLaunch | ||
- name: Build and Test Framework | ||
run: Scripts/build.swift ${{ matrix.platforms }} | ||
- name: Prepare Coverage Reports | ||
run: ./Scripts/prepare-coverage-reports.sh | ||
- name: Upload Coverage Reports | ||
if: success() | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
spm-16-swift: | ||
name: Swift Build Xcode 16 | ||
runs-on: macos-14 | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.3.5' | ||
bundler-cache: true | ||
- name: Select Xcode Version | ||
run: sudo xcode-select --switch /Applications/Xcode_16.app/Contents/Developer | ||
- name: Build and Test Framework | ||
run: xcrun swift test -c release -Xswiftc -enable-testing | ||
linux: | ||
name: "Build and Test on Linux" | ||
runs-on: ubuntu-24.04 | ||
container: swift:6.0 | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
- name: Build and Test Framework | ||
run: swift test -c release --enable-code-coverage -Xswiftc -enable-testing | ||
- name: Prepare Coverage Reports | ||
run: | | ||
llvm-cov export -format="lcov" .build/x86_64-unknown-linux-gnu/release/swift-testing-expectationPackageTests.xctest -instr-profile .build/x86_64-unknown-linux-gnu/release/codecov/default.profdata > coverage.lcov | ||
- name: Upload Coverage Reports | ||
if: success() | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
lint-swift: | ||
name: Lint Swift | ||
runs-on: ubuntu-latest | ||
container: swift:6.0 | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
- name: Lint Swift | ||
run: swift run --package-path CLI swiftformat --swiftversion 6.0 . --lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# format options | ||
--indent tab | ||
--modifierorder nonisolated,open,public,internal,fileprivate,private,private(set),final,override,required | ||
--ranges no-space | ||
--extensionacl on-declarations | ||
--funcattributes prev-line | ||
--typeattributes prev-line | ||
--storedvarattrs same-line | ||
--hexgrouping none | ||
--decimalgrouping 3 | ||
|
||
# rules | ||
--enable isEmpty | ||
--enable wrapEnumCases | ||
--enable wrapMultilineStatementBraces | ||
--disable consistentSwitchCaseSpacing | ||
--disable blankLineAfterSwitchCase |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
CLI/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"originHash" : "b043e9190ddd3045375d40ccb608edf659c48e3b9f8e2ee40cc489c8ec3f496d", | ||
"pins" : [ | ||
{ | ||
"identity" : "swiftformat", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/nicklockwood/SwiftFormat", | ||
"state" : { | ||
"revision" : "ab6844edb79a7b88dc6320e6cee0a0db7674dac3", | ||
"version" : "0.54.5" | ||
} | ||
} | ||
], | ||
"version" : 3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// swift-tools-version: 6.0 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "CLI", | ||
platforms: [ | ||
.macOS(.v14), | ||
], | ||
products: [], | ||
dependencies: [ | ||
.package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.54.5"), | ||
], | ||
targets: [] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
### One issue or bug per Pull Request | ||
|
||
Keep your Pull Requests small. Small PRs are easier to reason about which makes them significantly more likely to get merged. | ||
|
||
### Issues before features | ||
|
||
If you want to add a feature, please file an [Issue](../../issues) first. An Issue gives us the opportunity to discuss the requirements and implications of a feature with you before you start writing code. | ||
|
||
### Backwards compatibility | ||
|
||
Respect the minimum deployment target. If you are adding code that uses new APIs, make sure to prevent older clients from crashing or misbehaving. Our CI runs against our minimum deployment targets, so you will not get a green build unless your code is backwards compatible. | ||
|
||
### Forwards compatibility | ||
|
||
Please do not write new code using deprecated APIs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// swift-tools-version: 6.0 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "swift-testing-expectation", | ||
platforms: [ | ||
.macOS(.v13), | ||
.iOS(.v16), | ||
.tvOS(.v16), | ||
.watchOS(.v9), | ||
.macCatalyst(.v16), | ||
.visionOS(.v1), | ||
], | ||
products: [ | ||
.library( | ||
name: "TestingExpectation", | ||
targets: ["TestingExpectation"] | ||
), | ||
], | ||
targets: [ | ||
.target( | ||
name: "TestingExpectation", | ||
dependencies: [], | ||
swiftSettings: [ | ||
.swiftLanguageMode(.v6), | ||
] | ||
), | ||
.testTarget( | ||
name: "TestingExpectationTests", | ||
dependencies: ["TestingExpectation"], | ||
swiftSettings: [ | ||
.swiftLanguageMode(.v6), | ||
] | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,46 @@ | ||
# swift-testing-expectation | ||
Makes it easy to create an asynchronous expectation in Swift Testing | ||
[![CI Status](https://img.shields.io/github/actions/workflow/status/dfed/swift-testing-expectation/ci.yml?branch=main)](https://github.com/dfed/swift-testing-expectation/actions?query=workflow%3ACI+branch%3Amain) | ||
[![codecov](https://codecov.io/gh/dfed/swift-testing-expectation/branch/main/graph/badge.svg?token=nZBHcZZ63F)](https://codecov.io/gh/dfed/swift-testing-expectation) | ||
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html) | ||
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fdfed%2Fswift-testing-expectation%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/dfed/swift-testing-expectation) | ||
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fdfed%2Fswift-testing-expectation%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/dfed/swift-testing-expectation) | ||
|
||
Making it easy to create an asynchronous expectation in Swift Testing | ||
|
||
## Testing with asynchronous expectations | ||
|
||
The [Swift Testing](https://developer.apple.com/documentation/testing/testing-asynchronous-code) vends a [confirmation](https://developer.apple.com/documentation/testing/confirmation(_:expectedcount:isolation:sourcelocation:_:)) method which enables testing asynchronous code. However unlike [XCTest](https://developer.apple.com/documentation/xctest/asynchronous_tests_and_expectations)’s [XCTestExpectation](https://developer.apple.com/documentation/xctest/xctestexpectation), this `confirmation` must be confirmed before the confirmation’s `body` completes. Swift Testing has no out-of-the-box way to ensure that an expectation is fulfilled at some indeterminate point in the future. | ||
|
||
The `Expectation` vended from this library fills that gap: | ||
|
||
```swift | ||
@Test func testMethodCallEventuallyTriggersClosure() async { | ||
let expectation = Expectation() | ||
|
||
systemUnderTest.closure = { expectation.fulfill() } | ||
systemUnderTest.method() | ||
|
||
await expectation.fulfillment(within: .seconds(5)) | ||
} | ||
``` | ||
|
||
## Requirements | ||
|
||
* Xcode 16.0 or later. | ||
* iOS 16 or later. | ||
* tvOS 16 or later. | ||
* watchOS 9 or later. | ||
* macOS 13 or later. | ||
* Swift 5.10 or later. | ||
|
||
## Installation | ||
|
||
### Swift Package Manager | ||
|
||
To install swift-async-queue in your project with [Swift Package Manager](https://github.com/apple/swift-package-manager), the following lines can be added to your `Package.swift` file: | ||
|
||
```swift | ||
dependencies: [ | ||
.package(url: "https://github.com/dfed/swift-testing-expectation", from: "0.1.0"), | ||
] | ||
``` |
Oops, something went wrong.