Skip to content

Commit 162016a

Browse files
committed
Add tests coverage for new tag: prefix behavior for both --filter and --skip
1 parent 753e7c5 commit 162016a

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Tests/TestingTests/SwiftPMTests.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ private func configurationForEntryPoint(withArguments args: [String]) throws ->
2020
return try configurationForEntryPoint(from: args)
2121
}
2222

23+
private extension Tag {
24+
@Tag static var testTag: Self
25+
}
26+
2327
/// Reads event stream output from the provided file matching event stream
2428
/// version `V`.
2529
private func decodedEventStreamRecords<V: ABI.Version>(fromPath filePath: String) throws -> [ABI.Record<V>] {
@@ -116,6 +120,18 @@ struct SwiftPMTests {
116120
#expect(!planTests.contains(test2))
117121
}
118122

123+
124+
@Test("--filter argument with tag: prefix")
125+
func filterByTag() async throws {
126+
let configuration = try configurationForEntryPoint(withArguments: ["PATH", "--filter", "tag:testTag"])
127+
let test1 = Test(.tags(.testTag), name: "hello") {}
128+
let test2 = Test(name: "goodbye") {}
129+
let plan = await Runner.Plan(tests: [test1, test2], configuration: configuration)
130+
let planTests = plan.steps.map(\.test)
131+
#expect(planTests.contains(test1))
132+
#expect(!planTests.contains(test2))
133+
}
134+
119135
@Test("Multiple --filter arguments")
120136
func multipleFilter() async throws {
121137
let configuration = try configurationForEntryPoint(withArguments: ["PATH", "--filter", "hello", "--filter", "sorry"])
@@ -159,6 +175,17 @@ struct SwiftPMTests {
159175
#expect(planTests.contains(test2))
160176
}
161177

178+
@Test("--skip argument with tag: prefix")
179+
func skipByTag() async throws {
180+
let configuration = try configurationForEntryPoint(withArguments: ["PATH", "--skip", "tag:testTag"])
181+
let test1 = Test(.tags(.testTag), name: "hello") {}
182+
let test2 = Test(name: "goodbye") {}
183+
let plan = await Runner.Plan(tests: [test1, test2], configuration: configuration)
184+
let planTests = plan.steps.map(\.test)
185+
#expect(!planTests.contains(test1))
186+
#expect(planTests.contains(test2))
187+
}
188+
162189
@Test("--filter or --skip argument as last argument")
163190
func filterOrSkipAsLast() async throws {
164191
_ = try configurationForEntryPoint(withArguments: ["PATH", "--filter"])

0 commit comments

Comments
 (0)