forked from replikativ/datahike
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_node.js
executable file
·57 lines (47 loc) · 1.36 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
53
54
55
56
57
#!/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('datahike.test')
goog.require('datahike.js')
} else {
nodeGlobalRequire('./target/datahike.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(datahike.test.test_cljs(), tests_js.test_all())
else if ('--js' === process.argv[2]) var res = tests_js.test_all()
else if ('--cljs' === process.argv[2]) var res = datahike.test.test_cljs()
else {
var t0 = global.performance.now()
var res = datahike.test.test_most()
var t1 = global.performance.now()
console.log('Time: ' + (t1 - t0) + 'msec')
}
if (res.fail + res.error > 0) process.exit(1)