Sha256: 74a0e8f4879e514fd0c388cb64910fbe452ac6ed5d8cb93949160a5466668b78
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
/* * Test runner for phantomjs */ var args = phantom.args; var page = require('webpage').create(); var url = args[0]; /* * Exit phantom instance "safely" see - https://github.com/ariya/phantomjs/issues/12697 * https://github.com/nobuoka/gulp-qunit/commit/d242aff9b79de7543d956e294b2ee36eda4bac6c */ function phantom_exit(code) { page.close(); setTimeout(function () { phantom.exit(code); }, 0); } page.onConsoleMessage = function(msg) { console.log(msg); }; page.onInitialized = function() { page.evaluate(function () { window.OPAL_SPEC_PHANTOM = true; }); }; var system = require('system'); page.onCallback = function(data) { switch (data[0]) { case 'exit': var status = data[1] || 0; phantom_exit(status); case 'stdout': system.stdout.write(data[1] || ''); break; case 'stderr': system.stderr.write(data[1] || ''); break; default: console.error('Unknown callback data: ', data); } }; page.open(url, function(status) { if (status !== 'success') { console.error("Cannot load: " + url); phantom_exit(1); } else { var timeout = parseInt(args[1] || 60000, 10); var start = Date.now(); var interval = setInterval(function() { if (Date.now() > start + timeout) { console.error("Specs timed out"); phantom_exit(124); } else { var code = page.evaluate(function() { return window.OPAL_SPEC_CODE; }); if (code === 0 || code === 1) { clearInterval(interval); phantom_exit(code); } } }, 500); } });
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
opal-0.9.0.beta2 | tasks/testing/phantomjs1-sprockets.js |
opal-0.9.0.beta1 | tasks/testing/phantomjs1-sprockets.js |