Skip to content

Commit

Permalink
Merge pull request #45 from drewfish/test-pages
Browse files Browse the repository at this point in the history
use new tests/test262/pages to run tests
  • Loading branch information
andyearnshaw committed Jan 10, 2014
2 parents 40e6897 + deae3fe commit 09ee559
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"scripts": {
"build": "grunt",
"lint": "jshint Intl.js",
"test": "cd tests && ./run402"
"test": "cd tests && node noderunner.js"
},
"repository": {
"type": "git",
Expand Down
73 changes: 73 additions & 0 deletions tests/noderunner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@


var LIBS = {
fs: require('fs'),
path: require('path'),
vm: require('vm')
},
TEST_DIR = __dirname + '/test262/pages';


// returns Error if test threw one
function runTest(testPath) {
var content;
var sandbox = {};
content = LIBS.fs.readFileSync(LIBS.path.resolve(TEST_DIR, testPath)).toString();
try {
LIBS.vm.runInNewContext(content, sandbox, testPath);
} catch (err) {
return err;
}
return;
}


function listTests() {
var tests = [],
todo = [ '.' ],
doing,
path;
while (todo.length) {
doing = todo.shift();
path = LIBS.path.resolve(TEST_DIR, doing);
stat = LIBS.fs.statSync(path);
if (stat.isFile()) {
tests.push(doing);
continue;
}
if (stat.isDirectory()) {
todo = todo.concat(LIBS.fs.readdirSync(path).map(function(a) {
return LIBS.path.join(doing, a);
}));
}
}
return tests;
}


function main() {
var tests,
passCount = 0,
failCount = 0;
tests = listTests();
tests.sort();
tests.forEach(function(testPath) {
var name,
err;
name = LIBS.path.basename(testPath, LIBS.path.extname(testPath));
err = runTest(testPath);
if (err) {
console.log(name, '-- FAILED', err.message);
failCount++;
} else {
console.log(name);
passCount++;
}
});
console.log('total ' + (tests.length) + ' -- passed ' + passCount + ' -- failed ' + failCount);
process.exit(failCount ? 1 : 0);
}
main();



0 comments on commit 09ee559

Please sign in to comment.