Sha256: 6c2ff12ed053322a078705c5aa547d2c8e6fa735c1ea3c034ef4932aad246796
Contents?: true
Size: 1.47 KB
Versions: 14
Compression:
Stored size: 1.47 KB
Contents
/* * Test runner for phantomjs */ var system = require('system'); var args = system.args.slice(1); var page = require('webpage').create(); page.onConsoleMessage = function(msg) { console.log(msg); }; page.onInitialized = function() { page.evaluate(function () { window.OPAL_SPEC_PHANTOM = true; }); }; page.onCallback = function(data) { switch (data[0]) { case 'stdout': system.stdout.write(data[1] || ''); break; case 'stderr': system.stderr.write(data[1] || ''); break; default: console.error('Unknown callback data: ', data); } }; /* * 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.open(args[0], function(status) { if (status !== 'success') { console.error("Cannot load: " + args[0]); 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
14 entries across 14 versions & 2 rubygems