-
Notifications
You must be signed in to change notification settings - Fork 1
/
runner.js
42 lines (38 loc) · 1.07 KB
/
runner.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* Suite runner.
* To be called like
* node runner.js TESTS_DIRECTORY
*
* This currently very basic, and largely inadequate.
* It simply runs each test file one by one.
* It will need to:
* + agregate contexts together when they are spread over multiple files.
* + report on the results of running the test files
* - including exiting with non-zero whenever any test fails
*/
var test = require('./testnode')();
var sys = require('sys');
var glob = require('glob');
var control = new (require('events').EventEmitter);
test.onFailureExitNonZero();
test.suiteMode();
var dir = process.ARGV[2];
if (!dir) {
sys.puts("Usage: node runner.js TESTS_DIRECTORY");
process.exit(0);
}
var files;
var getFiles = function() {
dir = (dir.charAt(dir.length-1)=='/') ? (dir + '**') : (dir + '/**');
glob.glob(dir + '/**', null, function(error, matches){
files = matches;
control.emit('getFilesDone');
});
};
control.on('getFilesDone', function(){
files.forEach(function(file){
sys.puts('Loading file ' + file);
require('./' + file);
});
});
getFiles();