<commit_before>/**
 * @fileOverview JUnit XML reporter for Jasmine v2.0.0rc5
 *
 * The JUnit XML reporter was adapted from <NAME> JUnit reporter for
 * Jasmine v1.3, Copyright (c) 2010 <NAME>, MIT licensed:
 * https://github.com/larrymyers/jasmine-reporters
 *
 * The reporter does not properly support nested test suites.
 */
/*global module*/

function elapsed(startTime, endTime) {
  return (endTime - startTime)/1000;
}

function ISODateString(d) {
  function pad(n) { return n < 10 ? '0'+n : n; }

  return d.getFullYear() + '-' +
      pad(d.getMonth()+1) + '-' +
      pad(d.getDate()) + 'T' +
      pad(d.getHours()) + ':' +
      pad(d.getMinutes()) + ':' +
      pad(d.getSeconds());
}

function trim(str) {
  return str.replace(/^\s+/, '' ).replace(/\s+$/, '' );
}

function escapeInvalidXmlChars(str) {
  return str.replace(/\&/g, '&amp;')
      .replace(/</g, '&lt;')
      .replace(/\>/g, '&gt;')
      .replace(/\"/g, '&quot;')
      .replace(/\'/g, '&apos;');
}


/**
 * Generates JUnit XML for the given spec run.
 * Allows the test results to be used in java based CI
 * systems like CruiseControl and Hudson.
 *
 * @param {string} savePath where to save the files
 */
var JUnitXmlReporter = function (savePath) {
  this.savePath = savePath || '';
  this.runningSuites = [];
  this.suites = [];
};


JUnitXmlReporter.prototype.suiteStarted = function (suite) {
  this.suites.push(suite);
  this.runningSuites.push(suite);
  suite.startTime = new Date();
};


JUnitXmlReporter.prototype.suiteDone = function (suite) {
  suite.startTime = suite.startTime || new Date();
  suite.duration = elapsed(suite.startTime, new Date());
  this.runningSuites.pop(suite);
};


JUnitXmlReporter.prototype.specStarted = function (spec) {
  spec.startTime = new Date();
  var suite = this.runningSuites[this.runningSuites.length - 1];
  if (!suite.specs) {
    suite.specs = [];
  }
  suite.specs.push(spec);
  spec.suite = suite;
};


JUnitXmlReporter.prototype.specDone = function (spec) {
  spec.duration = elapsed(spec.startTime, new Date());
  spec.duration = elapsed(spec.startTime, new Date());
  spec.classname = this.getFullName(spec.suite).replace(/\./g, '');
  spec.output = '<testcase ' +
    'classname="' + spec.classname + '" ' +
    'name="' + escapeInvalidXmlChars(spec.description) + '" ' +
    'time="' + spec.duration + '">';

  var failure = '';
  var failures = 0;
  spec.failedExpectations.forEach(function (expectation) {
    failures += 1;
    failure += (failures + ': ' + escapeInvalidXmlChars(expectation.message) + ' ');
  });
  if (failure) {
    spec.output += '\n      <failure>' + trim(failure) + '</failure>\n    ';
  }
  spec.output += '</testcase>';
};


JUnitXmlReporter.prototype.jasmineDone = function () {
  var self = this;
  this.suites.forEach(function (suite) {
    var fileName = 'report-' + self.getFullName(suite, true) + '.xml';<commit_msg>Junit reporting: improved test name in XML results<commit_after>/**
 * @fileOverview JUnit XML reporter for Jasmine v2.0.0rc5
 *
 * The JUnit XML reporter was adapted from Larry Myers JUnit reporter for
 * Jasmine v1.3, Copyright (c) 2010 <NAME>, MIT licensed:
 * https://github.com/larrymyers/jasmine-reporters
 *
 * The reporter does not properly support nested test suites.
 */
/*global module*/

function elapsed(startTime, endTime) {
  return (endTime - startTime)/1000;
}

function ISODateString(d) {
  function pad(n) { return n < 10 ? '0'+n : n; }

  return d.getFullYear() + '-' +
      pad(d.getMonth()+1) + '-' +
      pad(d.getDate()) + 'T' +
      pad(d.getHours()) + ':' +
      pad(d.getMinutes()) + ':' +
      pad(d.getSeconds());
}

function trim(str) {
  return str.replace(/^\s+/, '' ).replace(/\s+$/, '' );
}

function escapeInvalidXmlChars(str) {
  return str.replace(/\&/g, '&amp;')
      .replace(/</g, '&lt;')
      .replace(/\>/g, '&gt;')
      .replace(/\"/g, '&quot;')
      .replace(/\'/g, '&apos;');
}


/**
 * Generates JUnit XML for the given spec run.
 * Allows the test results to be used in java based CI
 * systems like CruiseControl and Hudson.
 *
 * @param {string} savePath where to save the files
 */
var JUnitXmlReporter = function (savePath) {
  this.savePath = savePath || '';
  this.runningSuites = [];
  this.suites = [];
};


JUnitXmlReporter.prototype.suiteStarted = function (suite) {
  this.suites.push(suite);
  this.runningSuites.push(suite);
  suite.startTime = new Date();
};


JUnitXmlReporter.prototype.suiteDone = function (suite) {
  suite.startTime = suite.startTime || new Date();
  suite.duration = elapsed(suite.startTime, new Date());
  this.runningSuites.pop(suite);
};


JUnitXmlReporter.prototype.specStarted = function (spec) {
  spec.startTime = new Date();
  var suite = this.runningSuites[this.runningSuites.length - 1];
  if (!suite.specs) {
    suite.specs = [];
  }
  suite.specs.push(spec);
  spec.suite = suite;
};


JUnitXmlReporter.prototype.specDone = function (spec) {
  spec.duration = elapsed(spec.startTime, new Date());
  spec.duration = elapsed(spec.startTime, new Date());
  spec.classname = this.getFullName(spec.suite).replace(/\./g, '-');
  spec.output = '<testcase ' +
    'classname="' + spec.classname + '" ' +
    'name="' + escapeInvalidXmlChars(spec.fullName) + '" ' +
    'time="' + spec.duration + '">';

  var failure = '';
  var failures = 0;
  spec.failedExpectations.forEach(function (expectation) {
    failures += 1;
    failure += (failures + ': ' + escapeInvalidXmlChars(expectation.message) + ' ');
  });
  if (failure) {
    spec.output += '\n      <failure>' + trim(failure) + '</failure>\n    ';
  }
  spec.output += '</testcase>';
};


JUnitXmlReporter.prototype.jasmineDone = function () {
  var self = this;
  this.suites.forEach(function (suite) {
    var fileName = 'report-' + self.getFullName(suite, true) + '.xml';
{'fraction_non_alphanumeric': 0.178755586112066, 'fraction_numerical': 0.007218975592987281, 'mean_word_length': 3.4419847328244275, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 16, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5284227', 'n_tokens_mistral': 2051, 'n_tokens_neox': 1977, 'n_words': 429}