From dd76ff85d4ac8681e506d6bd69601e40ce5b55f4 Mon Sep 17 00:00:00 2001 From: Futago-za Ryuu Date: Tue, 11 Sep 2018 10:32:23 +0100 Subject: [PATCH] Update execution files --- test/impact | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/test/impact b/test/impact index 71382c3..1d85614 100644 --- a/test/impact +++ b/test/impact @@ -23,24 +23,20 @@ if ( process.cwd() !== cwd ) process.chdir( cwd ); // Execution Files -let NEWER_PEGJS_BIN = "bin/peg.js"; -let NEWER_BENCHMARK_BIN = "test/benchmark/run"; +function binfile( ...files ) { -const ef = { + for ( const file of files ) { - get pegjs() { + if ( fs.existsSync( file ) ) return file; - return fs.existsSync( NEWER_PEGJS_BIN ) ? NEWER_PEGJS_BIN : "bin/pegjs"; + } - }, + throw `Could not find: ${ files.join( " || " ) }`; - get benchmark() { - - return fs.existsSync( NEWER_BENCHMARK_BIN ) ? NEWER_BENCHMARK_BIN : "benchmark/run"; - - }, +} -}; +let PEGJS_BIN = binfile( "packages/pegjs/bin/peg.js", "bin/peg.js", "bin/pegjs" ); +let BENCHMARK_BIN = binfile( "test/benchmark/run", "benchmark/run" ); // Utils @@ -65,7 +61,7 @@ function prepare( commit ) { function runBenchmark() { return parseFloat( - exec( "node " + ef.benchmark ) + exec( "node " + BENCHMARK_BIN ) // Split by table seprator, reverse and return the total bytes per second .split( "│" ) @@ -91,7 +87,7 @@ function measureSize() { glob.sync( "examples/*.pegjs" ) .forEach( example => { - exec( `node ${ ef.pegjs } ${ example }` ); + exec( `node ${ PEGJS_BIN } ${ example }` ); example = example.slice( 0, -5 ) + "js"; size += fs.statSync( example ).size; fs.unlinkSync( example );