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 {
5757 }
5858
5959 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 " )
6364 }
64- fatalError ( )
65- #else
66- return try ! AbsolutePath ( validating: CommandLine . arguments. first!, relativeTo: localFileSystem. currentWorkingDirectory!)
67- . parentDirectory. appending ( executableName)
68- #endif
6965 }
7066}
7167
Original file line number Diff line number Diff line change @@ -21,15 +21,29 @@ import struct TSCBasic.StringError
2121import struct TSCUtility. SerializedDiagnostics
2222
2323#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 {
2535 for bundle in Bundle . allBundles where bundle. bundlePath. hasSuffix ( " .xctest " ) {
2636 return try AbsolutePath ( validating: bundle. bundlePath) . parentDirectory
2737 }
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 " )
2943}
3044#endif
3145
32- private func resolveBinDir( ) throws -> AbsolutePath {
46+ package func resolveBinDir( ) throws -> AbsolutePath {
3347#if os(macOS)
3448 return try macOSBundleRoot ( )
3549#else
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ struct ObservabilitySystemTest {
7575 #expect( diagnostic2_metadata. testKey3 == mergedMetadata2. testKey3)
7676
7777 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)
7979 #expect( diagnostic2_5_metadata. testKey1 == mergedMetadata2. testKey1)
8080 #expect( diagnostic2_5_metadata. testKey2 == mergedMetadata2. testKey2)
8181 #expect( diagnostic2_5_metadata. testKey3 == mergedMetadata2. testKey3)
Original file line number Diff line number Diff line change 99// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010//
1111//===----------------------------------------------------------------------===//
12+ import Foundation
1213import DriverSupport
1314import PackageModel
1415import TSCBasic
15- import XCTest
16+ import Testing
1617import _InternalTestSupport
1718
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 {
2124
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
3135
32- """ )
36+ """ )
37+ }
38+ } when: {
39+ ProcessInfo . hostOperatingSystem == . windows
3340 }
3441 }
3542}
You can’t perform that action at this time.
0 commit comments