@@ -20,6 +20,49 @@ import SwiftExtensions
20
20
import TSCBasic
21
21
import ToolchainRegistry
22
22
23
+ package struct WindowsPlatformInfo {
24
+ package struct DefaultProperties {
25
+ /// XCTEST_VERSION
26
+ /// specifies the version string of the bundled XCTest.
27
+ public let xctestVersion : String
28
+
29
+ /// SWIFT_TESTING_VERSION
30
+ /// specifies the version string of the bundled swift-testing.
31
+ public let swiftTestingVersion : String ?
32
+
33
+ /// SWIFTC_FLAGS
34
+ /// Specifies extra flags to pass to swiftc from Swift Package Manager.
35
+ public let extraSwiftCFlags : [ String ] ?
36
+ }
37
+
38
+ public let defaults : DefaultProperties
39
+ }
40
+
41
+ extension WindowsPlatformInfo . DefaultProperties : Decodable {
42
+ enum CodingKeys : String , CodingKey {
43
+ case xctestVersion = " XCTEST_VERSION "
44
+ case swiftTestingVersion = " SWIFT_TESTING_VERSION "
45
+ case extraSwiftCFlags = " SWIFTC_FLAGS "
46
+ }
47
+ }
48
+
49
+ extension WindowsPlatformInfo : Decodable {
50
+ enum CodingKeys : String , CodingKey {
51
+ case defaults = " DefaultProperties "
52
+ }
53
+ }
54
+
55
+ extension WindowsPlatformInfo {
56
+ package init ? ( reading path: URL ) {
57
+ do {
58
+ let data : Data = try Data ( contentsOf: path)
59
+ self = try PropertyListDecoder ( ) . decode ( WindowsPlatformInfo . self, from: data)
60
+ } catch {
61
+ return nil
62
+ }
63
+ }
64
+ }
65
+
23
66
package struct IndexedSingleSwiftFileTestProject {
24
67
enum Error : Swift . Error {
25
68
case swiftcNotFound
@@ -79,17 +122,19 @@ package struct IndexedSingleSwiftFileTestProject {
79
122
// The following are needed so we can import XCTest
80
123
let sdkUrl = URL ( fileURLWithPath: sdk)
81
124
#if os(Windows)
82
- let xctestModuleDir =
83
- sdkUrl
84
- . deletingLastPathComponent ( )
85
- . deletingLastPathComponent ( )
86
- . appendingPathComponent ( " Library " )
87
- . appendingPathComponent ( " XCTest-development " )
88
- . appendingPathComponent ( " usr " )
89
- . appendingPathComponent ( " lib " )
90
- . appendingPathComponent ( " swift " )
91
- . appendingPathComponent ( " windows " )
92
- compilerArguments += [ " -I " , try xctestModuleDir. filePath]
125
+ let platform = sdkUrl. deletingLastPathComponent ( ) . deletingLastPathComponent ( ) . deletingLastPathComponent ( )
126
+ if let info = WindowsPlatformInfo ( reading: platform. appendingPathComponent ( " Info.plist " ) ) {
127
+ let xctestModuleDir =
128
+ platform
129
+ . appendingPathComponent ( " Developer " )
130
+ . appendingPathComponent ( " Library " )
131
+ . appendingPathComponent ( " XCTest- \( info. defaults. xctestVersion) " )
132
+ . appendingPathComponent ( " usr " )
133
+ . appendingPathComponent ( " lib " )
134
+ . appendingPathComponent ( " swift " )
135
+ . appendingPathComponent ( " windows " )
136
+ compilerArguments += [ " -I " , try xctestModuleDir. filePath]
137
+ }
93
138
#else
94
139
let usrLibDir =
95
140
sdkUrl
0 commit comments