File tree Expand file tree Collapse file tree 6 files changed +40
-22
lines changed Expand file tree Collapse file tree 6 files changed +40
-22
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,9 @@ extension CModule {
36
36
37
37
extension Product {
38
38
var Info : ( _: Void , plist: String ) {
39
- let bundleExecutable = " Package "
39
+ precondition ( isTest)
40
+
41
+ let bundleExecutable = name
40
42
let bundleID = " org.swift.pm. \( name) "
41
43
let bundleName = name
42
44
Original file line number Diff line number Diff line change @@ -34,10 +34,11 @@ public class Product {
34
34
return " lib \( name) .so "
35
35
#endif
36
36
case . Test:
37
+ let base = " \( name) .xctest "
37
38
#if os(OSX)
38
- return " \( name ) .xctest /Contents/MacOS/\( name) "
39
+ return " \( base ) /Contents/MacOS/ \( name) "
39
40
#else
40
- return " test- \( name ) "
41
+ return base
41
42
#endif
42
43
}
43
44
}
Original file line number Diff line number Diff line change @@ -28,9 +28,8 @@ extension Package {
28
28
29
29
if !testModules. isEmpty {
30
30
let modules : [ SwiftModule ] = testModules. map { $0} // or linux compiler crash (2016-02-03)
31
- //TODO name should be package name
32
31
//TODO and then we should prefix all modules with their package probably
33
- let product = Product ( name: " Package " , type: . Test, modules: modules)
32
+ let product = Product ( name: self . name , type: . Test, modules: modules)
34
33
products. append ( product)
35
34
}
36
35
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ extension Error: CustomStringConvertible {
19
19
case . DebugYAMLNotFound:
20
20
return " build the package using `swift build` before running tests "
21
21
case . TestsExecutableNotFound:
22
- return " no tests found to execute, create a test- module in `Tests` directory "
22
+ return " no tests found to execute, create a module in your `Tests' directory "
23
23
}
24
24
}
25
25
}
Original file line number Diff line number Diff line change 21
21
usage ( )
22
22
case . Run( let xctestArg) :
23
23
let dir = try directories ( )
24
+
25
+ func determineTestPath( ) -> String {
26
+
27
+ //FIXME better, ideally without parsing manifest since
28
+ // that makes us depend on the whole Manifest system
29
+
30
+ let packageName = dir. root. basename //FIXME probably not true
31
+ let maybePath = Path . join ( dir. build, " \( packageName) .xctest " )
32
+
33
+ if maybePath. exists {
34
+ return maybePath
35
+ } else {
36
+ return walk ( dir. build) . filter {
37
+ $0. basename != " Package.xctest " && // this was our hardcoded name, may still exist if no clean
38
+ $0. hasSuffix ( " .xctest " )
39
+ } . first!
40
+ }
41
+ }
42
+
24
43
let yamlPath = Path . join ( dir. build, " debug.yaml " )
25
44
guard yamlPath. exists else { throw Error . DebugYAMLNotFound }
26
45
27
46
try build ( YAMLPath: yamlPath, target: " test " )
28
- let success = try test ( dir. build, " debug " , xctestArg: xctestArg)
47
+
48
+ let success = try test ( path: determineTestPath ( ) , xctestArg: xctestArg)
29
49
exit ( success ? 0 : 1 )
30
50
}
31
51
} 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 ... , xctestArg: String ? = nil ) throws -> Bool {
15
- let path = Path . join ( path)
16
- var args : [ String ] = [ ]
17
- let testsPath : String
14
+ func test( path path: String , xctestArg: String ? = nil ) throws -> Bool {
15
+
16
+ guard path. isValidTest else {
17
+ throw Error . TestsExecutableNotFound
18
+ }
18
19
20
+ var args : [ String ] = [ ]
19
21
#if os(OSX)
20
- testsPath = Path . join ( path, " Package.xctest " )
21
22
args = [ " xcrun " , " xctest " ]
22
23
if let xctestArg = xctestArg {
23
24
args += [ " -XCTest " , xctestArg]
24
25
}
25
- args += [ testsPath ]
26
+ args += [ path ]
26
27
#else
27
- testsPath = Path . join ( path, " test-Package " )
28
- args += [ testsPath]
28
+ args += [ path]
29
29
if let xctestArg = xctestArg {
30
30
args += [ xctestArg]
31
31
}
32
32
#endif
33
33
34
- guard testsPath. testExecutableExists else {
35
- throw Error . TestsExecutableNotFound
36
- }
37
-
38
34
let result : Void ? = try ? system ( args)
39
35
return result != nil
40
36
}
41
37
42
38
private extension String {
43
- var testExecutableExists : Bool {
39
+ var isValidTest : Bool {
44
40
#if os(OSX)
45
- return self . isDirectory //Package .xctest is dir on OSX
41
+ return isDirectory // ${foo} .xctest is dir on OSX
46
42
#else
47
- return self . isFile //test-Package is executable on OSX
43
+ return isFile // otherwise ${foo}.xctest is executable file
48
44
#endif
49
45
}
50
46
}
You can’t perform that action at this time.
0 commit comments