<commit_before>var path = require('path'),
    temp = require('temp'),
    process = require('child_process'),
    nunit = require('./nunit.js');

module.exports = function(grunt) {
    grunt.registerTask('nunit', 'Runs the NUnit test runner.', function() {
        var options = this.options();
        var cleanup;

        if (!options.result && options.teamcity) {
            temp.track();
            options.result = temp.path({ suffix: '.xml' });
            cleanup = temp.cleanup;
        }

        console.log();
        console.log('NUnit Task Runner');
        console.log();

        var files = nunit.findTestAssemblies(options.files);
        var command = nunit.buildCommand(files, options);

        console.log('Running tests in:');
        console.log();
        files.forEach(function(file) { console.log('    ' + file); });
        console.log();

        console.log(command.path + ' ' + command.args.join(' '));
        console.log();

        var taskComplete = this.async();
        var nunitProcess = process.spawn(command.path, command.args, { windowsVerbatimArguments: true });

        var log = function(message) { console.log(message.toString('utf8')); };

        nunitProcess.stdout.on('data', log);
        nunitProcess.stderr.on('data', log);

        nunitProcess.on('exit', function(code) { 
            if (options.teamcity) console.log(nunit.createTeamcityLog(options.result).join(''));
            if (code > 0) grunt.fail.fatal('Tests failed.');
            if (cleanup) cleanup();
            taskComplete();
        });    
    });
};<commit_msg>Fixed #1 no error thrown when nunit not found.<commit_after>var path = require('path'),
    temp = require('temp'),
    process = require('child_process'),
    nunit = require('./nunit.js');

module.exports = function(grunt) {
    grunt.registerTask('nunit', 'Runs the NUnit test runner.', function() {
        var options = this.options();
        var cleanup;

        if (!options.result && options.teamcity) {
            temp.track();
            options.result = temp.path({ suffix: '.xml' });
            cleanup = temp.cleanup;
        }

        console.log();
        console.log('NUnit Task Runner');
        console.log();

        var files = nunit.findTestAssemblies(options.files);
        var command = nunit.buildCommand(files, options);

        console.log('Running tests in:');
        console.log();
        files.forEach(function(file) { console.log('    ' + file); });
        console.log();

        console.log(command.path + ' ' + command.args.join(' '));
        console.log();

        var taskComplete = this.async();
        var nunitProcess = process.spawn(command.path, command.args, { windowsVerbatimArguments: true });

        var log = function(message) { console.log(message.toString('utf8')); };

        nunitProcess.stdout.on('data', log);
        nunitProcess.stderr.on('data', log);

        nunitProcess.on('exit', function(code) { 
            if (options.teamcity) console.log(nunit.createTeamcityLog(options.result).join(''));
            if (cleanup) cleanup();
            if (code > 0) grunt.fail.fatal('Tests failed.');
            taskComplete();
        });  

        nunitProcess.on('error', function(e) { 
            grunt.fail.fatal(e.code === 'ENOENT' ? 'Unable to find NUnit Console.exe located at ' + command.path : e.message);
        });     
    });
};
{'fraction_non_alphanumeric': 0.1591309453904874, 'fraction_numerical': 0.001467997651203758, 'mean_word_length': 2.373267326732673, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2041484', 'n_tokens_mistral': 979, 'n_tokens_neox': 950, 'n_words': 195}