<commit_before>/**
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @fileOverview Take QUnit output and write out Ant/JUnit XML reports.
 */

var JUnitReporter = function(pattern) {
    this._doc = null;
    this._root = null;
    this._init();
    this._suites = {};
    this._cases = {};
    this._pattern = pattern;
};

JUnitReporter.prototype._init = function() {
    this._doc = null;
    this._doc = JUnitReporter._createDocument();
    this._root = this._doc.createElement('testsuites');
    this._doc.appendChild(this._root);
};

JUnitReporter.prototype.write = function(file) {
    var str = '<?xml version="1.0" encoding="UTF-8"?>\n';
    str += JUnitReporter.serialize(this._doc);
    Envjs.writeToFile(str, Envjs.uri(file));
};

JUnitReporter.prototype.writeByPattern = function(module) {
    this.write(this._pattern.replace(/%\(module\)s/g, module));
};

JUnitReporter.prototype.moduleStart = function(name, start) {
    this._suites[name] = {'name': name, 'time': start};
};

JUnitReporter.prototype.moduleDone = function(name, failed, total) {
    this._suites[name]['tests'] = total;
    this._suites[name]['failures'] = failed;
    this._suites[name]['errors'] = 0;
    this._suites[name]['time'] -= (new Date()).getTime();
    this._suites[name]['time'] /= -1000.0;
    this._suites[name]['hostname'] = 'localhost';
    this._suites[name]['timestamp'] = JUnitReporter.date();
    var att, testcase, suite = this._doc.createElement('testsuite');
    for (att in this._suites[name]) {
        if (this._suites[name].hasOwnProperty(att)) {
            suite.setAttribute(att, this._suites[name][att]);<commit_msg>sometimes (race condition?) moduleDone gets called before moduleStart, which won't ultimately be a problem since it will be called correctly later, so just return<commit_after>/**
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @fileOverview Take QUnit output and write out Ant/JUnit XML reports.
 */

var JUnitReporter = function(pattern) {
    this._doc = null;
    this._root = null;
    this._init();
    this._suites = {};
    this._cases = {};
    this._pattern = pattern;
};

JUnitReporter.prototype._init = function() {
    this._doc = null;
    this._doc = JUnitReporter._createDocument();
    this._root = this._doc.createElement('testsuites');
    this._doc.appendChild(this._root);
};

JUnitReporter.prototype.write = function(file) {
    var str = '<?xml version="1.0" encoding="UTF-8"?>\n';
    str += JUnitReporter.serialize(this._doc);
    Envjs.writeToFile(str, Envjs.uri(file));
};

JUnitReporter.prototype.writeByPattern = function(module) {
    this.write(this._pattern.replace(/%\(module\)s/g, module));
};

JUnitReporter.prototype.moduleStart = function(name, start) {
    this._suites[name] = {'name': name, 'time': start};
};

JUnitReporter.prototype.moduleDone = function(name, failed, total) {
    if (typeof this._suites[name] === "undefined") {
        return;
    }
    this._suites[name]['tests'] = total;
    this._suites[name]['failures'] = failed;
    this._suites[name]['errors'] = 0;
    this._suites[name]['time'] -= (new Date()).getTime();
    this._suites[name]['time'] /= -1000.0;
    this._suites[name]['hostname'] = 'localhost';
    this._suites[name]['timestamp'] = JUnitReporter.date();
    var att, testcase, suite = this._doc.createElement('testsuite');
    for (att in this._suites[name]) {
        if (this._suites[name].hasOwnProperty(att)) {
            suite.setAttribute(att, this._suites[name][att]);
{'fraction_non_alphanumeric': 0.175947187141217, 'fraction_numerical': 0.005166475315729047, 'mean_word_length': 4.028860028860029, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 2, '>': 13, 'https://': 0, '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': '6500511', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1130, 'n_words': 207}