<commit_before>var path = require( 'path' );
var fs = require( 'fs' );
var rimraf = require( 'rimraf' );
var child_process = require( 'child_process' );
var assert = require( 'assert' );
var glob = require( 'glob' );
var SourceMapConsumer = require( 'source-map' ).SourceMapConsumer;
var getLocation = require( './utils/getLocation.js' );
var buble = require( '../dist/buble.umd.js' );

require( 'source-map-support' ).install();
require( 'console-group' ).install();

function equal ( a, b ) {
	assert.equal( showInvisibles( a ), showInvisibles( b ) );
}

function showInvisibles ( str ) {
	return str
		.replace( /^ +/gm, spaces => repeat( '•', spaces.length ) )
		.replace( / +$/gm, spaces => repeat( '•', spaces.length ) )
		.replace( /^\t+/gm, tabs => repeat( '›   ', tabs.length ) )
		.replace( /\t+$/gm, tabs => repeat( '›   ', tabs.length ) );
}

function repeat ( str, times ) {
	var result = '';
	while ( times-- ) result += str;
	return result;
}

const subsetIndex = process.argv.indexOf( '--subset' );
const subset = ~subsetIndex ? process.argv[ subsetIndex + 1 ].split( ',' ).map( file => `${file}.js` ) : null;
const subsetFilter = subset ? file => ~subset.indexOf( file ) : () => true;

describe( 'buble', () => {
	fs.readdirSync( 'test/samples' ).filter( subsetFilter ).forEach( file => {
		if ( !/\.js$/.test( file ) ) return; // avoid vim .js.swp files
		var samples = require( './samples/' + file );

		describe( path.basename( file ), () => {
			samples.forEach( sample => {
				( sample.solo ? it.only : sample.skip ? it.skip : it )( sample.description, () => {
					if ( sample.error ) {
						assert.throws( () => {
							buble.transform( sample.input, sample.options );
						}, sample.error );
					}

					else {
						equal( buble.transform( sample.input, sample.options  ).code, sample.output );
					}
				});
			});
		});
	});

	if ( subset ) return;

	describe( 'cli', () => {
		fs.readdirSync( 'test/cli' ).forEach( dir => {
			if ( dir[0] === '.' ) return; // .DS_Store

			it( dir, done => {
				dir = path.resolve( 'test/cli', dir );
				rimraf.sync( path.resolve( dir, 'actual' ) );
				fs.mkdirSync( path.resolve( dir, 'actual' ) );

				var binFile = path.resolve(__dirname, '../bin/buble');
				var commandFile = path.resolve( dir, 'command.sh' );

				var command = fs.readFileSync( commandFile, 'utf-8' )
					.replace( 'buble', 'node "' + binFile + '"' );
				child_process.exec( command, {
					cwd: dir
				}, ( err, stdout, stderr ) => {
					if ( err ) return done( err );

					if ( stdout ) console.log( stdout );
					if ( stderr ) console.error( stderr );

					function catalogue ( subdir ) {
						subdir = path.resolve( dir, subdir );

						return glob.sync( '**/*.js?(.map)', { cwd: subdir })
							.sort()
							.map( name => {
								var contents = fs.readFileSync( path.resolve( subdir, name ), 'utf-8' ).trim();

								if ( path.extname( name ) === '.map' ) {
									contents = JSON.parse( contents );
								}

								return {
									name: name,
									contents: contents
								};
							});
					}

					var expected = catalogue( 'expected' );
					var actual = catalogue( 'actual' );

					try {
						assert.deepEqual( actual, expected );
						done();
					} catch ( err ) {
						done( err );
					}
				});
			});<commit_msg>get tests to pass on windows, hopefully<commit_after>var path = require( 'path' );
var fs = require( 'fs' );
var rimraf = require( 'rimraf' );
var child_process = require( 'child_process' );
var assert = require( 'assert' );
var glob = require( 'glob' );
var SourceMapConsumer = require( 'source-map' ).SourceMapConsumer;
var getLocation = require( './utils/getLocation.js' );
var buble = require( '../dist/buble.umd.js' );

require( 'source-map-support' ).install();
require( 'console-group' ).install();

function equal ( a, b ) {
	assert.equal( showInvisibles( a ), showInvisibles( b ) );
}

function showInvisibles ( str ) {
	return str
		.replace( /^ +/gm, spaces => repeat( '•', spaces.length ) )
		.replace( / +$/gm, spaces => repeat( '•', spaces.length ) )
		.replace( /^\t+/gm, tabs => repeat( '›   ', tabs.length ) )
		.replace( /\t+$/gm, tabs => repeat( '›   ', tabs.length ) );
}

function repeat ( str, times ) {
	var result = '';
	while ( times-- ) result += str;
	return result;
}

const subsetIndex = process.argv.indexOf( '--subset' );
const subset = ~subsetIndex ? process.argv[ subsetIndex + 1 ].split( ',' ).map( file => `${file}.js` ) : null;
const subsetFilter = subset ? file => ~subset.indexOf( file ) : () => true;

describe( 'buble', () => {
	fs.readdirSync( 'test/samples' ).filter( subsetFilter ).forEach( file => {
		if ( !/\.js$/.test( file ) ) return; // avoid vim .js.swp files
		var samples = require( './samples/' + file );

		describe( path.basename( file ), () => {
			samples.forEach( sample => {
				( sample.solo ? it.only : sample.skip ? it.skip : it )( sample.description, () => {
					if ( sample.error ) {
						assert.throws( () => {
							buble.transform( sample.input, sample.options );
						}, sample.error );
					}

					else {
						equal( buble.transform( sample.input, sample.options  ).code, sample.output );
					}
				});
			});
		});
	});

	if ( subset ) return;

	describe( 'cli', () => {
		fs.readdirSync( 'test/cli' ).forEach( dir => {
			if ( dir[0] === '.' ) return; // .DS_Store

			it( dir, done => {
				dir = path.resolve( 'test/cli', dir );
				rimraf.sync( path.resolve( dir, 'actual' ) );
				fs.mkdirSync( path.resolve( dir, 'actual' ) );

				var binFile = path.resolve(__dirname, '../bin/buble');
				var commandFile = path.resolve( dir, 'command.sh' );

				var command = fs.readFileSync( commandFile, 'utf-8' )
					.replace( 'buble', 'node "' + binFile + '"' );
				child_process.exec( command, {
					cwd: dir
				}, ( err, stdout, stderr ) => {
					if ( err ) return done( err );

					if ( stdout ) console.log( stdout );
					if ( stderr ) console.error( stderr );

					function catalogue ( subdir ) {
						subdir = path.resolve( dir, subdir );

						return glob.sync( '**/*.js?(.map)', { cwd: subdir })
							.sort()
							.map( name => {
								var contents = fs.readFileSync( path.resolve( subdir, name ), 'utf-8' ).trim();

								if ( path.extname( name ) === '.map' ) {
									contents = JSON.parse( contents );
								}

								return {
									name: name,
									contents: contents.replace(/\r\n/g, '\n')
								};
							});
					}

					var expected = catalogue( 'expected' );
					var actual = catalogue( 'actual' );

					try {
						assert.deepEqual( actual, expected );
						done();
					} catch ( err ) {
						done( err );
					}
				});
			});
{'fraction_non_alphanumeric': 0.19264816204051013, 'fraction_numerical': 0.0012003000750187547, 'mean_word_length': 2.5608974358974357, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 39, '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': '1246045', 'n_tokens_mistral': 2741, 'n_tokens_neox': 2196, 'n_words': 565}