Skip to content

Commit

Permalink
Bench runner can now take args
Browse files Browse the repository at this point in the history
  • Loading branch information
NatalieWolfe committed Dec 8, 2017
1 parent f9b4b00 commit 746617c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bin/run-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ var benchpath = path.resolve(cwd, 'test/benchmark')

var tests = []
var globs = []
var opts = Object.create(null)

process.argv.slice(2).forEach(function forEachFileArg(file) {
if (/[*]/.test(file)) {
if (/^--/.test(file)) {
opts[file.substr(2)] = true
} else if (/[*]/.test(file)) {
globs.push(path.join(benchpath, file))
} else if (/\.bench\.js$/.test(file)) {
tests.push(path.join(benchpath, file))
} else {
globs.push(
path.join(benchpath, file, '*.bench.js'),
path.join(benchpath, file + '*.bench.js'),
path.join(benchpath, file, '**/*.bench.js')
)
}
Expand Down Expand Up @@ -60,7 +64,11 @@ a.series([
var test = path.relative(benchpath, file)

console.log(test)
var child = cp.spawn('node', ['--expose-gc', file], {cwd: cwd, stdio: 'inherit'})
var args = ['--expose-gc', file]
if (opts.inspect) {
args.unshift('--inspect-brk')
}
var child = cp.spawn('node', args, {cwd: cwd, stdio: 'inherit'})
child.on('error', cb)
child.on('exit', function onChildExit(code) {
console.log('')
Expand Down

0 comments on commit 746617c

Please sign in to comment.