Commit caf73290 caf73290c1995111ef59fc2124815c0b2d51c6e8 by Nicolas Perriault

Merge branch 'master' into skip

2 parents 939cee41 583d1e7b
......@@ -5,3 +5,4 @@ modules/querystring.js
samples/**
tests/**
tmp
./*.js
......
......@@ -69,12 +69,16 @@ CasperError.prototype = Object.getPrototypeOf(new Error());
}
function __die(message) {
if (message) {
console.error(message);
}
phantom.exit(1);
}
function __terminate(message) {
if (message) {
console.log(message);
}
phantom.exit();
}
......@@ -90,13 +94,17 @@ CasperError.prototype = Object.getPrototypeOf(new Error());
}
})(phantom.version);
// Hooks in default phantomjs error handler to print a hint when a possible
// casperjs command misuse is detected.
// Hooks in default phantomjs error handler
phantom.onError = function onPhantomError(msg, trace) {
phantom.defaultErrorHandler.apply(phantom, arguments);
// print a hint when a possible casperjs command misuse is detected
if (msg.indexOf("ReferenceError: Can't find variable: casper") === 0) {
console.error('Hint: you may want to use the `casperjs test` command.');
}
// exits on syntax error
if (msg.indexOf('SyntaxError: Parse error') === 0) {
__die();
}
};
// Patching fs
......
......@@ -375,7 +375,6 @@ Casper.prototype.checkStep = function checkStep(self, onComplete) {
}
} catch (error) {
self.emit('complete.error', error);
throw error;
}
};
......@@ -1387,7 +1386,6 @@ Casper.prototype.runStep = function runStep(step) {
}
} catch (err) {
this.emit('step.error', err);
throw err;
}
if (!skipLog) {
this.emit('step.complete', stepResult);
......
......@@ -285,7 +285,7 @@ Tester.prototype.assertTrue = function assert(subject, message, context) {
}
}, context || {});
if (!result.success && result.doThrow) {
throw new AssertionError(message, result);
throw new AssertionError(message || result.standard, result);
}
return this.processAssertionResult(result);
};
......
qsfjdhf!èrè"èqwnfkmsghfkswjdgfjksn
......@@ -81,6 +81,20 @@ class CasperExecTest(unittest.TestCase):
self.assertCommandOutputEquals(script_path, 'it works')
@timeout(20)
def test_syntax_error(self):
script_path = os.path.join(TEST_ROOT, 'error', 'syntax.js')
self.assertCommandOutputContains(script_path, [
'SyntaxError: Parse error',
], failing=True)
@timeout(20)
def test_syntax_error_in_test(self):
script_path = os.path.join(TEST_ROOT, 'error', 'syntax.js')
self.assertCommandOutputContains('test %s' % script_path, [
'SyntaxError: Parse error',
], failing=True)
@timeout(20)
def test_simple_test_script(self):
script_path = os.path.join(TEST_ROOT, 'tester', 'mytest.js')
self.assertCommandOutputContains('test ' + script_path, [
......