1 |
|
2 |
|
3 |
|
4 |
|
5 | var nodeunit = require('../nodeunit'),
|
6 | path = require('path');
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | exports.info = 'The LCOV reporter reads JS files instrumented by JSCoverage (http://siliconforks.com/jscoverage/) and outputs coverage data in the LCOV format (http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php)';
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | exports.run = function (files, options, callback) {
|
22 |
|
23 | var paths = files.map(function (p) {
|
24 | return path.resolve(p);
|
25 | });
|
26 |
|
27 | nodeunit.runFiles(paths, {
|
28 | done: function (assertions) {
|
29 | var cov = (global || window)._$jscoverage || {};
|
30 |
|
31 | Object.keys(cov).forEach(function (filename) {
|
32 | var data = cov[filename];
|
33 | reportFile(filename, data);
|
34 | });
|
35 |
|
36 | if (callback) callback(assertions.failures() ? new Error('We have got test failures.') : undefined);
|
37 | }
|
38 | });
|
39 | };
|
40 |
|
41 | function reportFile(filename, data) {
|
42 | console.log('SF:' + filename);
|
43 |
|
44 | data.source.forEach(function(line, num) {
|
45 |
|
46 | num++;
|
47 |
|
48 | if (data[num] !== undefined) {
|
49 | console.log('DA:' + num + ',' + data[num]);
|
50 | }
|
51 | });
|
52 |
|
53 | console.log('end_of_record');
|
54 | }
|