Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,38 @@ on:
branches:
- '*'

concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: MacOS
runs-on: macOS-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Run tests
run: make test

ubuntu:
name: Ubuntu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Run tests
run: make test

wasm:
name: SwiftWASM
runs-on: ubuntu-latest
strategy:
matrix:
include:
- { toolchain: wasm-5.6.0-RELEASE }

steps:
- uses: actions/checkout@v3
- run: echo "${{ matrix.toolchain }}" > .swift-version
- uses: swiftwasm/swiftwasm-action@v5.6
with:
shell-action: swift build
74 changes: 74 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Build and deploy DocC to GitHub pages. Based off of @karwa's work here:
# https://github.com/karwa/swift-url/blob/main/.github/workflows/docs.yml
name: Documentation

on:
release:
types:
- published
push:
branches:
- main
workflow_dispatch:

concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: macos-12
steps:
- name: Select Xcode 14.1
run: sudo xcode-select -s /Applications/Xcode_14.1.app

- name: Checkout Package
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Checkout gh-pages Branch
uses: actions/checkout@v3
with:
ref: gh-pages
path: docs-out

- name: Build documentation
run: >
rm -rf docs-out/.git;
rm -rf docs-out/main;
git tag -l --sort=-v:refname | grep -e "\d\+\.\d\+.0" | tail -n +6 | xargs -I {} rm -rf {};

for tag in $(echo "main"; git tag -l --sort=-v:refname | grep -e "\d\+\.\d\+.0" | head -6);
do
if [ -d "docs-out/$tag/data/documentation/xctestdynamicoverlay" ]
then
echo "✅ Documentation for "$tag" already exists.";
else
echo "⏳ Generating documentation for XCTestDynamicOverlay @ "$tag" release.";
rm -rf "docs-out/$tag";

git checkout .;
git checkout "$tag";

swift package \
--allow-writing-to-directory docs-out/"$tag" \
generate-documentation \
--target XCTestDynamicOverlay \
--output-path docs-out/"$tag" \
--transform-for-static-hosting \
--hosting-base-path /xctest-dynamic-overlay/"$tag" \
&& echo "✅ Documentation generated for XCTestDynamicOverlay @ "$tag" release." \
|| echo "⚠️ Documentation skipped for XCTestDynamicOverlay @ "$tag".";
fi;
done

- name: Fix permissions
run: 'sudo chown -R $USER docs-out'

- name: Publish documentation to GitHub Pages
uses: JamesIves/github-pages-deploy-action@4.1.7
with:
branch: gh-pages
folder: docs-out
single-commit: true
4 changes: 4 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- main

concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: true

jobs:
swift_format:
name: swift-format
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
/.build
/.swiftpm
/Packages
/*.xcodeproj
xcuserdata/
7 changes: 0 additions & 7 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ EXPECTED_STRING = This is expected to fail!
EXPECTED = \033[31m\"$(EXPECTED_STRING)\"\033[0m

test:
@swift test 2>&1 | grep '$(EXPECTED_STRING)' > /dev/null \
@TEST_FAILURE=true swift test 2>&1 | grep '$(EXPECTED_STRING)' > /dev/null \
&& (echo "$(PASS) $(XCT_FAIL) was called with $(EXPECTED)" && exit) \
|| (echo "$(FAIL) expected $(XCT_FAIL) to be called with $(EXPECTED)" >&2 && exit 1)

Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func testValidation() {

However, you cannot ship this code with the target that defines `AnalyticsClient`. You either need to extract it out to a test support module (which means `AnalyticsClient` must also be extracted), or the code must be confined to a test target and thus not shareable.

However, with XCTest Dynamic Overlay we can have our cake and eat it too 😋. We can define both the client type and the unimplemented instance right next to each in application code without needing to extract out needless modules or targets:
With XCTest Dynamic Overlay we can have our cake and eat it too 😋. We can define both the client type and the unimplemented instance right next to each in application code without needing to extract out needless modules or targets:

```swift
struct AnalyticsClient {
Expand Down Expand Up @@ -166,6 +166,12 @@ extension AppDependencies {

The above `placeholder` parameters can be left off, but will fatal error when the endpoint is called.

## Documentation

Full documentation can be found [here][docs].

## License

This library is released under the MIT license. See [LICENSE](LICENSE) for details.

[docs]: https://pointfreeco.github.io/xctest-dynamic-overlay/main/documentation/xctestdynamicoverlay
25 changes: 25 additions & 0 deletions Sources/XCTestDynamicOverlay/Documentation.docc/Unimplemented.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ``XCTestDynamicOverlay/unimplemented(_:fileID:line:)-5098a``

## Topics

### Failure

- ``UnimplementedFailure``

### Overloads

- ``unimplemented(_:fileID:line:)-5po3t``
- ``unimplemented(_:fileID:line:)-75xnz``
- ``unimplemented(_:fileID:line:)-8czxo``
- ``unimplemented(_:fileID:line:)-161a``
- ``unimplemented(_:fileID:line:)-6cyz2``
- ``unimplemented(_:fileID:line:)-5iwue``
- ``unimplemented(_:fileID:line:)-3dnau``
- ``unimplemented(_:fileID:line:)-2ndsd``
- ``unimplemented(_:fileID:line:)-38aet``
- ``unimplemented(_:fileID:line:)-9b7um``
- ``unimplemented(_:fileID:line:)-85v19``

### Deprecations

- ``XCTUnimplemented(_:)-3obl5``
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ``XCTestDynamicOverlay/unimplemented(_:placeholder:fileID:line:)-7jrdo``

## Topics

### Overloads

- ``unimplemented(_:placeholder:fileID:line:)-63r9c``
- ``unimplemented(_:file:fileID:line:)-7naoc``
- ``unimplemented(_:placeholder:fileID:line:)-1d7ul``
- ``unimplemented(_:file:fileID:line:)-dpc1``
- ``unimplemented(_:file:fileID:line:)-4of0j``
- ``unimplemented(_:placeholder:fileID:line:)-2l156``
- ``unimplemented(_:file:fileID:line:)-3i70x``
- ``unimplemented(_:placeholder:fileID:line:)-4l5m5``
- ``unimplemented(_:file:fileID:line:)-53i23``
- ``unimplemented(_:placeholder:fileID:line:)-29ki5``
- ``unimplemented(_:file:fileID:line:)-8k8ag``
- ``unimplemented(_:placeholder:fileID:line:)-1wuvu``
- ``unimplemented(_:file:fileID:line:)-4ac84``
- ``unimplemented(_:placeholder:fileID:line:)-5yn0z``
- ``unimplemented(_:file:fileID:line:)-25iai``
- ``unimplemented(_:placeholder:fileID:line:)-6zh67``
- ``unimplemented(_:file:fileID:line:)-kf0z``
- ``unimplemented(_:placeholder:fileID:line:)-1lxib``
- ``unimplemented(_:file:fileID:line:)-226zs``
- ``unimplemented(_:placeholder:fileID:line:)-jdwj``
- ``unimplemented(_:file:fileID:line:)-33j2q``
- ``unimplemented(_:placeholder:fileID:line:)-49o3h``
- ``unimplemented(_:file:fileID:line:)-2c0df``

### Deprecations

- ``XCTUnimplemented(_:placeholder:)-1ho66``
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
# ``XCTestDynamicOverlay/XCTUnimplemented(_:placeholder:file:line:)-l4v2``
# ``XCTestDynamicOverlay/XCTUnimplemented(_:placeholder:)-1ho66``

## Topics

### Overloads

- ``XCTUnimplemented(_:placeholder:file:line:)-4cefg``
- ``XCTUnimplemented(_:placeholder:file:line:)-50but``
- ``XCTUnimplemented(_:placeholder:file:line:)-2jqzu``
- ``XCTUnimplemented(_:placeholder:file:line:)-9mvva``
- ``XCTUnimplemented(_:placeholder:file:line:)-92nev``
- ``XCTUnimplemented(_:placeholder:file:line:)-6wlpq``
- ``XCTUnimplemented(_:placeholder:file:line:)-97hr8``
- ``XCTUnimplemented(_:placeholder:file:line:)-qhqq``
- ``XCTUnimplemented(_:placeholder:file:line:)-4akkm``
- ``XCTUnimplemented(_:placeholder:file:line:)-5i77i``
- ``XCTUnimplemented(_:placeholder:file:line:)-4xhs3``
- ``XCTUnimplemented(_:placeholder:)-2e3z9``
- ``XCTUnimplemented(_:file:line:)-3d9bq``
- ``XCTUnimplemented(_:placeholder:)-7zq1m``
- ``XCTUnimplemented(_:file:line:)-2v7cw``
- ``XCTUnimplemented(_:file:line:)-5k1u``
- ``XCTUnimplemented(_:placeholder:)-f6km``
- ``XCTUnimplemented(_:file:line:)-9nzey``
- ``XCTUnimplemented(_:placeholder:)-55i4t``
- ``XCTUnimplemented(_:file:line:)-3okct``
- ``XCTUnimplemented(_:placeholder:)-8sn8``
- ``XCTUnimplemented(_:file:line:)-s7bl``
- ``XCTUnimplemented(_:placeholder:)-1nulk``
- ``XCTUnimplemented(_:file:line:)-1x268``
- ``XCTUnimplemented(_:placeholder:)-mbpz``
- ``XCTUnimplemented(_:file:line:)-6qpy4``
- ``XCTUnimplemented(_:placeholder:)-437q7``
- ``XCTUnimplemented(_:file:line:)-8c1gm``
- ``XCTUnimplemented(_:placeholder:)-k1by``
- ``XCTUnimplemented(_:file:line:)-63m0r``
- ``XCTUnimplemented(_:placeholder:)-r87l``
- ``XCTUnimplemented(_:file:line:)-4njow``
- ``XCTUnimplemented(_:placeholder:)-6e4ct``
- ``XCTUnimplemented(_:file:line:)-8w02g``
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ XCTest Dynamic Overlay provides APIs for invoking XCTest's `XCTFail` directly in

### Unimplemented Dependencies

- ``XCTUnimplemented(_:placeholder:file:line:)-l4v2``
- ``XCTUnimplemented(_:)-3obl5``
- ``unimplemented(_:placeholder:fileID:line:)-7jrdo``
- ``unimplemented(_:fileID:line:)-5098a``
44 changes: 44 additions & 0 deletions Sources/XCTestDynamicOverlay/Internal/DefaultInitializable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
protocol _DefaultInitializable {
init()
}

extension Array: _DefaultInitializable {}
extension Bool: _DefaultInitializable {}
extension Character: _DefaultInitializable { init() { self.init(" ") } }
extension Dictionary: _DefaultInitializable {}
extension Double: _DefaultInitializable {}
extension Float: _DefaultInitializable {}
extension Int: _DefaultInitializable {}
extension Int8: _DefaultInitializable {}
extension Int16: _DefaultInitializable {}
extension Int32: _DefaultInitializable {}
extension Int64: _DefaultInitializable {}
extension Set: _DefaultInitializable {}
extension String: _DefaultInitializable {}
extension Substring: _DefaultInitializable {}
extension UInt: _DefaultInitializable {}
extension UInt8: _DefaultInitializable {}
extension UInt16: _DefaultInitializable {}
extension UInt32: _DefaultInitializable {}
extension UInt64: _DefaultInitializable {}

extension AsyncStream: _DefaultInitializable {
init() { self.init { $0.finish() } }
}

extension AsyncThrowingStream: _DefaultInitializable where Failure == Error {
init() { self.init { $0.finish(throwing: CancellationError()) } }
}

#if canImport(Foundation)
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

extension Data: _DefaultInitializable {}
extension Date: _DefaultInitializable {}
extension Decimal: _DefaultInitializable {}
extension UUID: _DefaultInitializable {}
extension URL: _DefaultInitializable { init() { self.init(string: "/")! } }
#endif
Loading