Skip to content

Commit c1dfa00

Browse files
committed
Merge ks/describe-throws
2 parents 388a1b0 + 974591c commit c1dfa00

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

Sources/Build/Error.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright 2015 - 2016 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
*/
10+
11+
public enum Error: ErrorType {
12+
case NoModules
13+
case InvalidPlatformPath
14+
}

Sources/Build/describe().swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Utility
1919
public func describe(prefix: String, _ conf: Configuration, _ modules: [Module], _ products: [Product], Xcc: [String], Xld: [String], Xswiftc: [String]) throws -> String {
2020

2121
guard modules.count > 0 else {
22-
fatalError("No modules input") //TODO throw
22+
throw Error.NoModules
2323
}
2424

2525
let Xcc = Xcc.flatMap{ ["-Xcc", $0] } + extraImports()
@@ -54,10 +54,11 @@ public func describe(prefix: String, _ conf: Configuration, _ modules: [Module],
5454
args.append("-enable-testing")
5555

5656
#if os(OSX)
57-
//TODO if this fails and is required, throw
5857
if let platformPath = Resources.path.platformPath {
5958
let path = Path.join(platformPath, "Developer/Library/Frameworks")
6059
args += ["-F", path]
60+
} else {
61+
throw Error.InvalidPlatformPath
6162
}
6263
#endif
6364

@@ -129,10 +130,11 @@ public func describe(prefix: String, _ conf: Configuration, _ modules: [Module],
129130
#if os(OSX)
130131
args += ["-Xlinker", "-bundle"]
131132

132-
//TODO if this fails and is required, throw
133133
if let platformPath = Resources.path.platformPath {
134134
let path = Path.join(platformPath, "Developer/Library/Frameworks")
135135
args += ["-F", path]
136+
} else {
137+
throw Error.InvalidPlatformPath
136138
}
137139

138140
// TODO should be llbuild rules
@@ -149,7 +151,6 @@ public func describe(prefix: String, _ conf: Configuration, _ modules: [Module],
149151
let testDirectory = firstTestModule.sources.root.parentDirectory
150152
let main = Path.join(testDirectory, "LinuxMain.swift")
151153
args.append(main)
152-
153154
args.append("-emit-executable")
154155
args += ["-I", prefix]
155156
#endif

Tests/Build/DescribeTests.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright 2015 - 2016 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
*/
10+
11+
import Build
12+
import XCTest
13+
14+
final class DescribeTests: XCTestCase {
15+
func testDescribingNoModulesThrows() {
16+
do {
17+
let _ = try describe("foo", .Debug, [], [], Xcc: [], Xld: [])
18+
XCTFail("This call should throw")
19+
} catch Build.Error.NoModules {
20+
XCTAssert(true, "This error should be throw")
21+
} catch {
22+
XCTFail("No other error should be thrown")
23+
}
24+
}
25+
}

Tests/LinuxMain.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
// we want to generate this.
33
// read the AST and generate it
4-
// ticket:
4+
// ticket:
55

66
import XCTest
77

@@ -37,4 +37,5 @@ XCTMain([
3737
VersionTests(),
3838
WalkTests(),
3939
ModuleMapsTestCase(),
40+
DescribeTests(),
4041
])

0 commit comments

Comments
 (0)