Skip to content

Commit aa454fb

Browse files
committed
Tests: Augment SwiftBuild build provider test coverage
Augment some test to run against the native and swiftbuild build providers to gain extra confidence with the swift build integration.
1 parent e952244 commit aa454fb

10 files changed

+171
-70
lines changed

Sources/_InternalTestSupport/XCTAssertHelpers.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public func XCTSkipIfCI(file: StaticString = #filePath, line: UInt = #line) thro
5050
}
5151
}
5252

53+
public func XCTSkipSwiftBuildTodo(because reason: String) throws {
54+
throw XCTSkip("SWBINTTODO: \(reason)")
55+
}
56+
5357
/// An `async`-friendly replacement for `XCTAssertThrowsError`.
5458
public func XCTAssertAsyncThrowsError<T>(
5559
_ expression: @autoclosure () async throws -> T,

Tests/CommandsTests/BuildCommandTests.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ class BuildCommandSwiftBuildTests: BuildCommandTestCases {
855855
}
856856

857857
override func testNonReachableProductsAndTargetsFunctional() async throws {
858-
throw XCTSkip("SWBINTTODO: Test failed. This needs to be investigated")
858+
try XCTSkipSwiftBuildTodo(because: "Test failed. This needs to be investigated")
859859
}
860860

861861
override func testParseableInterfaces() async throws {
@@ -877,7 +877,7 @@ class BuildCommandSwiftBuildTests: BuildCommandTestCases {
877877
}
878878

879879
override func testAutomaticParseableInterfacesWithLibraryEvolution() async throws {
880-
throw XCTSkip("SWBINTTODO: Test failed because of missing 'A.swiftmodule/*.swiftinterface' files")
880+
try XCTSkipSwiftBuildTodo(because: "Test failed because of missing 'A.swiftmodule/*.swiftinterface' files")
881881
// TODO: We still need to override this test just like we did for `testParseableInterfaces` above.
882882
}
883883

@@ -896,50 +896,50 @@ class BuildCommandSwiftBuildTests: BuildCommandTestCases {
896896
}
897897

898898
override func testGetTaskAllowEntitlement() async throws {
899-
throw XCTSkip("SWBINTTODO: Test failed because swiftbuild doesn't output precis codesign commands. Once swift run works with swiftbuild the test can be investigated.")
899+
try XCTSkipSwiftBuildTodo(because: "Test failed because swiftbuild doesn't output precis codesign commands. Once swift run works with swiftbuild the test can be investigated.")
900900
}
901901

902902
override func testCodeCoverage() async throws {
903-
throw XCTSkip("SWBINTTODO: Test failed because of missing plugin support in the PIF builder. This can be reinvestigated after the support is there.")
903+
try XCTSkipSwiftBuildTodo(because: "Test failed because of missing plugin support in the PIF builder. This can be reinvestigated after the support is there.")
904904
}
905905

906906
override func testAtMainSupport() async throws {
907907
#if !os(macOS)
908-
throw XCTSkip("SWBINTTODO: File not found or missing libclang errors on non-macOS platforms. This needs to be investigated")
908+
try XCTSkipSwiftBuildTodo(because: "File not found or missing libclang errors on non-macOS platforms. This needs to be investigated")
909909
#else
910910
try await super.testAtMainSupport()
911911
#endif
912912
}
913913

914914
override func testImportOfMissedDepWarning() async throws {
915-
throw XCTSkip("SWBINTTODO: Test fails because the warning message regarding missing imports is expected to be more verbose and actionable at the SwiftPM level with mention of the involved targets. This needs to be investigated. See case targetDiagnostic(TargetDiagnosticInfo) as a message type that may help.")
915+
try XCTSkipSwiftBuildTodo(because: "Test fails because the warning message regarding missing imports is expected to be more verbose and actionable at the SwiftPM level with mention of the involved targets. This needs to be investigated. See case targetDiagnostic(TargetDiagnosticInfo) as a message type that may help.")
916916
}
917917

918918
override func testProductAndTarget() async throws {
919-
throw XCTSkip("SWBINTTODO: Test fails because there isn't a clear warning message about the lib1 being an automatic product and that the default product is being built instead. This needs to be investigated")
919+
try XCTSkipSwiftBuildTodo(because: "Test fails because there isn't a clear warning message about the lib1 being an automatic product and that the default product is being built instead. This needs to be investigated")
920920
}
921921

922922
override func testSwiftGetVersion() async throws {
923-
throw XCTSkip("SWBINTTODO: Test fails because the dummy-swiftc used in the test isn't accepted by swift-build. This needs to be investigated")
923+
try XCTSkipSwiftBuildTodo(because: "Test fails because the dummy-swiftc used in the test isn't accepted by swift-build. This needs to be investigated")
924924
}
925925

926926
override func testSymlink() async throws {
927-
throw XCTSkip("SWBINTTODO: Test fails because of a difference in the build layout. This needs to be updated to the expected path")
927+
try XCTSkipSwiftBuildTodo(because: "Test fails because of a difference in the build layout. This needs to be updated to the expected path")
928928
}
929929

930930
#if !canImport(Darwin)
931931
override func testIgnoresLinuxMain() async throws {
932-
throw XCTSkip("SWBINTTODO: Swift build doesn't currently ignore Linux main when linking on Linux. This needs further investigation.")
932+
try XCTSkipSwiftBuildTodo(because: "Swift build doesn't currently ignore Linux main when linking on Linux. This needs further investigation.")
933933
}
934934
#endif
935935

936936
#if !os(macOS)
937937
override func testBuildStartMessage() async throws {
938-
throw XCTSkip("SWBINTTODO: Swift build produces an error building the fixture for this test.")
938+
try XCTSkipSwiftBuildTodo(because: "Swift build produces an error building the fixture for this test.")
939939
}
940940

941941
override func testSwiftDriverRawOutputGetsNewlines() async throws {
942-
throw XCTSkip("SWBINTTODO: Swift build produces an error building the fixture for this test.")
942+
try XCTSkipSwiftBuildTodo(because: "Swift build produces an error building the fixture for this test.")
943943
}
944944
#endif
945945

@@ -959,7 +959,7 @@ class BuildCommandSwiftBuildTests: BuildCommandTestCases {
959959

960960
override func testBuildCompleteMessage() async throws {
961961
#if os(Linux)
962-
throw XCTSkip("SWBINTTODO: Need to properly set LD_LIBRARY_PATH on linux")
962+
try XCTSkipSwiftBuildTodo(because: "Need to properly set LD_LIBRARY_PATH on linux")
963963
#else
964964
try await super.testBuildCompleteMessage()
965965
#endif

Tests/CommandsTests/MultiRootSupportTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import _InternalTestSupport
1616
import Workspace
1717
import XCTest
1818

19-
final class MultiRootSupportTests: CommandsTestCase {
19+
final class MultiRootSupportTests: XCTestCase {
2020
func testWorkspaceLoader() throws {
2121
let fs = InMemoryFileSystem(emptyFiles: [
2222
"/tmp/test/dep/Package.swift",

Tests/CommandsTests/PackageCommandTests.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
13851385

13861386
func testPackageClean() async throws {
13871387
try await fixture(name: "DependencyResolution/External/Simple") { fixturePath in
1388-
let packageRoot = fixturePath.appending("Bar")
1388+
let packageRoot: AbsolutePath = fixturePath.appending("Bar")
13891389

13901390
// Build it.
13911391
await XCTAssertBuilds(packageRoot)
@@ -1397,6 +1397,8 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
13971397
// Clean, and check for removal of the build directory but not Packages.
13981398
_ = try await execute(["clean"], packagePath: packageRoot)
13991399
XCTAssertNoSuchPath(binFile)
1400+
XCTAssertFalse(try localFileSystem.getDirectoryContents(buildPath.appending("repositories")).isEmpty)
1401+
14001402
// Clean again to ensure we get no error.
14011403
_ = try await execute(["clean"], packagePath: packageRoot)
14021404
}
@@ -1412,15 +1414,10 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
14121414
let binFile = buildPath.appending(components: try UserToolchain.default.targetTriple.platformBuildPathComponent, "debug", "Bar")
14131415
XCTAssertFileExists(binFile)
14141416
XCTAssert(localFileSystem.isDirectory(buildPath))
1415-
// Clean, and check for removal of the build directory but not Packages.
1416-
1417-
_ = try await execute(["clean"], packagePath: packageRoot)
1418-
XCTAssertNoSuchPath(binFile)
1419-
XCTAssertFalse(try localFileSystem.getDirectoryContents(buildPath.appending("repositories")).isEmpty)
14201417

14211418
// Fully clean.
14221419
_ = try await execute(["reset"], packagePath: packageRoot)
1423-
XCTAssertFalse(localFileSystem.isDirectory(buildPath))
1420+
XCTAssertFalse(localFileSystem.exists(buildPath))
14241421

14251422
// Test that we can successfully run reset again.
14261423
_ = try await execute(["reset"], packagePath: packageRoot)
@@ -3898,15 +3895,15 @@ class PackageCommandSwiftBuildTests: PackageCommandTestCase {
38983895
}
38993896

39003897
override func testCommandPluginBuildingCallbacks() async throws {
3901-
throw XCTSkip("SWBINTTODO: Test fails as plugins are not currenty supported")
3898+
try XCTSkipSwiftBuildTodo(because: "Test fails as plugins are not currenty supported")
39023899
}
39033900
override func testCommandPluginBuildTestability() async throws {
3904-
throw XCTSkip("SWBINTTODO: Test fails as plugins are not currenty supported")
3901+
try XCTSkipSwiftBuildTodo(because: "Test fails as plugins are not currenty supported")
39053902
}
39063903

39073904
#if !os(macOS)
39083905
override func testCommandPluginTestingCallbacks() async throws {
3909-
throw XCTSkip("SWBINTTODO: Test fails on inability to find libclang on Linux. Also, plugins are not currently supported")
3906+
try XCTSkipSwiftBuildTodo(because: "Test fails on inability to find libclang on Linux. Also, plugins are not currently supported")
39103907
}
39113908
#endif
39123909
}

Tests/CommandsTests/RunCommandTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,18 @@ class RunCommandSwiftBuildTests: RunCommandTestCase {
255255
}
256256

257257
override func testMultipleExecutableAndExplicitExecutable() async throws {
258-
throw XCTSkip("SWBINTTODO: https://github.com/swiftlang/swift-package-manager/issues/8279: Swift run using Swift Build does not output executable content to the terminal")
258+
try XCTSkipSwiftBuildTodo(because: "https://github.com/swiftlang/swift-package-manager/issues/8279: Swift run using Swift Build does not output executable content to the terminal")
259259
}
260260

261261
override func testUnknownProductAndArgumentPassing() async throws {
262-
throw XCTSkip("SWBINTTODO: https://github.com/swiftlang/swift-package-manager/issues/8279: Swift run using Swift Build does not output executable content to the terminal")
262+
try XCTSkipSwiftBuildTodo(because: "https://github.com/swiftlang/swift-package-manager/issues/8279: Swift run using Swift Build does not output executable content to the terminal")
263263
}
264264

265265
override func testToolsetDebugger() async throws {
266-
throw XCTSkip("SWBINTTODO: Test fixture fails to build")
266+
try XCTSkipSwiftBuildTodo(because: "Test fixture fails to build")
267267
}
268268

269269
override func testUnreachableExecutable() async throws {
270-
throw XCTSkip("SWBINTTODO: Test fails because of build layout differences.")
270+
try XCTSkipSwiftBuildTodo(because: "Test fails because of build layout differences.")
271271
}
272272
}

Tests/CommandsTests/TestCommandTests.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -648,54 +648,54 @@ class TestCommandSwiftBuildTests: TestCommandTestCase {
648648
}
649649

650650
override func testList() async throws {
651-
throw XCTSkip("SWBINTTODO: Test currently fails due to 'error: build failed'")
651+
try XCTSkipSwiftBuildTodo(because: "Test currently fails due to 'error: build failed'")
652652
}
653653

654654
override func testEnableTestDiscoveryDeprecation() async throws {
655-
throw XCTSkip("SWBINTTODO: Test currently fails due to 'error: build failed'")
655+
try XCTSkipSwiftBuildTodo(because: "Test currently fails due to 'error: build failed'")
656656
}
657657

658658
override func testEnableDisableTestability() async throws {
659-
throw XCTSkip("SWBINTTODO: Test currently fails due to 'error: build failed'")
659+
try XCTSkipSwiftBuildTodo(because: "Test currently fails due to 'error: build failed'")
660660
}
661661

662662
override func testToolsetRunner() async throws {
663-
throw XCTSkip("SWBINTTODO: Test currently fails, as some assertions are not met")
663+
try XCTSkipSwiftBuildTodo(because: "Test currently fails, as some assertions are not met")
664664
}
665665

666666
override func testWithReleaseConfiguration() async throws {
667-
throw XCTSkip("SWBINTTODO: Test currently fails with 'error: toolchain is invalid: could not find CLI tool `swiftpm-testing-helper` at any of these directories: [..., ...]'")
667+
try XCTSkipSwiftBuildTodo(because: "Test currently fails with 'error: toolchain is invalid: could not find CLI tool `swiftpm-testing-helper` at any of these directories: [..., ...]'")
668668
}
669669

670670
override func testXCTestOnlyDoesNotLogAboutNoMatchingTests() async throws {
671-
throw XCTSkip("SWBINTTODO: Test currently fails assertion as the there is a different error message 'error: no tests found; create a target in the 'Tests' directory'")
671+
try XCTSkipSwiftBuildTodo(because: "Test currently fails assertion as the there is a different error message 'error: no tests found; create a target in the 'Tests' directory'")
672672
}
673673

674674
override func testSwiftTestXMLOutputVerifyMultipleTestFailureMessageWithFlagEnabledSwiftTesting() async throws {
675-
throw XCTSkip("SWBINTTODO: Test currently fails assertion as the there is a different error message 'error: no tests found; create a target in the 'Tests' directory'")
675+
try XCTSkipSwiftBuildTodo(because: "Test currently fails assertion as the there is a different error message 'error: no tests found; create a target in the 'Tests' directory'")
676676
}
677677

678678
override func testSwiftTestXMLOutputVerifySingleTestFailureMessageWithFlagDisabledSwiftTesting() async throws {
679-
throw XCTSkip("SWBINTTODO: Test currently fails, further investigation is needed")
679+
try XCTSkipSwiftBuildTodo(because: "Test currently fails, further investigation is needed")
680680
}
681681

682682
override func testSwiftTestXMLOutputVerifySingleTestFailureMessageWithFlagEnabledSwiftTesting() async throws {
683-
throw XCTSkip("SWBINTTODO: Test currently fails, further investigation is needed")
683+
try XCTSkipSwiftBuildTodo(because: "Test currently fails, further investigation is needed")
684684
}
685685

686686
override func testSwiftTestXMLOutputVerifyMultipleTestFailureMessageWithFlagDisabledSwiftTesting() async throws {
687-
throw XCTSkip("SWBINTTODO: Test currently fails, further investigation is needed")
687+
try XCTSkipSwiftBuildTodo(because: "Test currently fails, further investigation is needed")
688688
}
689689

690690
#if !canImport(Darwin)
691691
override func testGeneratedMainIsExistentialAnyClean() async throws {
692-
throw XCTSkip("SWBINTTODO: This is a PIF builder missing GUID problem. Further investigation is needed.")
692+
try XCTSkipSwiftBuildTodo(because: "This is a PIF builder missing GUID problem. Further investigation is needed.")
693693
}
694694
#endif
695695

696696
#if !canImport(Darwin)
697697
override func testGeneratedMainIsConcurrencySafe_XCTest() async throws {
698-
throw XCTSkip("SWBINTTODO: This is a PIF builder missing GUID problem. Further investigation is needed.")
698+
try XCTSkipSwiftBuildTodo(because: "This is a PIF builder missing GUID problem. Further investigation is needed.")
699699
}
700700
#endif
701701

0 commit comments

Comments
 (0)