@@ -4,6 +4,45 @@ import XCTest
44
55import SwiftLintFramework
66
7+ #if os(Windows)
8+ private struct PlatformInfo {
9+ struct DefaultProperties {
10+ let versionXCTest : String
11+ let versionSwiftTesting : String
12+ let swiftFlags : [ String ] ?
13+ }
14+
15+ let defaults : DefaultProperties
16+ }
17+
18+ extension PlatformInfo . DefaultProperties : Decodable {
19+ enum CodingKeys : String , CodingKey {
20+ case versionXCTest = " XCTEST_VERSION "
21+ case versionSwiftTesting = " SWIFT_TESTING_VERSION "
22+ case swiftFlags = " SWIFTC_FLAGS "
23+ }
24+ }
25+
26+ extension PlatformInfo : Decodable {
27+ enum CodingKeys : String , CodingKey {
28+ case defaults = " DefaultProperties "
29+ }
30+ }
31+
32+ private let info : PlatformInfo = {
33+ let sdk = URL ( fileURLWithPath: sdkPath ( ) , isDirectory: true )
34+ . deletingLastPathComponent ( )
35+ . deletingLastPathComponent ( )
36+ . deletingLastPathComponent ( )
37+ . appendingPathComponent ( " Info.plist " )
38+ guard let data = try ? Data ( contentsOf: sdk) ,
39+ let info = try ? PropertyListDecoder ( ) . decode ( PlatformInfo . self, from: data) else {
40+ fatalError ( " invalid platform SDK - couldn't decode \( sdk. path) " )
41+ }
42+ return info
43+ } ( )
44+ #endif
45+
746// swiftlint:disable file_length
847
948private let violationMarker = " ↓ "
@@ -28,12 +67,29 @@ private extension SwiftLintFile {
2867 . appendingPathComponent ( " Library " )
2968 . appendingPathComponent ( " Frameworks " )
3069 . path
31- return [
32- " -F " ,
33- frameworks,
70+
71+ let arguments = [
72+ " -F " , frameworks,
3473 " -sdk " , sdk,
35- " -j4 " , path!,
74+ " -Xfrontend " , " -enable-objc-interop " ,
75+ " -j4 " ,
76+ path!,
3677 ]
78+ #if os(Windows)
79+ let XCTestPath = URL ( fileURLWithPath: sdk, isDirectory: true )
80+ . deletingLastPathComponent ( )
81+ . deletingLastPathComponent ( )
82+ . appendingPathComponent ( " Library " )
83+ . appendingPathComponent ( " XCTest- \( info. defaults. versionXCTest) " )
84+ . appendingPathComponent ( " usr " )
85+ . appendingPathComponent ( " lib " )
86+ . appendingPathComponent ( " swift " )
87+ . appendingPathComponent ( " windows " )
88+ . path
89+ return [ " -I " , XCTestPath] + arguments
90+ #else
91+ return arguments
92+ #endif
3793 }
3894}
3995
@@ -265,6 +321,11 @@ private func testCorrection(_ correction: (Example, Example),
265321 guard correction. 0 . testOnLinux else {
266322 return
267323 }
324+ #endif
325+ #if os(Windows)
326+ guard correction. 0 . testOnWindows else {
327+ return
328+ }
268329#endif
269330 var config = configuration
270331 if let correctionConfiguration = correction. 0 . configuration,
0 commit comments