This repository has been archived by the owner on Dec 7, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 149
/
node-tests.js
executable file
·68 lines (60 loc) · 1.58 KB
/
node-tests.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env node
function doneLogMsg(msg) {
return function() {
console.log(msg);
};
}
require("native-promise-only");
var path = require("path");
var ASQ = require(path.join(__dirname,"asq.src.js"));
var tests = require(path.join(__dirname,"tests.js"))(doneLogMsg);
var fs = require("fs");
var child_process = require("child_process");
var contrib_tests_file = path.join(__dirname,"contrib","node-tests.js");
var contrib_tests = [function(done){
console.log("*** CONTRIB TESTS SKIPPED ***");
done();
}];
// if `./contrib/` exists, run the contrib test suite
if (fs.existsSync(contrib_tests_file)) {
contrib_tests = [function __contrib_tests__(done) {
console.log("");
var cp = child_process.spawn(
contrib_tests_file,
/*args=*/[],
{
cwd: path.join(__dirname,"contrib"),
env: process.env,
encoding: "utf8"
}
);
cp.stdout.on("data",function(data){
console.log(data.toString().replace(/\n$/,""));
});
cp.stderr.on("data",function(data){
console.error(data.toString().replace(/\n$/,""));
});
cp.on("close",function(code){
if (code === 0) {
done();
}
else {
done.fail();
}
});
}];
}
console.log("asynquence test suite");
ASQ.apply(ASQ,tests)
.val(doneLogMsg("ALL CORE TESTS PASSED!"))
.then.apply(ASQ,contrib_tests) // contrib tests, if any
.val(doneLogMsg("\nALL TESTS PASSED!"))
.or(function(){
doneLogMsg("*** TEST SUITE FAILURE ***")();
for (var i=0; i<arguments.length; i++) {
doneLogMsg(arguments[i] +
(arguments[i] && arguments[i].stack ? arguments[i].stack : "")
)();
}
process.exit(1); // non-zero exit code!
});