forked from tonsky/datascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_node.js
executable file
·53 lines (42 loc) · 1.3 KB
/
test_node.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
#!/usr/local/bin/node
var fs = require('fs'),
vm = require('vm');
global.performance = { now: function () {
var t = process.hrtime();
return t[0] * 1000 + t[1] / 1000000;
} }
global.goog = {};
global.CLOSURE_IMPORT_SCRIPT = function(src) {
require('./target/none/goog/' + src);
return true;
};
function nodeGlobalRequire(file) {
vm.runInThisContext.call(global, fs.readFileSync(file), file);
}
if (fs.existsSync("./target/none")) {
nodeGlobalRequire('./target/none/goog/base.js');
nodeGlobalRequire('./target/none/cljs_deps.js');
goog.require('datascript.test');
goog.require('datascript.js');
} else {
nodeGlobalRequire('./target/datascript.js');
}
function merge(m1, m2) {
return { fail: m1.fail + m2.fail,
error: m1.error + m2.error,
test: m1.test + m2.test,
pass: m1.pass + m2.pass }
}
if ("--all" === process.argv[2] || "--js" === process.argv[2]) {
var tests_js = require('./test/js/tests.js');
}
if ("--all" === process.argv[2])
var res = merge(datascript.test.test_all(), tests_js.test_all());
else if ("--btset" === process.argv[2])
var res = datascript.test.test_btset();
else if ("--js" === process.argv[2])
var res = tests_js.test_all();
else
var res = datascript.test.test_most();
if (res.fail + res.error > 0)
process.exit(1);