Skip to content

Commit

Permalink
fix return app code
Browse files Browse the repository at this point in the history
  • Loading branch information
Szabo Bogdan committed Jun 14, 2017
1 parent 76c8cb7 commit 920cf1c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions lifecycle/trial/runner.d
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,37 @@ auto runTests(string testName = "") {
return runTests(LifeCycleListeners.instance.getTestCases, testName);
}

/// Check if a suite result list is a success
bool isSuccess(SuiteResult[] results) {
return results.map!(a => a.tests).joiner.map!(a => a.status).all!(a => a == TestResult.Status.success);
}

version(unittest) {
import fluent.asserts;
}

/// It should return true for an empty result
unittest {
[].isSuccess.should.equal(true);
}

/// It should return true if all the tests succeded
unittest {
SuiteResult[] results = [ SuiteResult("") ];
results[0].tests = [ new TestResult("") ];
results[0].tests[0].status = TestResult.Status.success;

results.isSuccess.should.equal(true);
}

/// It should return false if one the tests failed
unittest {
SuiteResult[] results = [ SuiteResult("") ];
results[0].tests = [ new TestResult("") ];
results[0].tests[0].status = TestResult.Status.failure;

results.isSuccess.should.equal(false);
}

/// The lifecycle listeners collections. You must use this instance in order
/// to extend the runner. You can have as many listeners as you want. The only restriction
Expand Down
4 changes: 2 additions & 2 deletions runner/trial/generator.d
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ string generateTestFile(Settings settings, bool hasTrialDependency, string[2][]
}

code ~= `
void main() {
int main() {
setupLifecycle(` ~ settings.toCode ~ `);` ~ "\n\n";

if(hasTrialDependency) {
Expand All @@ -104,7 +104,7 @@ string generateTestFile(Settings settings, bool hasTrialDependency, string[2][]
code ~= generateDiscoveries(settings.testDiscovery, modules, hasTrialDependency);

code ~= `
runTests("` ~ testName ~ `");
return runTests("` ~ testName ~ `").isSuccess ? 0 : 1;
}
version (unittest) shared static this()
Expand Down

0 comments on commit 920cf1c

Please sign in to comment.