File tree Expand file tree Collapse file tree 3 files changed +29
-8
lines changed Expand file tree Collapse file tree 3 files changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -10,13 +10,16 @@ See http://swift.org/CONTRIBUTORS.txt for Swift project authors
10
10
11
11
enum Error : ErrorType {
12
12
case DebugYAMLNotFound
13
+ case TestsExecutableNotFound
13
14
}
14
15
15
16
extension Error : CustomStringConvertible {
16
17
var description : String {
17
18
switch self {
18
19
case . DebugYAMLNotFound:
19
20
return " build the package using `swift build` before running tests "
21
+ case . TestsExecutableNotFound:
22
+ return " no tests found to execute, create a test-module in `Tests` directory "
20
23
}
21
24
}
22
25
}
Original file line number Diff line number Diff line change 27
27
guard yamlPath. exists else { throw Error . DebugYAMLNotFound }
28
28
29
29
try build ( YAMLPath: yamlPath, target: " test " )
30
- let success = test ( dir. build, " debug " )
30
+ let success = try test ( dir. build, " debug " )
31
31
exit ( success ? 0 : 1 )
32
32
33
33
} catch {
Original file line number Diff line number Diff line change 11
11
import PackageType
12
12
import Utility
13
13
14
- func test( path: String ... , args: String ? = nil ) -> Bool {
14
+ func test( path: String ... , args: String ? = nil ) throws -> Bool {
15
15
let path = Path . join ( path)
16
- let result : Void ?
16
+ var args : [ String ] = [ ]
17
+ let testsPath : String
18
+
17
19
#if os(OSX)
18
- var args = [ " xcrun " , " xctest " ]
20
+ testsPath = Path . join ( path, " Package.xctest " )
21
+ args = [ " xcrun " , " xctest " ]
19
22
args += Process . arguments. dropFirst ( )
20
- args += [ Path . join ( path, " Package.xctest " ) ]
21
- result = try ? system ( args)
22
23
#else
23
- result = try ? system ( Path . join ( path, " test-Package " ) )
24
+ testsPath = Path . join ( path, " test-Package " )
24
25
#endif
25
-
26
+
27
+ guard testsPath. testExecutableExists else {
28
+ throw Error . TestsExecutableNotFound
29
+ }
30
+
31
+ args += [ testsPath]
32
+
33
+ let result : Void ? = try ? system ( args)
26
34
return result != nil
27
35
}
36
+
37
+ private extension String {
38
+ var testExecutableExists : Bool {
39
+ #if os(OSX)
40
+ return self . isDirectory //Package.xctest is dir on OSX
41
+ #else
42
+ return self . isFile //test-Package is executable on OSX
43
+ #endif
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments