run-jasmine example: Ensure exit code is always returned.

https://github.com/ariya/phantomjs/pull/12486
2.0
Marcel Duran 2014-08-20 15:49:18 -07:00 committed by Ariya Hidayat
parent 1e7829db97
commit 3be7005a17
1 changed files with 25 additions and 20 deletions

View File

@ -50,8 +50,8 @@ page.onConsoleMessage = function(msg) {
page.open(system.args[1], function(status){
if (status !== "success") {
console.log("Unable to access network");
phantom.exit();
console.log("Unable to open " + system.args[1]);
phantom.exit(1);
} else {
waitFor(function(){
return page.evaluate(function(){
@ -59,6 +59,7 @@ page.open(system.args[1], function(status){
});
}, function(){
var exitCode = page.evaluate(function(){
try {
console.log('');
console.log(document.body.querySelector('.description').innerText);
var list = document.body.querySelectorAll('.results > #details > .specDetail.failed');
@ -79,6 +80,10 @@ page.open(system.args[1], function(status){
console.log(document.body.querySelector('.alert > .passingAlert.bar').innerText);
return 0;
}
} catch (ex) {
console.log(ex);
return 1;
}
});
phantom.exit(exitCode);
});