File tree Expand file tree Collapse file tree 4 files changed +43
-26
lines changed
Sources/_InternalTestSupport Expand file tree Collapse file tree 4 files changed +43
-26
lines changed Original file line number Diff line number Diff line change @@ -57,15 +57,11 @@ extension SwiftPM {
57
57
}
58
58
59
59
public static func xctestBinaryPath(for executableName: RelativePath) -> AbsolutePath {
60
- #if canImport(Darwin)
61
- for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
62
- return try! AbsolutePath(AbsolutePath(validating: bundle.bundlePath).parentDirectory, executableName)
60
+ do {
61
+ return try resolveBinDir().appending(executableName)
62
+ } catch {
63
+ fatalError("Unable to determine xctestBinaryPath")
63
64
}
64
- fatalError()
65
- #else
66
- return try! AbsolutePath(validating: CommandLine.arguments.first!, relativeTo: localFileSystem.currentWorkingDirectory!)
67
- .parentDirectory.appending(executableName)
68
- #endif
69
65
}
70
66
}
71
67
Original file line number Diff line number Diff line change @@ -21,15 +21,29 @@ import struct TSCBasic.StringError
21
21
import struct TSCUtility.SerializedDiagnostics
22
22
23
23
#if os(macOS)
24
- private func macOSBundleRoot() throws -> AbsolutePath {
24
+ func nextItem<T: Equatable>(in array: [T], after item: T) -> T? {
25
+ for (index, element) in array.enumerated() {
26
+ if element == item {
27
+ let nextIndex = index + 1
28
+ return nextIndex < array.count ? array[nextIndex] : nil
29
+ }
30
+ }
31
+ return nil // Item not found or it's the last item
32
+ }
33
+
34
+ package func macOSBundleRoot() throws -> AbsolutePath {
25
35
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
26
36
return try AbsolutePath(validating: bundle.bundlePath).parentDirectory
27
37
}
28
- fatalError()
38
+ if let testBundlePath = nextItem(in: ProcessInfo.processInfo.arguments, after: "--test-bundle-path") {
39
+ let binDir = AbsolutePath(testBundlePath).parentDirectory.parentDirectory.parentDirectory.parentDirectory
40
+ return binDir
41
+ }
42
+ fatalError("Unable to find macOS bundle root")
29
43
}
30
44
#endif
31
45
32
- private func resolveBinDir() throws -> AbsolutePath {
46
+ package func resolveBinDir() throws -> AbsolutePath {
33
47
#if os(macOS)
34
48
return try macOSBundleRoot()
35
49
#else
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ struct ObservabilitySystemTest {
75
75
#expect(diagnostic2_metadata.testKey3 == mergedMetadata2.testKey3)
76
76
77
77
let diagnostic2_5 = try #require(result.check(diagnostic: "error 2.5", severity: .error))
78
- let diagnostic2_5_metadata = try #require(diagnostic2 .metadata)
78
+ let diagnostic2_5_metadata = try #require(diagnostic2_5 .metadata)
79
79
#expect(diagnostic2_5_metadata.testKey1 == mergedMetadata2.testKey1)
80
80
#expect(diagnostic2_5_metadata.testKey2 == mergedMetadata2.testKey2)
81
81
#expect(diagnostic2_5_metadata.testKey3 == mergedMetadata2.testKey3)
Original file line number Diff line number Diff line change 9
9
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
10
//
11
11
//===----------------------------------------------------------------------===//
12
+ import Foundation
12
13
import DriverSupport
13
14
import PackageModel
14
15
import TSCBasic
15
- import XCTest
16
+ import Testing
16
17
import _InternalTestSupport
17
18
18
- final class StaticBinaryLibraryTests: XCTestCase {
19
- func testStaticLibrary() async throws {
20
- try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8657")
19
+ struct StaticBinaryLibraryTests {
20
+ @Test(
21
+ .bug("https://github.com/swiftlang/swift-package-manager/issues/8657")
22
+ )
23
+ func staticLibrary() async throws {
21
24
22
- try await fixture(name: "BinaryLibraries") { fixturePath in
23
- let (stdout, stderr) = try await executeSwiftRun(
24
- fixturePath.appending("Static").appending("Package1"),
25
- "Example",
26
- extraArgs: ["--experimental-prune-unused-dependencies"]
27
- )
28
- XCTAssertEqual(stdout, """
29
- 42
30
- 42
25
+ try await withKnownIssue {
26
+ try await fixture(name: "BinaryLibraries") { fixturePath in
27
+ let (stdout, stderr) = try await executeSwiftRun(
28
+ fixturePath.appending("Static").appending("Package1"),
29
+ "Example",
30
+ extraArgs: ["--experimental-prune-unused-dependencies"]
31
+ )
32
+ #expect(stdout == """
33
+ 42
34
+ 42
31
35
32
- """)
36
+ """)
37
+ }
38
+ } when: {
39
+ ProcessInfo.hostOperatingSystem == .windows
33
40
}
34
41
}
35
42
}
You can’t perform that action at this time.
0 commit comments