<commit_before>var Mocha = require('mocha');

var MochaTestRunner = function(testOptions, testMonitor){
	var failed = false,
		mocha = new Mocha();
	mocha.addFile(testOptions.tests[0]);

	this.start = function(){
		var runner = mocha.run(end);
		runner.on('fail', function(){
			failed = true;
		});
		runner.on('pass', function(){
			console.log('pass');
		});
	};

	function end(){
		if (failed){
			testMonitor.failed();
		}
		else {
			testMonitor.passed();
		}
	}
};

module.exports = MochaTestRunner;<commit_msg>refactoring<commit_after>var Mocha = require('mocha');

var MochaTestRunner = function(testOptions, testMonitor){
	var mocha = new Mocha();
	mocha.addFile(testOptions.tests[0]);

	this.start = function(){
		var testRunResults = new TestRunResults(testMonitor),
			runner = mocha.run(testRunResults.publishResults);
		runner.on('fail', function(){
			testRunResults.recordFailure();
		});
	};
};

var TestRunResults = function(testMonitor){
	var hasFailed = false;
	
	this.recordFailure = function(){
		hasFailed = true;
	};

	this.publishResults = function(){
		if (hasFailed){
			testMonitor.failed();
		}
		else {
			testMonitor.passed();
		}
	};
};

module.exports = MochaTestRunner;
{'fraction_non_alphanumeric': 0.15946843853820597, 'fraction_numerical': 0.0016611295681063123, 'mean_word_length': 4.452488687782806, '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': '2453257', 'n_tokens_mistral': 455, 'n_tokens_neox': 398, 'n_words': 76}