Skip to content

Commit

Permalink
Run all files under directories if matched by a glob. When passing te…
Browse files Browse the repository at this point in the history
…st262Dir, run all tests by default.
  • Loading branch information
bterlson committed Apr 22, 2015
1 parent a23d40c commit e60a511
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
20 changes: 16 additions & 4 deletions bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 13 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
]);
4 changes: 2 additions & 2 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit e60a511

Please sign in to comment.