2013-08-20 06:15:41 +02:00
|
|
|
var fs = require('fs');
|
2013-08-21 20:27:14 +02:00
|
|
|
var _ = require('third/underscore/underscore.js');
|
2013-08-20 06:15:41 +02:00
|
|
|
|
2013-08-20 18:34:56 +02:00
|
|
|
// Run all the JS scripts in our test directory. Tests do NOT run
|
|
|
|
// in isolation.
|
2013-08-20 06:15:41 +02:00
|
|
|
|
|
|
|
var tests = fs.readdirSync(__dirname)
|
|
|
|
.filter(function (filename) { return (/\.js$/i).test(filename); })
|
|
|
|
.map(function (filename) { return filename.replace(/\.js$/i, ''); });
|
|
|
|
|
2013-08-21 23:53:00 +02:00
|
|
|
|
|
|
|
tests.sort();
|
|
|
|
|
2013-08-21 20:27:14 +02:00
|
|
|
var dependencies = [];
|
|
|
|
|
|
|
|
global.set_global = function (name, val) {
|
|
|
|
global[name] = val;
|
|
|
|
dependencies.push(name);
|
|
|
|
return val;
|
|
|
|
};
|
|
|
|
|
|
|
|
global.add_dependencies = function (dct) {
|
|
|
|
_.each(dct, function (fn, name) {
|
|
|
|
var obj = require(fn);
|
|
|
|
set_global(name, obj);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-08-20 06:15:41 +02:00
|
|
|
tests.forEach(function (filename) {
|
2013-08-21 20:27:14 +02:00
|
|
|
if (filename === 'index') {
|
2013-08-20 06:15:41 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
console.info('running tests for ' + filename);
|
|
|
|
require('./' + filename);
|
2013-08-21 20:27:14 +02:00
|
|
|
|
|
|
|
dependencies.forEach(function (name) {
|
|
|
|
delete global[name];
|
|
|
|
});
|
|
|
|
dependencies = [];
|
2013-08-20 06:15:41 +02:00
|
|
|
});
|