Skip to content

Commit f3625a8

Browse files
committed
Attempt solution at a custom XFail for XCTest..
1 parent 2d64529 commit f3625a8

File tree

3 files changed

+100
-24
lines changed

3 files changed

+100
-24
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,38 @@
11
import SPMBuildCore
22
import XCTest
33

4+
public struct XFailCaseName {
5+
let testName: String
6+
let reason: String
7+
8+
public init(_ testName: String, because reason: String) {
9+
self.testName = testName
10+
self.reason = reason
11+
}
12+
}
413
open class BuildSystemProviderTestCase: XCTestCase {
514
open var buildSystemProvider: BuildSystemProvider.Kind {
615
fatalError("\(self) does not implement \(#function)")
716
}
17+
18+
open var xFailTestCaseNames: [XFailCaseName] {
19+
return []
20+
}
21+
22+
override open func recordFailure(withDescription description: String, inFile filePath: String, atLine lineNumber: Int, expected: Bool) {
23+
// Get current test name:
24+
print("--->> In recordFailure: Test name is >>>\(self.name)<<<")
25+
26+
if self.xFailTestCaseNames.map({ item in item.testName }).contains(self.name) {
27+
// do nothing
28+
print("--->> In recordFailure: Test name is >>>\(self.name)<<< is expected to fail, so mark as passed!!")
29+
} else {
30+
super.recordFailure(
31+
withDescription: description,
32+
inFile: filePath,
33+
atLine: lineNumber,
34+
expected: expected
35+
)
36+
}
37+
}
838
}

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6880,17 +6880,34 @@ class BuildPlanSwiftBuildTests: BuildPlanTestCase {
68806880
return .swiftbuild
68816881
}
68826882

6883+
override open var xFailTestCaseNames: [XFailCaseName] {
6884+
return [
6885+
XFailCaseName(
6886+
String(describing: testDuplicateProductNamesWithNonDefaultLibsThrowError.self),
6887+
because: "This test is not expected to fail.. it should pass.",
6888+
),
6889+
XFailCaseName(
6890+
String(describing: testTargetsWithPackageAccess.self),
6891+
because: "Skip until swift build system can support this case",
6892+
),
6893+
// XFailCaseName(
6894+
// String(describing: testTestModule.self),
6895+
// because: "Skip until swift build system can support this case."
6896+
// )
6897+
]
6898+
}
6899+
68836900
override func testDuplicateProductNamesWithNonDefaultLibsThrowError() async throws {
68846901
try await super.testDuplicateProductNamesWithNonDefaultLibsThrowError()
68856902
}
68866903

6887-
override func testTargetsWithPackageAccess() async throws {
6888-
throw XCTSkip("Skip until swift build system can support this case.")
6889-
}
6904+
// override func testTargetsWithPackageAccess() async throws {
6905+
// throw XCTSkip("Skip until swift build system can support this case.")
6906+
// }
68906907

6891-
override func testTestModule() async throws {
6892-
throw XCTSkip("Skip until swift build system can support this case.")
6893-
}
6908+
// override func testTestModule() async throws {
6909+
// throw XCTSkip("Skip until swift build system can support this case.")
6910+
// }
68946911

68956912
override func testPackageNameFlag() async throws {
68966913
#if os(Windows)

Tests/CommandsTests/RunCommandTests.swift

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import XCTest
1919

2020
import class Basics.AsyncProcess
2121

22-
class RunCommandTestCase: BuildSystemProviderTestCase {
22+
class RunCommandTestCase: CommandsBuildProviderTestCase {
2323
override func setUpWithError() throws {
2424
try XCTSkipIf(type(of: self) == RunCommandTestCase.self, "Pay no attention to the class behind the curtain.")
2525
}
@@ -291,28 +291,57 @@ class RunCommandSwiftBuildTests: RunCommandTestCase {
291291
try await super.testUsage()
292292
}
293293

294-
override func testMultipleExecutableAndExplicitExecutable() async throws {
295-
try XCTSkip("https://github.com/swiftlang/swift-package-manager/issues/8279: Swift run using Swift Build does not output executable content to the terminal")
294+
override open var xFailTestCaseNames: [XFailCaseName] {
295+
return [
296+
XFailCaseName(
297+
String(describing: testMultipleExecutableAndExplicitExecutable.self),
298+
because: "https://github.com/swiftlang/swift-package-manager/issues/8279: Swift run using Swift Build does not output executable content to the terminal",
299+
),
300+
XFailCaseName(
301+
String(describing: testUnknownProductAndArgumentPassing.self),
302+
because: "https://github.com/swiftlang/swift-package-manager/issues/8279: Swift run using Swift Build does not output executable content to the terminal",
303+
),
304+
XFailCaseName(
305+
String(describing: testPackageWithExcutableTargetsContainsPlatformConditionalsBuildsSuccessfullyInDebugConfig.self),
306+
because: "Test fixture fails to build",
307+
),
308+
XFailCaseName(
309+
String(describing: testPackageWithExcutableTargetsContainsPlatformConditionalsBuildsSuccessfullyInReleaseConfig.self),
310+
because: "Test fixture fails to build",
311+
),
312+
XFailCaseName(
313+
String(describing: testToolsetDebugger.self),
314+
because: "Test fixture fails to build",
315+
),
316+
XFailCaseName(
317+
String(describing: testUnreachableExecutable.self),
318+
because: "Need to investigate test failure",
319+
),
320+
]
296321
}
297322

298-
override func testUnknownProductAndArgumentPassing() async throws {
299-
try XCTSkip("https://github.com/swiftlang/swift-package-manager/issues/8279: Swift run using Swift Build does not output executable content to the terminal")
300-
}
323+
// override func testMultipleExecutableAndExplicitExecutable() async throws {
324+
// try XCTSkip("https://github.com/swiftlang/swift-package-manager/issues/8279: Swift run using Swift Build does not output executable content to the terminal")
325+
// }
301326

302-
override func testPackageWithExcutableTargetsContainsPlatformConditionalsBuildsSuccessfullyInDebugConfig() async throws {
303-
try XCTSkip("Test fixture fails to build")
304-
}
327+
// override func testUnknownProductAndArgumentPassing() async throws {
328+
// try XCTSkip("https://github.com/swiftlang/swift-package-manager/issues/8279: Swift run using Swift Build does not output executable content to the terminal")
329+
// }
305330

306-
override func testPackageWithExcutableTargetsContainsPlatformConditionalsBuildsSuccessfullyInReleaseConfig() async throws {
307-
try XCTSkip("Test fixture fails to build")
308-
}
331+
// override func testPackageWithExcutableTargetsContainsPlatformConditionalsBuildsSuccessfullyInDebugConfig() async throws {
332+
// try XCTSkip("Test fixture fails to build")
333+
// }
309334

310-
override func testToolsetDebugger() async throws {
311-
try XCTSkip("Test fixture fails to build")
312-
}
335+
// override func testPackageWithExcutableTargetsContainsPlatformConditionalsBuildsSuccessfullyInReleaseConfig() async throws {
336+
// try XCTSkip("Test fixture fails to build")
337+
// }
313338

314-
override func testUnreachableExecutable() async throws {
315-
try XCTSkip("Need to investigate test failure")
316-
}
339+
// override func testToolsetDebugger() async throws {
340+
// try XCTSkip("Test fixture fails to build")
341+
// }
342+
343+
// override func testUnreachableExecutable() async throws {
344+
// try XCTSkip("Need to investigate test failure")
345+
// }
317346

318347
}

0 commit comments

Comments
 (0)