<commit_before>'use strict';

var path = require('path');
var gulp = require('gulp');
var conf = require('./conf');
var karma = require('karma');

var pathSrcHtml = [
    path.join(conf.paths.src, '/**/*.html')
];

var pathSrcJs = [
    path.join(conf.paths.src, '/**/!(*.spec).js')
];

function runTests(singleRun, done) {
    var localConfig;
    var preprocessors = {};
    var reporters = ['progress'];
    var server;

    pathSrcHtml.forEach(function (path) {
        preprocessors[path] = ['ng-html2js'];
    });

    if (singleRun) {
        pathSrcJs.forEach(function (path) {
            preprocessors[path] = ['coverage'];
        });
        reporters.push('coverage')
    }

    localConfig = {
        configFile: path.join(__dirname, '/../karma.conf.js'),
        singleRun: singleRun,
        autoWatch: !singleRun,
        reporters: reporters,
        preprocessors: preprocessors
    };

    server = new karma.Server(localConfig, function (failCount) {
        done(failCount ? new Error("Failed " + failCount + " tests.") : null);
    });

    server.start();
}

gulp.task('test', ['scripts'], function (done) {
    runTests(true, done);
});

gulp.task('test:auto', ['watch'], function (done) {
    runTests(false, done);
});<commit_msg>Fixed unit tests exit message<commit_after>'use strict';

var path = require('path');
var gulp = require('gulp');
var conf = require('./conf');
var Server = require('karma').Server;

var pathSrcHtml = [
    path.join(conf.paths.src, '/**/*.html')
];

var pathSrcJs = [
    path.join(conf.paths.src, '/**/!(*.spec).js')
];

function runTests(singleRun, done) {
    var localConfig;
    var preprocessors = {};
    var reporters = ['progress'];
    var server;

    pathSrcHtml.forEach(function (path) {
        preprocessors[path] = ['ng-html2js'];
    });

    if (singleRun) {
        pathSrcJs.forEach(function (path) {
            preprocessors[path] = ['coverage'];
        });
        reporters.push('coverage')
    }

    localConfig = {
        configFile: path.join(__dirname, '/../karma.conf.js'),
        singleRun: singleRun,
        autoWatch: !singleRun,
        reporters: reporters,
        preprocessors: preprocessors
    };

    server = new Server(localConfig, function (exitCode) {
        done(exitCode ? new Error('Karma has exited with ' + exitCode) : null);
    });

    server.start();
}

gulp.task('test', ['scripts'], function (done) {
    runTests(true, done);
});

gulp.task('test:auto', ['watch'], function (done) {
    runTests(false, done);
});
{'fraction_non_alphanumeric': 0.17679558011049723, 'fraction_numerical': 0.0007892659826361484, 'mean_word_length': 2.9241486068111455, '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': '1955357', 'n_tokens_mistral': 812, 'n_tokens_neox': 803, 'n_words': 168}