Skip to content

Commit 3cc6ba0

Browse files
committed
SPMTestSupport should not depend on Build
In #3398, we introduced a way to check whether a compiler supports specific flags. This functionality relies on the Swift Driver and therefore the `Build` module which isn't available on all platforms and therefore shouldn't be used by `SPMTestSupport`. This change removes the dependency and replaces the check in tests with a check for the 5.5 Swift compiler instead.
1 parent 6bbc28e commit 3cc6ba0

File tree

5 files changed

+31
-18
lines changed

5 files changed

+31
-18
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ let package = Package(
253253
.target(
254254
/** SwiftPM test support library */
255255
name: "SPMTestSupport",
256-
dependencies: ["SwiftToolsSupport-auto", "Basics", "Build", "TSCTestSupport", "PackageGraph", "PackageLoading", "SourceControl", "Workspace", "Xcodeproj", "XCBuildSupport"]),
256+
dependencies: ["SwiftToolsSupport-auto", "Basics", "TSCTestSupport", "PackageGraph", "PackageLoading", "SourceControl", "Workspace", "Xcodeproj", "XCBuildSupport"]),
257257

258258
// MARK: SwiftPM tests
259259

Sources/SPMTestSupport/Resources.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import SPMBuildCore
1313
import Foundation
1414
import PackageLoading
1515
import Workspace
16-
import Build
1716

1817
#if os(macOS)
1918
private func bundleRoot() -> AbsolutePath {
@@ -66,6 +65,4 @@ public class Resources: ManifestResourceProvider {
6665
public static var havePD4Runtime: Bool {
6766
return Resources.default.binDir == nil
6867
}
69-
70-
public let swiftCompilerSupportsRenamingMainSymbol = SwiftTargetBuildDescription.checkSupportedFrontendFlags(flags: ["entry-point-function-name"], fs: localFileSystem)
7168
}

Tests/FunctionalTests/MiscellaneousTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,9 @@ class MiscellaneousTestCase: XCTestCase {
562562

563563
func testTestsCanLinkAgainstExecutable() throws {
564564
// Check if the host compiler supports the '-entry-point-function-name' flag.
565-
try XCTSkipUnless(Resources.default.swiftCompilerSupportsRenamingMainSymbol, "skipping because host compiler doesn't support '-entry-point-function-name'")
565+
#if swift(>=5.5)
566+
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
567+
#endif
566568

567569
fixture(name: "Miscellaneous/TestableExe") { prefix in
568570
do {

Tests/FunctionalTests/PluginTests.swift

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ class PluginTests: XCTestCase {
1616

1717
func testUseOfBuildToolPluginTargetByExecutableInSamePackage() throws {
1818
// Check if the host compiler supports the '-entry-point-function-name' flag. It's not needed for this test but is needed to build any executable from a package that uses tools version 5.5.
19-
try XCTSkipUnless(Resources.default.swiftCompilerSupportsRenamingMainSymbol, "skipping because host compiler doesn't support '-entry-point-function-name'")
19+
#if swift(>=5.5)
20+
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
21+
#endif
2022

2123
fixture(name: "Miscellaneous/Plugins") { path in
2224
do {
@@ -35,7 +37,9 @@ class PluginTests: XCTestCase {
3537

3638
func testUseOfBuildToolPluginProductByExecutableAcrossPackages() throws {
3739
// Check if the host compiler supports the '-entry-point-function-name' flag. It's not needed for this test but is needed to build any executable from a package that uses tools version 5.5.
38-
try XCTSkipUnless(Resources.default.swiftCompilerSupportsRenamingMainSymbol, "skipping because host compiler doesn't support '-entry-point-function-name'")
40+
#if swift(>=5.5)
41+
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
42+
#endif
3943

4044
fixture(name: "Miscellaneous/Plugins") { path in
4145
do {
@@ -54,7 +58,9 @@ class PluginTests: XCTestCase {
5458

5559
func testUseOfPrebuildPluginTargetByExecutableAcrossPackages() throws {
5660
// Check if the host compiler supports the '-entry-point-function-name' flag. It's not needed for this test but is needed to build any executable from a package that uses tools version 5.5.
57-
try XCTSkipUnless(Resources.default.swiftCompilerSupportsRenamingMainSymbol, "skipping because host compiler doesn't support '-entry-point-function-name'")
61+
#if swift(>=5.5)
62+
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
63+
#endif
5864

5965
fixture(name: "Miscellaneous/Plugins") { path in
6066
do {
@@ -73,7 +79,9 @@ class PluginTests: XCTestCase {
7379

7480
func testContrivedTestCases() throws {
7581
// Check if the host compiler supports the '-entry-point-function-name' flag. It's not needed for this test but is needed to build any executable from a package that uses tools version 5.5.
76-
try XCTSkipUnless(Resources.default.swiftCompilerSupportsRenamingMainSymbol, "skipping because host compiler doesn't support '-entry-point-function-name'")
82+
#if swift(>=5.5)
83+
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
84+
#endif
7785

7886
fixture(name: "Miscellaneous/Plugins") { path in
7987
do {
@@ -92,7 +100,10 @@ class PluginTests: XCTestCase {
92100

93101
func testPluginScriptSandbox() throws {
94102
// Check if the host compiler supports the '-entry-point-function-name' flag. It's not needed for this test but is needed to build any executable from a package that uses tools version 5.5.
95-
try XCTSkipUnless(Resources.default.swiftCompilerSupportsRenamingMainSymbol, "skipping because host compiler doesn't support '-entry-point-function-name'")
103+
#if swift(>=5.5)
104+
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
105+
#endif
106+
96107
#if os(macOS)
97108
fixture(name: "Miscellaneous/Plugins") { path in
98109
do {
@@ -110,7 +121,10 @@ class PluginTests: XCTestCase {
110121

111122
func testUseOfVendedBinaryTool() throws {
112123
// Check if the host compiler supports the '-entry-point-function-name' flag. It's not needed for this test but is needed to build any executable from a package that uses tools version 5.5.
113-
try XCTSkipUnless(Resources.default.swiftCompilerSupportsRenamingMainSymbol, "skipping because host compiler doesn't support '-entry-point-function-name'")
124+
#if swift(>=5.5)
125+
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
126+
#endif
127+
114128
#if os(macOS)
115129
fixture(name: "Miscellaneous/Plugins") { path in
116130
do {

Tests/WorkspaceTests/InitTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ class InitTests: XCTestCase {
8686
["FooTests"])
8787

8888
// If we have a compiler that supports `-entry-point-function-name`, we try building it (we need that flag now).
89-
if (Resources.default.swiftCompilerSupportsRenamingMainSymbol) {
90-
XCTAssertBuilds(path)
91-
let triple = Resources.default.toolchain.triple
92-
let binPath = path.appending(components: ".build", triple.tripleString, "debug")
93-
XCTAssertFileExists(binPath.appending(component: "Foo"))
94-
XCTAssertFileExists(binPath.appending(components: "Foo.swiftmodule"))
95-
}
89+
#if swift(>=5.5)
90+
XCTAssertBuilds(path)
91+
let triple = Resources.default.toolchain.triple
92+
let binPath = path.appending(components: ".build", triple.tripleString, "debug")
93+
XCTAssertFileExists(binPath.appending(component: "Foo"))
94+
XCTAssertFileExists(binPath.appending(components: "Foo.swiftmodule"))
95+
#endif
9696
}
9797
}
9898

0 commit comments

Comments
 (0)