<commit_before>// from https://github.com/chrisgladd/grunt-phantomcss

var fs = require('fs');
var s = fs.separator;

// Parse arguments passed in
var args = JSON.parse(phantom.args[0]);
var paths = args.paths;

var viewportSize = {
  width: args.viewportSize[0],
  height: args.viewportSize[1]
};

// Initialise CasperJs
var phantomCSSPath = paths.phantomcss;
phantom.casperPath = paths.casper;
phantom.injectJs(paths.bin.casper + s + 'bootstrap.js');
phantom.casperTest = true; // fix for CasperError: casper.test property is only available using the `casperjs test` command in Casper 1.1

var casper = require('casper').create({
  viewportSize: viewportSize,
  logLevel: args.logLevel,
  verbose: true
});

// Require and initialise PhantomCSS module
var phantomcss = require(phantomCSSPath + s + 'phantomcss.js');
var fail = false; // Flag for failing tests

// Create report file if reportsRoot set in options
var sendResult = function(result, test) {
  console.log('[' + result + '] ' + JSON.stringify(test));
};

var onFail = function(test) {
  sendResult('Fail', test);
  fail = true;
};

var onPass = function(test) {
  sendResult('Pass', test);
};

var onNewImage = function(test) {
  console.log('[NEW IMAGE] ' + test.filename);
};

var onTimeout = function(test) {
  console.log('[TIMEOUT] ' + test.filename);
};

var onComplete = function(allTests, noOfFails, noOfErrors) {};

phantomcss.init({
  screenshotRoot: args.screenshots || args.screenshotRoot, // Add ability to use original option from PhantomCSS
  failedComparisonsRoot: args.failures || args.failedComparisonsRoot, // Add ability to use original option from PhantomCSS
  libraryRoot: phantomCSSPath, // Give absolute path, otherwise PhantomCSS fails
  onPass: args.onPass || onPass,
  onFail: args.onFail || onFail,
  onTimeout: args.onTimeout || onTimeout,
  onComplete: args.onComplete || onComplete

});

// Run the test scenario
require(args.test);

// End tests and compare screenshots
casper.then(function() {
    phantomcss.compareSession();
  })
  .then(function() {
    casper.test.done();
  })
  .then(function() {
    if (fail) {
      phantom.exit(1);
    } else {
      phantom.exit(0);
    }
  });<commit_msg>Added 'comparisonResultRoot' to list of params passed to phantomcss.init<commit_after>// from https://github.com/chrisgladd/grunt-phantomcss

var fs = require('fs');
var s = fs.separator;

// Parse arguments passed in
var args = JSON.parse(phantom.args[0]);
var paths = args.paths;

var viewportSize = {
  width: args.viewportSize[0],
  height: args.viewportSize[1]
};

// Initialise CasperJs
var phantomCSSPath = paths.phantomcss;
phantom.casperPath = paths.casper;
phantom.injectJs(paths.bin.casper + s + 'bootstrap.js');
phantom.casperTest = true; // fix for CasperError: casper.test property is only available using the `casperjs test` command in Casper 1.1

var casper = require('casper').create({
  viewportSize: viewportSize,
  logLevel: args.logLevel,
  verbose: true
});

// Require and initialise PhantomCSS module
var phantomcss = require(phantomCSSPath + s + 'phantomcss.js');
var fail = false; // Flag for failing tests

// Create report file if reportsRoot set in options
var sendResult = function(result, test) {
  console.log('[' + result + '] ' + JSON.stringify(test));
};

var onFail = function(test) {
  sendResult('Fail', test);
  fail = true;
};

var onPass = function(test) {
  sendResult('Pass', test);
};

var onNewImage = function(test) {
  console.log('[NEW IMAGE] ' + test.filename);
};

var onTimeout = function(test) {
  console.log('[TIMEOUT] ' + test.filename);
};

var onComplete = function(allTests, noOfFails, noOfErrors) {};

phantomcss.init({
  screenshotRoot: args.screenshots || args.screenshotRoot, // Add ability to use original option from PhantomCSS
  failedComparisonsRoot: args.failures || args.failedComparisonsRoot, // Add ability to use original option from PhantomCSS
  comparisonResultRoot: args.comparisonResultRoot,
  libraryRoot: phantomCSSPath, // Give absolute path, otherwise PhantomCSS fails
  onPass: args.onPass || onPass,
  onFail: args.onFail || onFail,
  onTimeout: args.onTimeout || onTimeout,
  onComplete: args.onComplete || onComplete

});

// Run the test scenario
require(args.test);

// End tests and compare screenshots
casper.then(function() {
    phantomcss.compareSession();
  })
  .then(function() {
    casper.test.done();
  })
  .then(function() {
    if (fail) {
      phantom.exit(1);
    } else {
      phantom.exit(0);
    }
  });
{'fraction_non_alphanumeric': 0.13398402839396628, 'fraction_numerical': 0.003105590062111801, 'mean_word_length': 4.224797219003476, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2586449', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1427, 'n_words': 380}