Skip to content

[5.5] SPMTestSupport should not depend on Build #3553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ let package = Package(
.target(
/** SwiftPM test support library */
name: "SPMTestSupport",
dependencies: ["SwiftToolsSupport-auto", "Basics", "Build", "TSCTestSupport", "PackageGraph", "PackageLoading", "SourceControl", "Workspace", "Xcodeproj", "XCBuildSupport"]),
dependencies: ["SwiftToolsSupport-auto", "Basics", "TSCTestSupport", "PackageGraph", "PackageLoading", "SourceControl", "Workspace", "Xcodeproj", "XCBuildSupport"]),

// MARK: SwiftPM tests

Expand Down
3 changes: 0 additions & 3 deletions Sources/SPMTestSupport/Resources.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import SPMBuildCore
import Foundation
import PackageLoading
import Workspace
import Build

#if os(macOS)
private func bundleRoot() -> AbsolutePath {
Expand Down Expand Up @@ -66,6 +65,4 @@ public class Resources: ManifestResourceProvider {
public static var havePD4Runtime: Bool {
return Resources.default.binDir == nil
}

public let swiftCompilerSupportsRenamingMainSymbol = SwiftTargetBuildDescription.checkSupportedFrontendFlags(flags: ["entry-point-function-name"], fs: localFileSystem)
}
4 changes: 3 additions & 1 deletion Tests/FunctionalTests/MiscellaneousTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,9 @@ class MiscellaneousTestCase: XCTestCase {

func testTestsCanLinkAgainstExecutable() throws {
// Check if the host compiler supports the '-entry-point-function-name' flag.
try XCTSkipUnless(Resources.default.swiftCompilerSupportsRenamingMainSymbol, "skipping because host compiler doesn't support '-entry-point-function-name'")
#if swift(<5.5)
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
#endif

fixture(name: "Miscellaneous/TestableExe") { prefix in
do {
Expand Down
26 changes: 20 additions & 6 deletions Tests/FunctionalTests/PluginTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class PluginTests: XCTestCase {

func testUseOfBuildToolPluginTargetByExecutableInSamePackage() throws {
// 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.
try XCTSkipUnless(Resources.default.swiftCompilerSupportsRenamingMainSymbol, "skipping because host compiler doesn't support '-entry-point-function-name'")
#if swift(<5.5)
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
#endif

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

func testUseOfBuildToolPluginProductByExecutableAcrossPackages() throws {
// 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.
try XCTSkipUnless(Resources.default.swiftCompilerSupportsRenamingMainSymbol, "skipping because host compiler doesn't support '-entry-point-function-name'")
#if swift(<5.5)
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
#endif

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

func testUseOfPrebuildPluginTargetByExecutableAcrossPackages() throws {
// 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.
try XCTSkipUnless(Resources.default.swiftCompilerSupportsRenamingMainSymbol, "skipping because host compiler doesn't support '-entry-point-function-name'")
#if swift(<5.5)
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
#endif

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

func testContrivedTestCases() throws {
// 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.
try XCTSkipUnless(Resources.default.swiftCompilerSupportsRenamingMainSymbol, "skipping because host compiler doesn't support '-entry-point-function-name'")
#if swift(<5.5)
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
#endif

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

func testPluginScriptSandbox() throws {
// 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.
try XCTSkipUnless(Resources.default.swiftCompilerSupportsRenamingMainSymbol, "skipping because host compiler doesn't support '-entry-point-function-name'")
#if swift(<5.5)
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
#endif

#if os(macOS)
fixture(name: "Miscellaneous/Plugins") { path in
do {
Expand All @@ -110,7 +121,10 @@ class PluginTests: XCTestCase {

func testUseOfVendedBinaryTool() throws {
// 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.
try XCTSkipUnless(Resources.default.swiftCompilerSupportsRenamingMainSymbol, "skipping because host compiler doesn't support '-entry-point-function-name'")
#if swift(<5.5)
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
#endif

#if os(macOS)
fixture(name: "Miscellaneous/Plugins") { path in
do {
Expand Down
14 changes: 7 additions & 7 deletions Tests/WorkspaceTests/InitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ class InitTests: XCTestCase {
["FooTests"])

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

Expand Down