Skip to content

Commit 8feeeb2

Browse files
authored
Merge pull request #124 from unsignedapps/swift-testing
Adopt swift-testing
2 parents 85175ff + cd0bb12 commit 8feeeb2

30 files changed

+1437
-1233
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: macos-latest
1818
steps:
1919
- name: 🛒 Checkout
20-
uses: actions/checkout@v2
20+
uses: actions/checkout@v4
2121

2222
- name: 👷 Build Website
2323
run: .github/scripts/generate-docs.sh

.github/workflows/documentation-coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: 🛒 Checkout
24-
uses: actions/checkout@v2
24+
uses: actions/checkout@v4
2525

2626
- name: 🧱 Install dependencies
2727
run: sudo apt-get install -y jq

.github/workflows/ios-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
changed: ${{ steps.filter.outputs.changed }}
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1818
- uses: dorny/paths-filter@v2
1919
id: filter
2020
with:
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Checkout
41-
uses: actions/checkout@v2
41+
uses: actions/checkout@v4
4242
- name: Build and Test
4343
run: |
4444
set -o pipefail && \

.github/workflows/linux-tests.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
changed: ${{ steps.filter.outputs.changed }}
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1818
- uses: dorny/paths-filter@v2
1919
id: filter
2020
with:
@@ -35,10 +35,8 @@ jobs:
3535
strategy:
3636
matrix:
3737
swift: [ "swift:5.10.1", "swiftlang/swift:nightly-6.0" ]
38-
os: [ amazonlinux2, bookworm, focal, jammy, rhel-ubi9, mantic, noble ]
38+
os: [ amazonlinux2, focal, jammy, rhel-ubi9, mantic, noble ]
3939
exclude:
40-
- swift: "swiftlang/swift:nightly-6.0"
41-
os: "bookworm"
4240
- swift: "swiftlang/swift:nightly-6.0"
4341
os: "mantic"
4442
- swift: "swiftlang/swift:nightly-6.0"

.github/workflows/macos-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
changed: ${{ steps.filter.outputs.changed }}
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1818
- uses: dorny/paths-filter@v2
1919
id: filter
2020
with:
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Checkout
41-
uses: actions/checkout@v2
41+
uses: actions/checkout@v4
4242
- name: Build and Test
4343
run: |
4444
set -o pipefail && \

.github/workflows/tvos-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
changed: ${{ steps.filter.outputs.changed }}
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1818
- uses: dorny/paths-filter@v2
1919
id: filter
2020
with:
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Checkout
41-
uses: actions/checkout@v2
41+
uses: actions/checkout@v4
4242
- name: Build and Test
4343
run: |
4444
set -o pipefail && \

.github/workflows/visionos-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
changed: ${{ steps.filter.outputs.changed }}
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1818
- uses: dorny/paths-filter@v2
1919
id: filter
2020
with:
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Checkout
41-
uses: actions/checkout@v2
41+
uses: actions/checkout@v4
4242
- name: Build and Test
4343
run: |
4444
set -o pipefail && \

.github/workflows/watchos-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
changed: ${{ steps.filter.outputs.changed }}
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1818
- uses: dorny/paths-filter@v2
1919
id: filter
2020
with:
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Checkout
41-
uses: actions/checkout@v2
41+
uses: actions/checkout@v4
4242
- name: Build and Test
4343
run: |
4444
set -o pipefail && \

.github/workflows/website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: macos-11.0
1919
steps:
2020
- name: 🛒 Checkout
21-
uses: actions/checkout@v2
21+
uses: actions/checkout@v4
2222

2323
- name: 👷 Build Website
2424
run: .github/scripts/generate-docs.sh

Package.swift

Lines changed: 106 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -20,82 +20,119 @@ let package = Package(
2020
// .library(name: "Vexillographer", targets: [ "Vexillographer" ]),
2121
],
2222

23-
dependencies: [
24-
.package(url: "https://github.com/apple/swift-async-algorithms.git", from: "1.0.0"),
25-
.package(url: "https://github.com/nicklockwood/SwiftFormat.git", from: "0.54.1"),
26-
.package(url: "https://github.com/apple/swift-syntax.git", exact: "600.0.0-prerelease-2024-06-12"),
27-
],
23+
dependencies: .init {
24+
Package.Dependency.package(url: "https://github.com/apple/swift-async-algorithms.git", from: "1.0.0")
25+
Package.Dependency.package(url: "https://github.com/nicklockwood/SwiftFormat.git", from: "0.54.1")
26+
Package.Dependency.package(url: "https://github.com/swiftlang/swift-syntax.git", exact: "600.0.0-prerelease-2024-06-12")
27+
28+
#if os(Linux)
29+
// Linux does not come bundled with swift-testing
30+
Package.Dependency.package(url: "https://github.com/apple/swift-testing.git", exact: "0.11.0")
31+
#endif
32+
33+
},
34+
35+
targets: .init {
36+
37+
// Vexil
38+
39+
Target.target(
40+
name: "Vexil",
41+
dependencies: [
42+
.target(name: "VexilMacros"),
43+
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
44+
],
45+
swiftSettings: [
46+
.enableExperimentalFeature("StrictConcurrency"),
47+
]
48+
)
49+
Target.testTarget(
50+
name: "VexilTests",
51+
dependencies: .init {
52+
Target.Dependency.target(name: "Vexil")
53+
54+
#if os(Linux)
55+
// Linux does not come bundled with swift-testing
56+
Target.Dependency.product(name: "Testing", package: "swift-testing")
57+
#endif
2858

29-
targets: {
30-
var targets: [Target] = [
31-
32-
// Vexil
33-
34-
.target(
35-
name: "Vexil",
36-
dependencies: [
37-
.target(name: "VexilMacros"),
38-
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
39-
],
40-
swiftSettings: [
41-
.enableExperimentalFeature("StrictConcurrency"),
42-
]
43-
),
44-
.testTarget(
45-
name: "VexilTests",
46-
dependencies: [
47-
.target(name: "Vexil"),
48-
],
49-
swiftSettings: [
50-
.enableExperimentalFeature("StrictConcurrency"),
51-
]
52-
),
53-
54-
// Vexillographer
55-
56-
// .target(
57-
// name: "Vexillographer",
58-
// dependencies: [
59-
// .target(name: "Vexil"),
60-
// ]
61-
// ),
62-
63-
// Macros
64-
65-
.macro(
66-
name: "VexilMacros",
67-
dependencies: [
68-
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
69-
.product(name: "SwiftSyntax", package: "swift-syntax"),
70-
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
71-
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
72-
],
73-
swiftSettings: [
74-
.enableExperimentalFeature("StrictConcurrency"),
75-
]
76-
),
77-
78-
]
59+
},
60+
swiftSettings: [
61+
.enableExperimentalFeature("StrictConcurrency"),
62+
]
63+
)
64+
65+
// Vexillographer
66+
67+
// Target.target(
68+
// name: "Vexillographer",
69+
// dependencies: [
70+
// .target(name: "Vexil"),
71+
// ]
72+
// ),
73+
74+
// Macros
75+
76+
Target.macro(
77+
name: "VexilMacros",
78+
dependencies: [
79+
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
80+
.product(name: "SwiftSyntax", package: "swift-syntax"),
81+
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
82+
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
83+
],
84+
swiftSettings: [
85+
.enableExperimentalFeature("StrictConcurrency"),
86+
]
87+
)
7988

8089
#if !os(Linux)
81-
targets += [
82-
.testTarget(
83-
name: "VexilMacroTests",
84-
dependencies: [
85-
.target(name: "VexilMacros"),
86-
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
87-
],
88-
swiftSettings: [
89-
.enableExperimentalFeature("StrictConcurrency"),
90-
]
91-
),
92-
]
90+
91+
// We can't disable macro validation using `swift test` so these are guaranteed to fail on Linux
92+
Target.testTarget(
93+
name: "VexilMacroTests",
94+
dependencies: [
95+
.target(name: "VexilMacros"),
96+
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
97+
],
98+
swiftSettings: [
99+
.enableExperimentalFeature("StrictConcurrency"),
100+
]
101+
)
102+
93103
#endif
94104

95-
return targets
96-
}(),
105+
},
97106

98107
swiftLanguageVersions: [
99108
.v6,
100109
]
110+
101111
)
112+
113+
// MARK: - Helpers
114+
115+
@resultBuilder
116+
enum CollectionBuilder<Element> {
117+
118+
typealias Component = [Element]
119+
120+
static func buildExpression(_ expression: Element) -> Component {
121+
[expression]
122+
}
123+
124+
static func buildBlock(_ components: Component...) -> Component {
125+
components.flatMap { $0 }
126+
}
127+
128+
static func buildLimitedAvailability(_ components: [Element]) -> Component {
129+
components
130+
}
131+
132+
}
133+
134+
extension Array {
135+
init(@CollectionBuilder<Element> collecting: () -> [Element]) {
136+
self = collecting()
137+
}
138+
}

0 commit comments

Comments
 (0)