-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin-configuration-test.js
72 lines (62 loc) · 1.73 KB
/
plugin-configuration-test.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
69
70
71
72
const async = require('async')
const spawn = require('child_process').spawn
const existsSync = require('fs')
const path = require('path')
const assert = require('core-assert')
const helper = require('./support/helper')
module.exports = function (cb) {
async.parallel([
vanillaTest,
runWithPlugins('customize-plugins'),
runWithPlugins('customize-configurator'),
runWithPlugins('customize-cli')
], cb)
}
function vanillaTest (cb) {
run('vanilla', function (er, code, log) {
assert.equal(code, 0)
helper.includes(log,
'TAP version 13\n' +
'1..2\n' +
'ok 1 - "add" - test #1 in `test/simple-test.js`\n' +
'ok 2 - "subtract" - test #2 in `test/simple-test.js`')
cb(er)
})
}
function runWithPlugins (name) {
return function (cb) {
run(name, function (er, code, log) {
assert.equal(code, 0)
helper.includes(log,
'TAP version 13\n' +
'1..2\n' +
'About to run a before all\n' +
'ok 1 - "add" - test #1 in `test/simple-test.js`\n' +
'ok 2 - "subtract" - test #2 in `test/simple-test.js`\n' +
'Sweet suite!')
cb(er)
})
}
}
function run (projectDir, cb) {
const options = {
cwd: path.resolve(process.cwd(), 'safe/fixtures/projects/' + projectDir)
}
if (process.platform === 'win32') {
options.shell = true
}
console.log(`Running ${options.shell}`);
const test = spawn('npm', ['test'], options)
let log = ''
test.stdout.on('data', function (text) {
console.log(projectDir, text.toString());
log += text.toString()
})
test.stderr.on('data', function (text) {
console.log(projectDir, text.toString());
log += text.toString()
})
test.on('close', function (code) {
cb(null, code, log)
})
}