Skip to content

Remove swiftpm-xctest-helper #6667

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 26, 2023
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
7 changes: 0 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -491,13 +491,6 @@ let package = Package(
name: "swift-package-registry",
dependencies: ["Commands", "PackageRegistryTool"]
),
.executableTarget(
/** Shim tool to find test names on OS X */
name: "swiftpm-xctest-helper",
dependencies: [],
linkerSettings: [
.unsafeFlags(["-Xlinker", "-rpath", "-Xlinker", "@executable_path/../../../lib/swift/macosx"], .when(platforms: [.macOS])),
]),

// MARK: Support for Swift macros, should eventually move to a plugin-based solution

Expand Down
39 changes: 26 additions & 13 deletions Sources/Commands/Utilities/TestingSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,34 @@ enum TestingSupport {
///
/// - Returns: Path to XCTestHelper tool.
static func xctestHelperPath(swiftTool: SwiftTool) throws -> AbsolutePath {
let xctestHelperBin = "swiftpm-xctest-helper"
let binDirectory = try AbsolutePath(validating: CommandLine.arguments.first!,
relativeTo: swiftTool.originalWorkingDirectory).parentDirectory
// XCTestHelper tool is installed in libexec.
let maybePath = binDirectory.parentDirectory.appending(components: "libexec", "swift", "pm", xctestHelperBin)
if swiftTool.fileSystem.isFile(maybePath) {
return maybePath
var triedPaths = [AbsolutePath]()

func findXCTestHelper(swiftBuildPath: AbsolutePath) -> AbsolutePath? {
// XCTestHelper tool is installed in libexec.
let maybePath = swiftBuildPath.parentDirectory.parentDirectory.appending(components: "libexec", "swift", "pm", "swiftpm-xctest-helper")
if swiftTool.fileSystem.isFile(maybePath) {
return maybePath
} else {
triedPaths.append(maybePath)
return nil
}
}
// This will be true during swiftpm development.
// FIXME: Factor all of the development-time resource location stuff into a common place.
let path = binDirectory.appending(component: xctestHelperBin)
if swiftTool.fileSystem.isFile(path) {
return path

if let firstCLIArgument = CommandLine.arguments.first {
let runningSwiftBuildPath = try AbsolutePath(validating: firstCLIArgument, relativeTo: swiftTool.originalWorkingDirectory)
if let xctestHelperPath = findXCTestHelper(swiftBuildPath: runningSwiftBuildPath) {
return xctestHelperPath
}
}
throw InternalError("XCTestHelper binary not found.")

// This will be true during swiftpm development or when using swift.org toolchains.
let xcodePath = try TSCBasic.Process.checkNonZeroExit(args: "/usr/bin/xcode-select", "--print-path").spm_chomp()
let installedSwiftBuildPath = try TSCBasic.Process.checkNonZeroExit(args: "/usr/bin/xcrun", "--find", "swift-build", environment: ["DEVELOPER_DIR": xcodePath]).spm_chomp()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the explicit DEVELOPER_DIR override here since I was seeing some confusing behavior from pure xcrun in the development scenario. I was basically ending up with the same path as runningSwiftBuildPath above. Looking up the Xcode path separately works, though.

if let xctestHelperPath = findXCTestHelper(swiftBuildPath: try AbsolutePath(validating: installedSwiftBuildPath)) {
return xctestHelperPath
}

throw InternalError("XCTestHelper binary not found, tried \(triedPaths.map { $0.pathString }.joined(separator: ", "))")
}

static func getTestSuites(in testProducts: [BuiltTestProduct], swiftTool: SwiftTool, enableCodeCoverage: Bool, sanitizers: [Sanitizer]) throws -> [AbsolutePath: [TestSuite]] {
Expand Down
3 changes: 0 additions & 3 deletions Sources/SPMTestSupport/SwiftPMProduct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public enum SwiftPM {
case Registry
case Test
case Run
case XCTestHelper
}

extension SwiftPM {
Expand All @@ -42,8 +41,6 @@ extension SwiftPM {
return "swift-test"
case .Run:
return "swift-run"
case .XCTestHelper:
return "swiftpm-xctest-helper"
}
}

Expand Down
147 changes: 0 additions & 147 deletions Sources/swiftpm-xctest-helper/main.swift

This file was deleted.

64 changes: 0 additions & 64 deletions Tests/FunctionalTests/SwiftPMXCTestHelperTests.swift

This file was deleted.

5 changes: 0 additions & 5 deletions Utilities/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,6 @@ def install_swiftpm(prefix, args):
note("Creating tool symlink from %s to %s" % (src, dest))
symlink_force(src, dest)

# On Darwin, also install the swiftpm-xctest-helper tool.
if platform.system() == 'Darwin':
dest = os.path.join(prefix, "libexec", "swift", "pm")
install_binary(args, "swiftpm-xctest-helper", dest)

# Install the PackageDescription/CompilerPluginSupport libraries and associated modules.
dest = os.path.join(prefix, "lib", "swift", "pm", "ManifestAPI")
install_dylib(args, "PackageDescription", dest, ["PackageDescription", "CompilerPluginSupport"])
Expand Down