-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-all-tests.js
57 lines (45 loc) · 1.66 KB
/
run-all-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
const { fork } = require("child_process");
const TEST_NAMES = ["composite", "single", "simpleToBuffer", "simpleToFile"];
const CONCURRENCY_OPTS = [0, 1];
const CACHE_OPTS = [false, true];
const CONCURRENT_OPS = 10;
const requestedTestNames = process.argv.slice(2).filter(requestedTestName => TEST_NAMES.includes(requestedTestName));
const testNames = requestedTestNames.length > 0 ? requestedTestNames : TEST_NAMES;
const runSingleTest = (testName, concurrentOps, concurrency, disableCache) =>
new Promise((resolve, reject) => {
console.log("Launching test " + [testName, concurrentOps, concurrency, disableCache].join(" ") + "\n");
const child = fork("./run-test.js", [testName, concurrentOps, concurrency, disableCache, true], {
stdio: ["inherit", "inherit", "inherit", "ipc"]
});
child.on("error", x => {
console.log("bl");
console.log(x);
reject(x);
});
child.on("close", code => {
if (code !== 0) {
reject(new Error("Test " + [testName, concurrentOps, concurrency, disableCache].join("-") + " failed"));
} else {
console.log("Test " + [testName, concurrentOps, concurrency, disableCache].join("-") + " succeeded\n");
resolve();
}
});
});
let promise = Promise.resolve();
testNames.forEach(testName => {
CONCURRENCY_OPTS.forEach(concurrency => {
CACHE_OPTS.forEach(disableCache => {
promise = promise.then(() => runSingleTest(testName, CONCURRENT_OPS, concurrency, disableCache));
});
});
});
promise.then(
() => {
console.log("All tests completed!");
},
err => {
console.log("Some tests failed...");
console.log(err.stack);
process.exit(1);
}
);