<commit_before>var vow = require('vow');
var Mocha = require('mocha');
var reporter = require('./reporter');
var mocha = new Mocha({
    ui: 'bdd',
    reporter: reporter
});

exports.run = function (files) {
    var defer = vow.defer();

    files.forEach(function (file) {
        mocha.addFile(file);
    });

    mocha.run(function (failures) {
        if (failures) {
            defer.reject(failures);
        } else {
            defer.resolve();
        }

        process.on('exit', function () {
            process.exit(failures);
        });
    });

    return defer.promise();
};
<commit_msg>Fixed the bug that the same test was run several times<commit_after>var vow = require('vow');
var Mocha = require('mocha');
var reporter = require('./reporter');
var mocha = new Mocha({
    ui: 'bdd',
    reporter: reporter
});

var oldFiles = [];

exports.run = function (files) {
    var defer = vow.defer();
    var run = false;

    files.forEach(function (file) {
        if (oldFiles.indexOf(file) === -1) {
            oldFiles.push(file);
            mocha.addFile(file);

            run = true;
        }
    });

    if (run) {
        mocha.run(function (failures) {
            if (failures) {
                defer.reject(failures);
            } else {
                defer.resolve();
            }

            process.on('exit', function () {
                process.exit(failures);
            });
        });
    }

    return defer.promise();
};

{'fraction_non_alphanumeric': 0.15264586160108548, 'fraction_numerical': 0.0006784260515603799, 'mean_word_length': 1.8585271317829457, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2301812', 'n_tokens_mistral': 467, 'n_tokens_neox': 438, 'n_words': 99}