@@ -98,16 +98,28 @@ enum Configuration {
98
98
99
99
private var globalSymbolInMainBinary = 0
100
100
101
+ private enum SwiftExecutable : String {
102
+ case Build = " swift-build "
103
+ case Test = " swift-test "
104
+ }
105
+
106
+ private func executablePath( exe: SwiftExecutable ) -> String {
107
+ #if os(OSX)
108
+ for bundle in NSBundle . allBundles ( ) where bundle. bundlePath. hasSuffix ( " .xctest " ) {
109
+ return Path . join ( bundle. bundlePath. parentDirectory, exe. rawValue)
110
+ }
111
+ fatalError ( )
112
+ #else
113
+ return Path . join ( Process . arguments. first!. abspath ( ) . parentDirectory, exe. rawValue)
114
+ #endif
115
+ }
101
116
102
117
func swiftBuildPath( ) -> String {
103
- #if os(OSX)
104
- for bundle in NSBundle . allBundles ( ) where bundle. bundlePath. hasSuffix ( " .xctest " ) {
105
- return Path . join ( bundle. bundlePath. parentDirectory, " swift-build " )
106
- }
107
- fatalError ( )
108
- #else
109
- return Path . join ( Process . arguments. first!. abspath ( ) . parentDirectory, " swift-build " )
110
- #endif
118
+ return executablePath ( exe: . Build)
119
+ }
120
+
121
+ func swiftTestPath( ) -> String {
122
+ return executablePath ( exe: . Test)
111
123
}
112
124
113
125
@@ -155,17 +167,6 @@ func executeSwiftBuild(_ chdir: String, configuration: Configuration = .Debug, p
155
167
}
156
168
}
157
169
158
- func swiftTestPath( ) -> String {
159
- #if os(OSX)
160
- for bundle in NSBundle . allBundles ( ) where bundle. bundlePath. hasSuffix ( " .xctest " ) {
161
- return Path . join ( bundle. bundlePath. parentDirectory, " swift-test " )
162
- }
163
- fatalError ( )
164
- #else
165
- return Path . join ( Process . arguments. first!. abspath ( ) . parentDirectory, " swift-test " )
166
- #endif
167
- }
168
-
169
170
func executeSwiftTest( _ chdir: String , printIfError: Bool = false , additionalArgs: [ String ] = [ ] ) throws -> String {
170
171
let args = [ swiftTestPath ( ) , " --chdir " , chdir] + additionalArgs
171
172
var out = " "
0 commit comments