Skip to content

Commit 9547011

Browse files
committed
Attempt solution at a custom XFail for XCTest..
1 parent 95ef5ff commit 9547011

File tree

3 files changed

+100
-24
lines changed

3 files changed

+100
-24
lines changed
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

+23-6
Original file line numberDiff line numberDiff line change
@@ -6886,17 +6886,34 @@ class BuildPlanSwiftBuildTests: BuildPlanTestCase {
68866886
return .swiftbuild
68876887
}
68886888

6889+
override open var xFailTestCaseNames: [XFailCaseName] {
6890+
return [
6891+
XFailCaseName(
6892+
String(describing: testDuplicateProductNamesWithNonDefaultLibsThrowError.self),
6893+
because: "This test is not expected to fail.. it should pass.",
6894+
),
6895+
XFailCaseName(
6896+
String(describing: testTargetsWithPackageAccess.self),
6897+
because: "Skip until swift build system can support this case",
6898+
),
6899+
// XFailCaseName(
6900+
// String(describing: testTestModule.self),
6901+
// because: "Skip until swift build system can support this case."
6902+
// )
6903+
]
6904+
}
6905+
68896906
override func testDuplicateProductNamesWithNonDefaultLibsThrowError() async throws {
68906907
try await super.testDuplicateProductNamesWithNonDefaultLibsThrowError()
68916908
}
68926909

6893-
override func testTargetsWithPackageAccess() async throws {
6894-
throw XCTSkip("Skip until swift build system can support this case.")
6895-
}
6910+
// override func testTargetsWithPackageAccess() async throws {
6911+
// throw XCTSkip("Skip until swift build system can support this case.")
6912+
// }
68966913

6897-
override func testTestModule() async throws {
6898-
throw XCTSkip("Skip until swift build system can support this case.")
6899-
}
6914+
// override func testTestModule() async throws {
6915+
// throw XCTSkip("Skip until swift build system can support this case.")
6916+
// }
69006917

69016918
override func testPackageNameFlag() async throws {
69026919
#if os(Windows)

Tests/CommandsTests/RunCommandTests.swift

+47-18
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
}
@@ -285,28 +285,57 @@ class RunCommandSwiftBuildTests: RunCommandTestCase {
285285
try await super.testUsage()
286286
}
287287

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

292-
override func testUnknownProductAndArgumentPassing() async throws {
293-
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-
}
317+
// override func testMultipleExecutableAndExplicitExecutable() async throws {
318+
// try XCTSkip("https://github.com/swiftlang/swift-package-manager/issues/8279: Swift run using Swift Build does not output executable content to the terminal")
319+
// }
295320

296-
override func testPackageWithExcutableTargetsContainsPlatformConditionalsBuildsSuccessfullyInDebugConfig() async throws {
297-
try XCTSkip("Test fixture fails to build")
298-
}
321+
// override func testUnknownProductAndArgumentPassing() async throws {
322+
// try XCTSkip("https://github.com/swiftlang/swift-package-manager/issues/8279: Swift run using Swift Build does not output executable content to the terminal")
323+
// }
299324

300-
override func testPackageWithExcutableTargetsContainsPlatformConditionalsBuildsSuccessfullyInReleaseConfig() async throws {
301-
try XCTSkip("Test fixture fails to build")
302-
}
325+
// override func testPackageWithExcutableTargetsContainsPlatformConditionalsBuildsSuccessfullyInDebugConfig() async throws {
326+
// try XCTSkip("Test fixture fails to build")
327+
// }
303328

304-
override func testToolsetDebugger() async throws {
305-
try XCTSkip("Test fixture fails to build")
306-
}
329+
// override func testPackageWithExcutableTargetsContainsPlatformConditionalsBuildsSuccessfullyInReleaseConfig() async throws {
330+
// try XCTSkip("Test fixture fails to build")
331+
// }
307332

308-
override func testUnreachableExecutable() async throws {
309-
try XCTSkip("Need to investigate test failure")
310-
}
333+
// override func testToolsetDebugger() async throws {
334+
// try XCTSkip("Test fixture fails to build")
335+
// }
336+
337+
// override func testUnreachableExecutable() async throws {
338+
// try XCTSkip("Need to investigate test failure")
339+
// }
311340

312341
}

0 commit comments

Comments
 (0)