log4js-node/tests.js
2010-01-17 12:08:28 +11:00

56 lines
1009 B
JavaScript

require.paths.unshift("./spec/lib", "./lib");
require("jspec");
log4js = require("log4js-node");
var sys = require("sys"), posix = require("posix");
quit = process.exit
print = sys.puts
readFile = function(path) {
var result;
try {
posix
.cat(path)
.addCallback(
function(contents){ result = contents; }
).wait();
} catch (e) {
throw e;
}
return result;
}
var specsFound = false;
if (process.ARGV[2]) {
specsFound = true;
JSpec.exec('spec/spec.' + process.ARGV[2] + '.js');
} else {
var files;
posix
.readdir('spec/')
.addCallback(
function(dirFiles) { files = dirFiles; }
).wait();
files.filter(
function (file) {
return file.indexOf('spec.') === 0;
}
).forEach(
function(file) {
specsFound = true;
JSpec.exec('spec/'+file);
}
);
}
if (specsFound) {
JSpec.run({ reporter: JSpec.reporters.Terminal });
JSpec.report();
} else {
print("No tests to run. This makes me sad.");
}