Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
Merge pull request #158 from BYK/bump-phantom
Browse files Browse the repository at this point in the history
Bump grunt-lib-phantomjs to latest master
  • Loading branch information
kmiyashiro committed Mar 27, 2016
2 parents 3bd773a + 28d99c0 commit 6681bc1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -26,11 +26,11 @@
"node": "*"
},
"scripts": {
"test": "./node_modules/.bin/grunt test"
"test": "grunt test"
},
"dependencies": {
"grunt-lib-phantomjs": "^0.7.1",
"mocha": "^2.3.4",
"grunt-lib-phantomjs": "gruntjs/grunt-lib-phantomjs#776bc346a8b7e151fe55c7f6dcb5563c0272e51b",
"mocha": "^2.4.5",
"lodash": "^3.9.0"
},
"peerDependencies": {
Expand Down
7 changes: 4 additions & 3 deletions phantomjs/main.js
Expand Up @@ -14,13 +14,14 @@

var fs = require('fs');
var _ = require('lodash');
var system = require('system');

// The temporary file used for communications.
var tmpfile = phantom.args[0];
var tmpfile = system.args[1];
// The page .html file to load.
var url = phantom.args[1];
var url = system.args[2];
// Extra, optionally overridable stuff.
var options = JSON.parse(phantom.args[2] || {});
var options = JSON.parse(system.args[3] || {});

// Keep track of the last time a client message was sent.
var last = new Date();
Expand Down
14 changes: 11 additions & 3 deletions tasks/mocha.js
Expand Up @@ -181,7 +181,11 @@ module.exports = function(grunt) {
var consoleLog = console.log;

// Only hijack if we really need to
// Some "good" reporters like XUnit accept an `output` option
// and we pass `dest` there but there's no good way to detect
// if a reporter supports this so stub out console.log just in case.
if (dest) {
grunt.file.delete(dest)
console.log = function() {
consoleLog.apply(console, arguments);
output.push(util.format.apply(util, arguments));
Expand Down Expand Up @@ -226,7 +230,7 @@ module.exports = function(grunt) {
grunt.fatal('Specified reporter is unknown or unresolvable: ' + options.reporter);
}
// XUnit reporter requires second arg (options)
reporter = new Reporter(runner, {});
reporter = new Reporter(runner, { reporterOptions: { output: dest } });

// Launch PhantomJS.
phantomjs.spawn(url, {
Expand Down Expand Up @@ -271,14 +275,18 @@ module.exports = function(grunt) {
}
});
},

// All tests have been run.
function() {
if (dest) {
// Restore console.log to original and write the output
console.log = consoleLog;
grunt.file.write(dest, output.join('\n'));
}

if (!grunt.file.exists(dest)) {
// Write only if our reporter ignored our `output` option
grunt.file.write(dest, output.join('\n'));
}
}
var stats = helpers.reduceStats(testStats);

if (stats.failures === 0) {
Expand Down

0 comments on commit 6681bc1

Please sign in to comment.