forked from sass/node-sass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoverage.js
67 lines (51 loc) · 1.18 KB
/
coverage.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
/*!
* node-sass: scripts/coverage.js
*/
require('../lib/extensions');
var bin = require('path').join.bind(null, __dirname, '..', 'node_modules', '.bin'),
spawn = require('child_process').spawn;
/**
* Run test suite
*
* @api private
*/
function suite() {
process.env.NODESASS_COV = 1;
var coveralls = spawn(bin('coveralls'));
var args = [bin('_mocha')].concat(['--reporter', 'mocha-lcov-reporter']);
var mocha = spawn(process.sass.runtime.execPath, args, {
env: process.env
});
mocha.on('error', function(err) {
console.error(err);
process.exit(1);
});
mocha.stderr.setEncoding('utf8');
mocha.stderr.on('data', function(err) {
console.error(err);
process.exit(1);
});
mocha.stdout.pipe(coveralls.stdin);
}
/**
* Generate coverage files
*
* @api private
*/
function coverage() {
var jscoverage = spawn(bin('jscoverage'), ['lib', 'lib-cov']);
jscoverage.on('error', function(err) {
console.error(err);
process.exit(1);
});
jscoverage.stderr.setEncoding('utf8');
jscoverage.stderr.on('data', function(err) {
console.error(err);
process.exit(1);
});
jscoverage.on('close', suite);
}
/**
* Run
*/
coverage();