Skip to content

Commit

Permalink
Improve Destination.sdkPlatformFrameworkPaths()
Browse files Browse the repository at this point in the history
We should not ignore errors or an empty SDK platform path since that means XCTest imports and test execution might silently fail on macOS with no indication to what the problem is. I am speculating that this may be contributing to the recent surge of tests failing by not seeing the XCTest Swift library. I am also re-enabling the disabled tests here to see if this has any practical effect, but regardless it doesn't seem reasonable to silently ignore some failure states here.

rdar://101868275
  • Loading branch information
neonichu committed Nov 4, 2022
1 parent 3c692dc commit 6d50e07
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 28 deletions.
22 changes: 12 additions & 10 deletions Sources/PackageModel/Destination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,23 @@ public struct Destination: Encodable, Equatable {
if let path = _sdkPlatformFrameworkPath {
return path
}
let platformPath = try? TSCBasic.Process.checkNonZeroExit(
let platformPath = try TSCBasic.Process.checkNonZeroExit(
arguments: ["/usr/bin/xcrun", "--sdk", "macosx", "--show-sdk-platform-path"],
environment: environment).spm_chomp()

if let platformPath = platformPath, !platformPath.isEmpty {
// For XCTest framework.
let fwk = try AbsolutePath(validating: platformPath).appending(
components: "Developer", "Library", "Frameworks")
guard !platformPath.isEmpty else {
throw StringError("could not determine SDK platform path")
}

// For XCTest Swift library.
let lib = try AbsolutePath(validating: platformPath).appending(
components: "Developer", "usr", "lib")
// For XCTest framework.
let fwk = try AbsolutePath(validating: platformPath).appending(
components: "Developer", "Library", "Frameworks")

_sdkPlatformFrameworkPath = (fwk, lib)
}
// For XCTest Swift library.
let lib = try AbsolutePath(validating: platformPath).appending(
components: "Developer", "usr", "lib")

_sdkPlatformFrameworkPath = (fwk, lib)
return _sdkPlatformFrameworkPath
}
/// Cache storage for sdk platform path.
Expand Down
12 changes: 0 additions & 12 deletions Sources/SPMTestSupport/Toolchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ private func resolveBinDir() throws -> AbsolutePath {
#endif
}

extension UserToolchain {

#if os(macOS)
public var sdkPlatformFrameworksPath: AbsolutePath {
get throws {
return try Destination.sdkPlatformFrameworkPaths()!.fwk
}
}
#endif

}

extension Destination {
public static var `default`: Self {
get throws {
Expand Down
2 changes: 0 additions & 2 deletions Tests/CommandsTests/BuildToolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ final class BuildToolTests: CommandsTestCase {
}

func testBuildCompleteMessage() throws {
throw XCTSkip("This test fails to match the 'Compiling' regex; rdar://101815761")

try fixture(name: "DependencyResolution/Internal/Simple") { fixturePath in
do {
let result = try execute([], packagePath: fixturePath)
Expand Down
2 changes: 0 additions & 2 deletions Tests/WorkspaceTests/InitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,6 @@ class InitTests: XCTestCase {
}

func testNonC99NameExecutablePackage() throws {
throw XCTSkip("This test fails to find XCTAssertEqual; rdar://101868275")

try withTemporaryDirectory(removeTreeOnDeinit: true) { tempDirPath in
XCTAssertDirectoryExists(tempDirPath)

Expand Down
2 changes: 0 additions & 2 deletions Tests/WorkspaceTests/WorkspaceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4291,8 +4291,6 @@ final class WorkspaceTests: XCTestCase {

// This verifies that the simplest possible loading APIs are available for package clients.
func testSimpleAPI() throws {
throw XCTSkip("This test fails to find XCTAssertEqual; rdar://101868275")

try testWithTemporaryDirectory { path in
// Create a temporary package as a test case.
let packagePath = path.appending(component: "MyPkg")
Expand Down

0 comments on commit 6d50e07

Please sign in to comment.