diff --git a/README.md b/README.md index 06f98b9..5306f5c 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,10 @@ Using -T, collateral paths are relative to the test262 root directory: `> test262-harness -T ~/test262 language/**/*` +When a glob matches a directory, the default behavior will run all files under it recursively: + +`> test262-harness -T ~/test262 language` + Run local tests in jsshell: `> test262-harness -r jsshell -e jsshell/js -b ./tests` diff --git a/bin/run.js b/bin/run.js index 628bc6c..fbb154c 100755 --- a/bin/run.js +++ b/bin/run.js @@ -275,12 +275,24 @@ function applyDefaults(config) { function getFilesStream(config) { var files = config._; - if(config.test262Dir) { - files = files.map(function(p) { - return path.join(config.test262Dir, 'test', p); - }) + // by default, run all files recursively when we pass test262Dir + if(config.test262Dir && files.length === 0) { + files = ['**/*'] } + files = files.map(function(p) { + if(config.test262Dir) { + p = path.join(config.test262Dir, 'test', p); + } + + if(fs.existsSync(p) && fs.statSync(p).isDirectory()) { + p = path.join(p, '**/*'); + } + + return p; + }) + + files = _(files.map(globStream)).merge(); if (config.exclude) files = files.filter(exclude); diff --git a/test/test.js b/test/test.js index d14678e..a480803 100644 --- a/test/test.js +++ b/test/test.js @@ -93,17 +93,27 @@ test('compile flag throws without output directory', function(t) { }); }); -// test that helpers work when specifying a glob to a test262 folder structure +// helpers work when specifying a glob to a test262 folder structure utils.testResultsCorrect('-r node-ip', 'test/test262alike/test/**/*.js', [ { file: 'test/test262alike/test/testHelper.js', strictMode: false, pass: true } ]); -// test test262Dir - helpers found, and test path relative to test262Dir/test +// test262Dir - helpers found, and test path relative to test262Dir/test utils.testResultsCorrect('-r node-ip --test262Dir test/test262alike', '**/*.js', [ { file: 'test/test262alike/test/testHelper.js', strictMode: false, pass: true } ]); -// test that we can pass a separate helper directory +// we can pass a separate helper directory utils.testResultsCorrect('-r node-ip --test262Dir test/test262alike --includesDir test/test262alike/badHarness', '**/*.js', [ { file: 'test/test262alike/test/testHelper.js', strictMode: false, pass: false, errorName: 'Error', errorMessage: 'bad' } ]); + +// We can pass a directory and it will run all files underneath it +utils.testResultsCorrect('-r node-ip', 'test/test262alike/test', [ + { file: 'test/test262alike/test/testHelper.js', strictMode: false, pass: true } +]); + +// We can pass test262dir and by default it will run all files under the test directory +utils.testResultsCorrect('-r node-ip --test262Dir test/test262alike', '', [ + { file: 'test/test262alike/test/testHelper.js', strictMode: false, pass: true } +]); diff --git a/test/utils.js b/test/utils.js index 9c79fce..6bc8f24 100644 --- a/test/utils.js +++ b/test/utils.js @@ -80,8 +80,8 @@ exports.run = function run(args, path, done) { path = undefined; } - path = path || 'test/collateral/*.js'; - console.log("Runing at path " + path); + if(path === undefined) path = 'test/collateral/*.js'; + args = args.split(" ").concat('--reporter', 'json', path); var child = cp.fork('bin/run.js', args, {silent: true})