Commit e5caf596 e5caf596322943f5ccbf6883f3ac5d5a902d32ab by Nicolas Perriault

fixes #704 - added --auto-exit=no test runner option

1 parent e4195f27
......@@ -159,6 +159,15 @@ Options are prefixed with a double-dash (``--``):
- ``--xunit=<filename>`` will export test suite results in a :ref:`XUnit XML file <xunit_report>`
- ``--direct`` will print :doc:`log messages <logging>` directly to the console
- ``--log-level=<logLevel>`` sets the logging level (see the :doc:`related section <logging>`)
- ``--auto-exit=no`` prevents the test runner to exit when all the tests have been executed; this usually allows performing supplementary operations, though implies to exit casper manually listening to the ``exit`` tester event::
// $ casperjs test --auto-exit=no
casper.test.on("exit", function() {
someTediousAsyncProcess(function() {
casper.exit();
});
});
.. versionadded:: 1.0
......
......@@ -1482,7 +1482,9 @@ Tester.prototype.renderFailureDetails = function renderFailureDetails() {
/**
* Render tests results, an optionally exit phantomjs.
*
* @param Boolean exit
* @param Boolean exit Exit casper after results have been rendered?
* @param Number status Exit status code (default: 0)
* @param String save Optional path to file where to save the results log
*/
Tester.prototype.renderResults = function renderResults(exit, status, save) {
"use strict";
......
......@@ -59,8 +59,9 @@ function checkArgs() {
casper.options.colorizerType = cls;
casper.colorizer = colorizer.create(cls);
}
casper.test.options.concise = casper.cli.get('concise') || false;
casper.test.options.failFast = casper.cli.get('fail-fast') || false;
casper.test.options.concise = casper.cli.get('concise', false);
casper.test.options.failFast = casper.cli.get('fail-fast', false);
casper.test.options.autoExit = casper.cli.get('auto-exit') !== "no";
// test paths are passed as args
if (casper.cli.args.length) {
......@@ -99,7 +100,7 @@ function initRunner() {
// test suites completion listener
casper.test.on('tests.complete', function() {
this.renderResults(true, undefined, casper.cli.get('xunit') || undefined);
this.renderResults(this.options.autoExit, undefined, casper.cli.get('xunit') || undefined);
if (this.options.failFast && this.testResults.failures.length > 0) {
casper.warn('Test suite failed fast, all tests may not have been executed.');
}
......