Skip to content

Commit b813132

Browse files
committed
run and verify that swift-test are passing
1 parent 30c2f3a commit b813132

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

Tests/Functional/TestMiscellaneous.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,11 @@ class MiscellaneousTestCase: XCTestCase {
347347
fixture(name: "SwiftTesting/SingleTarget", file: #file, line: #line) { prefix in
348348
XCTAssertBuilds(prefix)
349349
XCTAssertFileExists(prefix, ".build", "debug", "Foo.swiftmodule")
350+
XCTAssertTests(prefix)
350351
#if os(OSX)
351352
XCTAssertDirectoryExists(prefix, ".build", "debug", "Package.xctest")
352353
#else
353-
//FIXME: test-Package not generated during swift-build on linux so this will fail.
354-
//XCTAssertFileExists(prefix, ".build", "debug", "test-Package")
354+
XCTAssertFileExists(prefix, ".build", "debug", "test-Package")
355355
#endif
356356

357357
}

Tests/Functional/Utilities.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,31 @@ func executeSwiftBuild(chdir: String, configuration: Configuration = .Debug, pri
131131
}
132132
}
133133

134+
//TODO: refactor swift-build and swift-test tools runing
135+
func executeSwiftTest(dir: String, printIfError: Bool = false) throws -> String {
136+
let toolPath = Resources.findExecutable("swift-test")
137+
let env = [String:String]()
138+
let args = [toolPath]
139+
140+
var out = ""
141+
do {
142+
// FIXME: this probably should be refactored to --chdir arg in swift-test
143+
let cwd = try getcwd()
144+
defer { _ = try? POSIX.chdir(cwd) }
145+
try POSIX.chdir(dir)
146+
147+
try popen(args, redirectStandardError: true, environment: env) {
148+
out += $0
149+
}
150+
return out
151+
} catch {
152+
if printIfError {
153+
print(out)
154+
}
155+
throw error
156+
}
157+
}
158+
134159
func mktmpdir(file: StaticString = #file, line: UInt = #line, @noescape body: (String) throws -> Void) {
135160
do {
136161
try POSIX.mkdtemp("spm-tests") { dir in
@@ -169,6 +194,16 @@ func XCTAssertBuildFails(paths: String..., file: StaticString = #file, line: UIn
169194
}
170195
}
171196

197+
func XCTAssertTests(paths: String..., file: StaticString = #file, line: UInt = #line) {
198+
let prefix = Path.join(paths)
199+
do {
200+
print(" Testing")
201+
try executeSwiftTest(prefix, printIfError: true)
202+
} catch {
203+
XCTFail("swift-test failed:\n\n\(error)\n", file: file, line: line)
204+
}
205+
}
206+
172207
func XCTAssertFileExists(paths: String..., file: StaticString = #file, line: UInt = #line) {
173208
let path = Path.join(paths)
174209
if !path.isFile {

0 commit comments

Comments
 (0)