Skip to content

Commit 928132e

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 c5a35c3 commit 928132e

File tree

5 files changed

+299
-236
lines changed

5 files changed

+299
-236
lines changed

Sources/_InternalTestSupport/XCTAssertHelpers.swift

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

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

Sources/_InternalTestSupport/misc.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import enum TSCUtility.Git
3939
@_exported import func TSCTestSupport.systemQuietly
4040
@_exported import enum TSCTestSupport.StringPattern
4141

42-
public let isInCiEnvironment = ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] != nil
42+
public let isInPlatformCiEnvironment = ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] != nil
4343
public let isSelfHostedCiEnvironment = ProcessInfo.processInfo.environment["SWIFTCI_IS_SELF_HOSTED"] != nil
4444

4545
public let isRealSigningIdentyEcLabelEnvVarSet =
@@ -53,6 +53,14 @@ public let isRealSigningIdentitTestDefined = {
5353
#endif
5454
}()
5555

56+
public let duplicateSymbolRegex: Regex<AnyRegexOutput>? = {
57+
do {
58+
return try Regex(".*One of the duplicates must be removed or renamed.")
59+
} catch {
60+
return nil
61+
}
62+
}()
63+
5664
/// Test helper utility for executing a block with a temporary directory.
5765
public func testWithTemporaryDirectory(
5866
function: StaticString = #function,

Tests/BasicsTests/Environment/EnvironmentTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ struct EnvironmentTests {
147147

148148
/// Important: This test is inherently race-prone, if it is proven to be
149149
/// flaky, it should run in a singled threaded environment/removed entirely.
150-
@Test(.disabled(if: isInCiEnvironment, "This test can disrupt other tests running in parallel."))
150+
@Test(.disabled(if: isInPlatformCiEnvironment, "This test can disrupt other tests running in parallel."))
151151
func makeCustomPathEnv() async throws {
152152
let customEnvironment: Environment = .current
153153
let origPath = customEnvironment[.path]

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)