Commit ea07523f authored by Drew's avatar Drew

Tests should return true/false

We need this to report failures to XCTest (and probably for our own runner as well, but not included in this patch)
parent e421fa5c
......@@ -19,11 +19,13 @@ import Glibc
#endif
protocol CarolineEngine {
func testAll(_ tests: [CarolineTest])
@warn_unused_result
func testAll(_ tests: [CarolineTest]) -> Bool
}
public class CarolineCoreEngine : CarolineEngine {
public func testAll(_ tests: [CarolineTest]) {
@warn_unused_result
public func testAll(_ tests: [CarolineTest]) -> Bool {
setvbuf(stdout, nil, _IOLBF, 0)
for test in tests {
if test.skip {
......@@ -47,6 +49,9 @@ public class CarolineCoreEngine : CarolineEngine {
}
print("Test execution finished with \(tests.count) tests and \(failures) failures.")
print ("Skipped \(skipped) tests.")
if failures > 0 { return false }
return true
}
public init() { }
}
\ No newline at end of file
......@@ -41,13 +41,15 @@ func performXcodeIntegration() -> Bool {
xcTestFile += "import XCTest\n"
xcTestFile += "import CarolineCore\n"
xcTestFile += "@testable import MyMacFramework\n"
xcTestFile += "@testable import \(target)\n"
xcTestFile += "\n"
xcTestFile += "class CarolineEngineTests: XCTestCase {\n"
xcTestFile += " func testAllCarolineTests() {\n"
xcTestFile += allTestsDeclaration(tests: tests, indentation: 8) + "\n"
xcTestFile += " let engine = CarolineCoreEngine()\n"
xcTestFile += " engine.testAll(allTests)\n"
xcTestFile += " if !engine.testAll(allTests) {\n"
xcTestFile += " XCTFail(\"Caroline tests failed\")\n"
xcTestFile += " }\n"
xcTestFile += " }\n"
xcTestFile += "}\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment