Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 70e7633

Browse files
committed
Demonstrates emitting an appropriate status code on exit
The runner returns a results collection, and this class has methods for determining how may failures, warnings, skipped tests, unknown results, and success results were encountered. We can add warnings and failures to determine if they are a non-zero number, and, if so, exit with a status of 1.
1 parent 52ca693 commit 70e7633

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/book/usage.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ $runner->addCheck(new Check\DiskFree(100000000, '/tmp'));
8888
$runner->addReporter(new BasicConsole(80, true));
8989

9090
// Run all checks
91-
$runner->run();
91+
$results = $runner->run();
92+
93+
// Emit an appropriate exit code
94+
$status = ($results->getFailureCount() + $results->getWarningCount()) > 0 ? 1 : 0;
95+
exit($status);
9296
```
9397

9498
You can now run the file in your console (command line):

0 commit comments

Comments
 (0)