Commit 04be70a0 04be70a062a6347626345c826ae9ccea95bfcfd9 by Nicolas Perriault

sync with master

2 parents ce3860f5 5e488845
......@@ -4,6 +4,7 @@ CasperJS Changelog
XXXX-XX-XX, v1.0.0
------------------
- fixed [#215](https://github.com/n1k0/casperjs/issues/215) - fixed broken `--fail-fast` option creating an endless loop on error
- fixed `Tester.renderFailureDetails()` which couldn't print failure details correctly in certain circumstances
- fixed `Casper.getHTML()` wasn't retrieving active frame contents when using `Casper.withFrame()`
- merged PR [#322](https://github.com/n1k0/casperjs/pull/322) - Support number in `Casper.withFrame()`
......
......@@ -45,7 +45,7 @@ CASPER_PATH = os.path.abspath(os.path.join(os.path.dirname(resolve(__file__)), '
PHANTOMJS_ARGS = []
SYS_ARGS = sys.argv[1:]
if SYS_ARGS[0] == '__selfcommandtest':
if len(SYS_ARGS) and SYS_ARGS[0] == '__selfcommandtest':
print('Starting Python executable tests...')
pkg_version = json.loads(open('package.json').read()).get('version')
scripts_path = os.path.join(CASPER_PATH, 'tests', 'commands')
......
Subproject commit 0f6c923dbfe9bb605adfa5c9d6c8cd3ac1d56586
Subproject commit 1f932d7f7b77014f7abb7a0e53e8ef1f05dd4d3e
......
......@@ -158,7 +158,7 @@ var Casper = function Casper(options) {
this.on('error', function(msg, backtrace) {
if (msg === this.test.SKIP_MESSAGE) {
return this.warn(f('--fail-fast: aborted remaining tests in "%s"', this.test.currentTestFile));
return;
}
var c = this.getColorizer();
var match = /^(.*): __mod_error(.*):: (.*)/.exec(msg);
......
......@@ -644,7 +644,7 @@
} else if (typeof data === "string") {
dataString = data;
}
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
}
xhr.send(method === "POST" ? dataString : null);
return xhr.responseText;
......
......@@ -61,10 +61,13 @@ var Tester = function Tester(casper, options) {
throw new CasperError("Tester needs a Casper instance");
}
var self = this;
this.casper = casper;
this.SKIP_MESSAGE = '__termination__';
this.aborted = false;
this.executed = 0;
this.currentTestFile = null;
this.currentSuite = undefined;
......@@ -118,19 +121,26 @@ var Tester = function Tester(casper, options) {
if (!phantom.casperTest) {
return;
}
if (msg === self.SKIP_MESSAGE) {
this.warn(f('--fail-fast: aborted remaining tests in "%s"', self.currentTestFile));
self.aborted = true;
return self.done();
}
var line = 0;
if (!utils.isString(msg) && msg.indexOf(this.SKIP_MESSAGE) === -1) {
if (!utils.isString(msg)) {
try {
line = backtrace[0].line;
} catch (e) {}
}
this.test.uncaughtError(msg, this.test.currentTestFile, line, backtrace);
this.test.done();
self.uncaughtError(msg, self.currentTestFile, line, backtrace);
self.done();
});
this.casper.on('step.error', function onStepError(e) {
this.test.uncaughtError(e, this.test.currentTestFile);
this.test.done();
if (e.message !== self.SKIP_MESSAGE) {
self.uncaughtError(e, self.currentTestFile);
}
self.done();
});
};
......@@ -1064,9 +1074,10 @@ Tester.prototype.runSuites = function runSuites() {
if (self.running) {
return;
}
if (self.currentSuiteNum === testFiles.length) {
if (self.currentSuiteNum === testFiles.length || self.aborted) {
self.emit('tests.complete');
clearInterval(interval);
self.aborted = false;
} else {
self.runTest(testFiles[self.currentSuiteNum]);
self.currentSuiteNum++;
......