Skip to content

Commit c671f3f

Browse files
committed
Tests: Convert Run Command Tests to Swift Testing
Convert the Run Command Tests to Swift Testing. Make use of parameterized tests to reduce duplication and use withKnownIssue to get signal when tests have been fixed.
1 parent 92c1ec5 commit c671f3f

File tree

5 files changed

+311
-235
lines changed

5 files changed

+311
-235
lines changed

IntegrationTests/Sources/IntegrationTestSupport/Helpers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public let swiftTest: AbsolutePath = swiftpmBinaryDirectory.appending(component:
123123

124124
public let swiftRun: AbsolutePath = swiftpmBinaryDirectory.appending(component: "swift-run")
125125

126-
public let isSelfHosted: Bool = {
126+
public let runningInSelfHostedPipeline: Bool = {
127127
ProcessInfo.processInfo.environment["SWIFTCI_IS_SELF_HOSTED"] != nil
128128
}()
129129

Sources/_InternalTestSupport/XCTAssertHelpers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public func XCTAssertEqual<T:Equatable, U:Equatable> (_ lhs:(T,U), _ rhs:(T,U),
4848

4949
public func XCTSkipIfPlatformCI(because reason: String? = nil, file: StaticString = #filePath, line: UInt = #line) throws {
5050
// TODO: is this actually the right variable now?
51-
if isInCiEnvironment {
51+
if CiEnvironment.runningInSmokeTestPipeline {
5252
let failureCause = reason ?? "Skipping because the test is being run on CI"
5353
throw XCTSkip(failureCause, file: file, line: line)
5454
}

Sources/_InternalTestSupport/misc.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ public let isRealSigningIdentitTestDefined = {
6363
#endif
6464
}()
6565

66+
public let duplicateSymbolRegex: Regex<AnyRegexOutput>? = {
67+
do {
68+
return try Regex(".*One of the duplicates must be removed or renamed.")
69+
} catch {
70+
return nil
71+
}
72+
}()
73+
6674
/// Test helper utility for executing a block with a temporary directory.
6775
public func testWithTemporaryDirectory(
6876
function: StaticString = #function,

Tests/CommandsTests/BuildCommandTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ struct BuildCommandTestCases {
193193
arguments: SupportedBuildSystemOnPlatform,
194194
)
195195
func commandDoesNotEmitDuplicateSymbols(buildSystem: BuildSystemProvider.Kind) async throws {
196-
let duplicateSymbolRegex = try Regex(".*One of the duplicates must be removed or renamed.")
196+
let duplicateSymbolRegex = try #require(duplicateSymbolRegex)
197197
let (stdout, stderr) = try await execute(["--help"], buildSystem: buildSystem)
198198
#expect(!stdout.contains(duplicateSymbolRegex))
199199
#expect(!stderr.contains(duplicateSymbolRegex))

0 commit comments

Comments
 (0)