Commit d823e895 authored by Solly Ross's avatar Solly Ross

Support Running All Tests

Now, if the '-t' option is passed but no tests are listed,
all tests in the same directory as the launcher will be run.
A file is considered a test if it matches the RegEx
/^test\.(\w|\.|-)+\.js$/ (for those who cannot read PCRE,
that's roughly 'test.*.js').
parent 8eb88937
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
var ansi = require('ansi'); var ansi = require('ansi');
var program = require('commander'); var program = require('commander');
var path = require('path'); var path = require('path');
var fs = require('fs');
var make_list = function(val) { var make_list = function(val) {
return val.split(','); return val.split(',');
...@@ -19,11 +20,15 @@ program ...@@ -19,11 +20,15 @@ program
.option('-d, --debug', 'Show debug output (the "console" event) from the provider') .option('-d, --debug', 'Show debug output (the "console" event) from the provider')
.parse(process.argv); .parse(process.argv);
if (program.tests.length === 0) {
program.tests = fs.readdirSync(__dirname).filter(function(f) { return (/^test\.(\w|\.|-)+\.js$/).test(f); });
console.log('using files %s', program.tests);
}
var file_paths = []; var file_paths = [];
if (program.autoInject) { if (program.autoInject) {
var temp = require('temp'); var temp = require('temp');
var fs = require('fs');
temp.track(); temp.track();
var template = { var template = {
...@@ -70,7 +75,6 @@ else if (process.stdout.isTTY) use_ansi = true; ...@@ -70,7 +75,6 @@ else if (process.stdout.isTTY) use_ansi = true;
var cursor = ansi(process.stdout, { enabled: use_ansi }); var cursor = ansi(process.stdout, { enabled: use_ansi });
if (program.outputHtml) { if (program.outputHtml) {
var fs = require('fs');
file_paths.forEach(function(path, path_ind) { file_paths.forEach(function(path, path_ind) {
fs.readFile(path, function(err, data) { fs.readFile(path, function(err, data) {
if (err) { if (err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment