Browse Source

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').
Solly Ross 11 năm trước cách đây
mục cha
commit
d823e8956e
1 tập tin đã thay đổi với 6 bổ sung2 xóa
  1. 6 2
      tests/run_from_console.js

+ 6 - 2
tests/run_from_console.js

@@ -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
   .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;
 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) {