From c21bcb5c034b5948107c66409d7e43265c6675b7 Mon Sep 17 00:00:00 2001 From: Ankit Aggarwal Date: Sat, 27 Feb 2016 17:34:32 +0530 Subject: [PATCH 1/3] Throw error if `debug.yaml` not found --- Sources/swift-test/Error.swift | 22 ++++++++++++++++++++++ Sources/swift-test/main.swift | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 Sources/swift-test/Error.swift diff --git a/Sources/swift-test/Error.swift b/Sources/swift-test/Error.swift new file mode 100644 index 00000000000..6664a45adcb --- /dev/null +++ b/Sources/swift-test/Error.swift @@ -0,0 +1,22 @@ +/* +This source file is part of the Swift.org open source project + +Copyright 2015 - 2016 Apple Inc. and the Swift project authors +Licensed under Apache License v2.0 with Runtime Library Exception + +See http://swift.org/LICENSE.txt for license information +See http://swift.org/CONTRIBUTORS.txt for Swift project authors +*/ + +enum Error: ErrorType { + case DebugYAMLNotFound +} + +extension Error: CustomStringConvertible { + var description: String { + switch self { + case .DebugYAMLNotFound: + return "build the package using `swift build` before running tests" + } + } +} \ No newline at end of file diff --git a/Sources/swift-test/main.swift b/Sources/swift-test/main.swift index 115a5dfca32..8a1971e7ef2 100644 --- a/Sources/swift-test/main.swift +++ b/Sources/swift-test/main.swift @@ -24,6 +24,8 @@ do { setenv("SPM_INSTALL_PATH", dir.build, 0) let yamlPath = Path.join(dir.build, "debug.yaml") + if !yamlPath.exists { throw Error.DebugYAMLNotFound } + try build(YAMLPath: yamlPath, target: "test") let success = test(dir.build, "debug") exit(success ? 0 : 1) From d590245b3b447211f9f0d660236ac9b184c3868b Mon Sep 17 00:00:00 2001 From: Ankit Aggarwal Date: Sun, 28 Feb 2016 00:25:59 +0530 Subject: [PATCH 2/3] Change if to guard --- Sources/swift-test/main.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/swift-test/main.swift b/Sources/swift-test/main.swift index 8a1971e7ef2..a926b1ddf1a 100644 --- a/Sources/swift-test/main.swift +++ b/Sources/swift-test/main.swift @@ -24,7 +24,7 @@ do { setenv("SPM_INSTALL_PATH", dir.build, 0) let yamlPath = Path.join(dir.build, "debug.yaml") - if !yamlPath.exists { throw Error.DebugYAMLNotFound } + guard yamlPath.exists else { throw Error.DebugYAMLNotFound } try build(YAMLPath: yamlPath, target: "test") let success = test(dir.build, "debug") From 997f2c2fed84de779c9fc6ba999d4dcdbdb5cbb1 Mon Sep 17 00:00:00 2001 From: Ankit Aggarwal Date: Sun, 28 Feb 2016 00:32:31 +0530 Subject: [PATCH 3/3] Add \n at EOF --- Sources/swift-test/Error.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/swift-test/Error.swift b/Sources/swift-test/Error.swift index 6664a45adcb..05582ddb2a8 100644 --- a/Sources/swift-test/Error.swift +++ b/Sources/swift-test/Error.swift @@ -19,4 +19,4 @@ extension Error: CustomStringConvertible { return "build the package using `swift build` before running tests" } } -} \ No newline at end of file +}