X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Fphantom%2Frun-jasmine.js;h=b3702d4e2786c3a5c3dbec26f7c6fa4f24674dd5;hb=5a126c522666307f9dffd7835c70fe1889d276cc;hp=a1f870441b025930e1abdb67d2ec2d8b8ff7b850;hpb=03bf0ec199ccfcbd35d511878f66fcfe43ab0ee2;p=mkws-moved-to-github.git diff --git a/test/phantom/run-jasmine.js b/test/phantom/run-jasmine.js index a1f8704..b3702d4 100644 --- a/test/phantom/run-jasmine.js +++ b/test/phantom/run-jasmine.js @@ -46,7 +46,13 @@ function wait_for_jasmine(checkFx, readyFx, failFx, timeout) { clearInterval(interval); result.time = (new Date().getTime() - start); result.failed ? failFx(result) : readyFx(result); - phantom.exit(result.failed == 0 ? 0 : 2); + + // See: https://github.com/ariya/phantomjs/issues/12697 + // phantomjs 1.9.8 + page.close(); + setTimeout(function () { + phantom.exit(result.failed == 0 ? 0 : 2); + }, 0); } // timeout @@ -65,6 +71,19 @@ function wait_for_jasmine(checkFx, readyFx, failFx, timeout) { }, 500); //< repeat check every N ms }; +function dump_html(file) { + // not yet implemented + var spawn = require('child_process').spawn, + lynx = spawn("lynx", ["-nolist", "-dump", file]); + + lynx.stdout.on('data', function (data) { + console.log('lynx >> ' + data); + }); + + // lynx.stderr.on('data', function (data) { console.log('stderr: ' + data); }); + // lynx.on('close', function (code) { console.log('child process exited with code ' + code) }); +}; + // redirect webkit console.log() output page.onConsoleMessage = function (message) { if (debug >= 2) console.log(message); @@ -95,14 +114,14 @@ page.open(url, function (status) { var exit = wait_for_jasmine(function () { return page.evaluate(function () { - if (!window || !window.$ || !window.mkws) { + if (!window || !window.mkws || !window.mkws.$) { console.log("No window object found"); return false; } - var $ = window.$; + var $ = window.mkws.$; var error_msg = [""]; - var passing = $(".passingAlert").text() || window.$(".failingAlert").text(); + var passing = $(".passingAlert").text() || $(".failingAlert").text(); // extract failed tests var list = $('.results > #details > .specDetail.failed'); @@ -123,7 +142,7 @@ page.open(url, function (status) { html: $("html").html(), duration: $(".duration").text(), error_msg: error_msg, - failed: list.length, + failed: (list.length > 0 || !passing), passing: passing }; }) @@ -142,15 +161,17 @@ page.open(url, function (status) { var error_png = "./mkws-error.png"; var error_html = "./mkws-error.html"; + var html = result.html + "\n\n\n"; + var fs = require('fs'); + fs.write(error_html, html, "wb"); + dump_html(error_html); + console.log("MKWS tests failed after " + result.time / 1000 + " seconds"); console.log(result.error_msg.join("\n")); console.log("keep screenshot in '" + error_png + "'"); page.render(error_png); console.log("keep html DOM in '" + error_html + "'"); - console.log("you may run: lynx -nolist -dump " + error_html); - var html = result.html + "\n\n\n"; - var fs = require('fs'); - fs.write(error_html, html, "wb"); + // console.log("you may run: lynx -nolist -dump " + error_html); }, run_time * 1000); });