-
Notifications
You must be signed in to change notification settings - Fork 11
/
_runtest.js
58 lines (47 loc) · 1.38 KB
/
_runtest.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
import {Promise} from 'bluebird'
import path from 'path'
import file from 'file'
import Mocha from 'mocha'
//import fs from 'fs'
require('@babel/register')({
'babelrc': false,
'presets': ['@babel/preset-env'],
'plugins': [['babel-plugin-extensible-destructuring', {mode: 'optout', impl: 'test'}]],
})
function addFiles(mocha, root) {
file.walkSync(root, (pth, dirs, files) => {
for (let f of files) {
if (pth.indexOf('fixtures') === -1 &&
pth.indexOf('optin') === -1 && // will run optout later
f.substr(-3) === '.js' &&
f.length > 4) { // helper one-letter .js files
mocha.addFile(path.join(pth, f))
}
}
})
}
function mocharun(mocha) {
return new Promise((resolve, reject) => {
mocha.run((failures) => {
resolve(failures)
})
})
}
let mocha = new Mocha()
addFiles(mocha, './test/')
let failures1 = mocharun(mocha)
let failures2 = failures1.then(() => {
mocha = new Mocha()
require('@babel/register')({
'babelrc': false,
'presets': ['@babel/preset-env'],
'plugins': [['babel-plugin-extensible-destructuring', {mode: 'optin', impl: 'test'}]],
})
addFiles(mocha, './test/optin')
return mocharun(mocha)
})
Promise.all([failures1, failures2]).then(([f1, f2]) => {
process.on('exit', function() {
process.exit(Math.max(f1, f2)) // exit with non-zero status if there were failures
})
})