<commit_before>var gulp = require('gulp');
var resemble = require('node-resemble-js');
var paths = require('../util/paths');
var fs = require('fs');
var path = require('path');
var _ = require('underscore');


gulp.task('compare', function (done) {
  var compareConfig = JSON.parse(fs.readFileSync(paths.compareConfigFileName, 'utf8'));

  function updateProgress() {
    var results = {};
    _.each(compareConfig.testPairs, function (pair) {
      if (!results[pair.testStatus]) {
        results[pair.testStatus] = 0;
      }
      !results[pair.testStatus]++;
    });
    if (!results.running){
      console.log ("\nTest completed...")
      console.log ((results.pass || 0) + " Passed")
      console.log ((results.fail || 0) + " Failed\n")

      if (results.fail) {
        console.log ("*** Mismatch errors found ***")
        console.log ("For a detailed report run `gulp openReport`\n")
        // done(new Error('Mismatch errors found.')); //uncomment this line to have gulp pass an error back.
      } else {
        done();
      }

    }
  }


  _.each(compareConfig.testPairs, function (pair) {
    pair.testStatus = "running";

    var referencePath = path.join(paths.backstop, pair.reference);
    var testPath = path.join(paths.backstop, pair.test);

    resemble(referencePath).compareTo(testPath).onComplete(function(data) {
      var imageComparisonFailed = !data.isSameDimensions || data.misMatchPercentage > pair.misMatchThreshold;

      if (imageComparisonFailed) {
        pair.testStatus = "fail";
        console.log('ERROR:', pair.fileName);
      } else {
        pair.testStatus = "pass";
        console.log('OK:', pair.fileName);
      }
      updateProgress();
    });
  });
});<commit_msg>Adding label to console log compare output.<commit_after>var gulp = require('gulp');
var resemble = require('node-resemble-js');
var paths = require('../util/paths');
var fs = require('fs');
var path = require('path');
var _ = require('underscore');


gulp.task('compare', function (done) {
  var compareConfig = JSON.parse(fs.readFileSync(paths.compareConfigFileName, 'utf8'));

  function updateProgress() {
    var results = {};
    _.each(compareConfig.testPairs, function (pair) {
      if (!results[pair.testStatus]) {
        results[pair.testStatus] = 0;
      }
      !results[pair.testStatus]++;
    });
    if (!results.running){
      console.log ("\nTest completed...")
      console.log ((results.pass || 0) + " Passed")
      console.log ((results.fail || 0) + " Failed\n")

      if (results.fail) {
        console.log ("*** Mismatch errors found ***")
        console.log ("For a detailed report run `gulp openReport`\n")
        // done(new Error('Mismatch errors found.')); //uncomment this line to have gulp pass an error back.
      } else {
        done();
      }

    }
  }


  _.each(compareConfig.testPairs, function (pair) {
    pair.testStatus = "running";

    var referencePath = path.join(paths.backstop, pair.reference);
    var testPath = path.join(paths.backstop, pair.test);

    resemble(referencePath).compareTo(testPath).onComplete(function(data) {
      var imageComparisonFailed = !data.isSameDimensions || data.misMatchPercentage > pair.misMatchThreshold;

      if (imageComparisonFailed) {
        pair.testStatus = "fail";
        console.log('ERROR:', pair.label, pair.fileName);
      } else {
        pair.testStatus = "pass";
        console.log('OK:', pair.label, pair.fileName);
      }
      updateProgress();
    });
  });
});
{'fraction_non_alphanumeric': 0.15896118721461186, 'fraction_numerical': 0.00228310502283105, 'mean_word_length': 3.0194954128440368, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '2602944', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1044, 'n_words': 228}