<commit_before>// 
// Copyright (c) Microsoft and contributors.  All rights reserved.
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//   http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// 
// See the License for the specific language governing permissions and
// limitations under the License.
// 

var fs = require('fs');
var path = require('path');
var shell = require('shelljs');
var mocha = require ('mocha');
var buildRoot = path.join(__dirname, '_build');
var buildPath = path.join(buildRoot, 'vsoxplat');
var packageRoot = path.join(__dirname, '_package');
var tarRoot = path.join(__dirname, '_tar');
var testRoot = path.join(__dirname, '_test');
var testPath = path.join(testRoot, 'test');
var packagePath = path.join(packageRoot, 'vsoxplat');

var writeHeader = function(title) {
	console.log();
	console.log('********** ' + title + ' **********');
}

desc('This is the default task.');
task('default', ['clean', 'package', 'tar'], function () {

});

desc('Build');
task('build', {async: true}, function () {	
	writeHeader('build');
	jake.rmRf(buildRoot);
	jake.mkdirP(buildPath);
	
	console.log('Compiling typescript to _build...');
	jake.exec(['tsc --outDir ' + buildPath + ' @sources'], {printStdout: true, printStderr: true}, function(){
		console.log('Compiling done');
		console.log('Copying other files');
		jake.cpR('package.json', buildPath);
		jake.cpR('src/agent/handlers/vso.py', path.join(buildPath, 'agent', 'handlers'));
		jake.cpR('src/bin/install.js', path.join(buildPath, 'bin'));
		complete();
	});
});

desc('Run tests')
task('test', ['default'], function() {
	writeHeader('test');
	console.log('Creating _test folder');
	jake.rmRf(testRoot);
	console.log('Copying files');
	jake.cpR(buildPath, testRoot);
	jake.cpR('src/test/messages', path.join(testRoot, 'test'));
	jake.cpR('src/test/projects', path.join(testRoot, 'test'));
	jake.cpR(path.join(packagePath, 'agent'), testRoot);

	jake.mkdirP(path.join(testRoot, 'agent', 'work'));

	var runner = new mocha({reporter: 'spec', ui: 'bdd'});

	fs.readdirSync(testPath).filter(function(file){
		return file.substr(-3) === '.js';
	}).forEach(function(file){
		runner.addFile(path.join(testPath, file));
	});
<commit_msg>ci builds don't have mocha test colored output<commit_after>// 
// Copyright (c) Microsoft and contributors.  All rights reserved.
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//   http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// 
// See the License for the specific language governing permissions and
// limitations under the License.
// 

var fs = require('fs');
var path = require('path');
var shell = require('shelljs');
var mocha = require ('mocha');
var buildRoot = path.join(__dirname, '_build');
var buildPath = path.join(buildRoot, 'vsoxplat');
var packageRoot = path.join(__dirname, '_package');
var tarRoot = path.join(__dirname, '_tar');
var testRoot = path.join(__dirname, '_test');
var testPath = path.join(testRoot, 'test');
var packagePath = path.join(packageRoot, 'vsoxplat');

var writeHeader = function(title) {
	console.log();
	console.log('********** ' + title + ' **********');
}

desc('This is the default task.');
task('default', ['clean', 'package', 'tar'], function () {

});

desc('Build');
task('build', {async: true}, function () {	
	writeHeader('build');
	jake.rmRf(buildRoot);
	jake.mkdirP(buildPath);
	
	console.log('Compiling typescript to _build...');
	jake.exec(['tsc --outDir ' + buildPath + ' @sources'], {printStdout: true, printStderr: true}, function(){
		console.log('Compiling done');
		console.log('Copying other files');
		jake.cpR('package.json', buildPath);
		jake.cpR('src/agent/handlers/vso.py', path.join(buildPath, 'agent', 'handlers'));
		jake.cpR('src/bin/install.js', path.join(buildPath, 'bin'));
		complete();
	});
});

desc('Run tests')
task('test', ['default'], function(mode) {
	writeHeader('test');
	var useColors = true;
	if (mode) {
		console.log('mode: ' + mode);
		if (mode.toLowerCase() == 'ci') {
			useColors = false;
		}
	}
	console.log('Creating _test folder');
	jake.rmRf(testRoot);
	console.log('Copying files');
	jake.cpR(buildPath, testRoot);
	jake.cpR('src/test/messages', path.join(testRoot, 'test'));
	jake.cpR('src/test/projects', path.join(testRoot, 'test'));
	jake.cpR(path.join(packagePath, 'agent'), testRoot);

	jake.mkdirP(path.join(testRoot, 'agent', 'work'));

	var runner = new mocha({reporter: 'spec', ui: 'bdd', useColors:useColors});

	fs.readdirSync(testPath).filter(function(file){
		return file.substr(-3) === '.js';
	}).forEach(function(file){
		runner.addFile(path.join(testPath, file));
	});

{'fraction_non_alphanumeric': 0.18680279826054075, 'fraction_numerical': 0.0018907165815844206, 'mean_word_length': 4.89086859688196, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3565123', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1719, 'n_words': 460}