Skip to content

Commit 7c04a4d

Browse files
authored
feat: use debuglog rather than console.warn (bcoe#279)
1 parent 0858af5 commit 7c04a4d

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

lib/report.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ const getSourceMapFromFile = require('./source-map-from-file')
99
// TODO: switch back to @c88/v8-coverage once patch is landed.
1010
const v8toIstanbul = require('v8-to-istanbul')
1111
const isCjsEsmBridgeCov = require('./is-cjs-esm-bridge')
12+
const util = require('util')
13+
const debuglog = util.debuglog('c8')
1214

1315
class Report {
1416
constructor ({
@@ -103,7 +105,7 @@ class Report {
103105
map.merge(converter.toIstanbul())
104106
}
105107
} catch (err) {
106-
console.warn(`file: ${v8ScriptCov.url} error: ${err.stack}`)
108+
debuglog(`file: ${v8ScriptCov.url} error: ${err.stack}`)
107109
}
108110
}
109111

@@ -233,7 +235,7 @@ class Report {
233235
'utf8'
234236
)))
235237
} catch (err) {
236-
console.warn(`${err.stack}`)
238+
debuglog(`${err.stack}`)
237239
}
238240
}
239241
return reports
@@ -268,7 +270,7 @@ class Report {
268270
v8ScriptCov.url = furi.toSysPath(v8ScriptCov.url)
269271
fileIndex.add(v8ScriptCov.url)
270272
} catch (err) {
271-
console.warn(err)
273+
debuglog(`${err.stack}`)
272274
continue
273275
}
274276
}

test/integration.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ describe('c8', () => {
7979
'--clean=false',
8080
nodePath,
8181
require.resolve('./fixtures/multiple-spawn')
82-
])
82+
], {
83+
env: { NODE_DEBUG: 'c8' }
84+
})
8385
output.toString('utf8').should.match(
8486
/Error: ENOENT: no such file or directory.*loaders\.js/
8587
)

test/integration.js_10.snap

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ hey
139139
--------------------------|---------|----------|---------|---------|--------------------------------
140140
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
141141
--------------------------|---------|----------|---------|---------|--------------------------------
142-
All files | 75.69 | 58.23 | 66.67 | 75.69 |
142+
All files | 75.76 | 58.23 | 66.67 | 75.76 |
143143
bin | 78.85 | 60 | 66.67 | 78.85 |
144144
c8.js | 78.85 | 60 | 66.67 | 78.85 | 22,27-29,32-33,41-43,50-51
145-
lib | 80.67 | 51.85 | 83.33 | 80.67 |
145+
lib | 80.75 | 51.85 | 83.33 | 80.75 |
146146
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
147147
parse-args.js | 96.13 | 45.45 | 100 | 96.13 | 109-110,118-119,132-133
148-
report.js | 75.17 | 58.82 | 83.33 | 75.17 | ...206,236-237,264-265,271-273
148+
report.js | 75.35 | 58.82 | 83.33 | 75.35 | ...208,238-239,266-267,273-275
149149
source-map-from-file.js | 44 | 100 | 0 | 44 | 10-23
150150
lib/commands | 44.44 | 75 | 16.67 | 44.44 |
151151
check-coverage.js | 21.31 | 100 | 0 | 21.31 | 9-11,14-27,30-44,46-61
@@ -154,9 +154,9 @@ All files | 75.69 | 58.23 | 66.67 | 75.69 |
154154
async.js | 100 | 100 | 100 | 100 |
155155
normal.js | 75 | 66.67 | 33.33 | 75 | 14-16,18-20
156156
--------------------------|---------|----------|---------|---------|--------------------------------
157-
,ERROR: Coverage for lines (75.69%) does not meet global threshold (101%)
157+
,ERROR: Coverage for lines (75.76%) does not meet global threshold (101%)
158158
ERROR: Coverage for branches (58.23%) does not meet global threshold (82%)
159-
ERROR: Coverage for statements (75.69%) does not meet global threshold (95%)
159+
ERROR: Coverage for statements (75.76%) does not meet global threshold (95%)
160160
"
161161
`;
162162

@@ -174,9 +174,9 @@ ERROR: Coverage for branches (25%) does not meet threshold (82%) for lib/is-cjs-
174174
ERROR: Coverage for statements (90%) does not meet threshold (95%) for lib/is-cjs-esm-bridge.js
175175
ERROR: Coverage for lines (96.13%) does not meet threshold (101%) for lib/parse-args.js
176176
ERROR: Coverage for branches (45.45%) does not meet threshold (82%) for lib/parse-args.js
177-
ERROR: Coverage for lines (75.17%) does not meet threshold (101%) for lib/report.js
177+
ERROR: Coverage for lines (75.35%) does not meet threshold (101%) for lib/report.js
178178
ERROR: Coverage for branches (58.82%) does not meet threshold (82%) for lib/report.js
179-
ERROR: Coverage for statements (75.17%) does not meet threshold (95%) for lib/report.js
179+
ERROR: Coverage for statements (75.35%) does not meet threshold (95%) for lib/report.js
180180
ERROR: Coverage for lines (44%) does not meet threshold (101%) for lib/source-map-from-file.js
181181
ERROR: Coverage for statements (44%) does not meet threshold (95%) for lib/source-map-from-file.js
182182
ERROR: Coverage for lines (100%) does not meet threshold (101%) for test/fixtures/async.js
@@ -189,9 +189,9 @@ ERROR: Coverage for statements (75%) does not meet threshold (95%) for test/fixt
189189
exports[`c8 check-coverage exits with 0 if coverage within threshold 1`] = `",,"`;
190190

191191
exports[`c8 check-coverage exits with 1 if coverage is below threshold 1`] = `
192-
",,ERROR: Coverage for lines (75.69%) does not meet global threshold (101%)
192+
",,ERROR: Coverage for lines (75.76%) does not meet global threshold (101%)
193193
ERROR: Coverage for branches (58.23%) does not meet global threshold (82%)
194-
ERROR: Coverage for statements (75.69%) does not meet global threshold (95%)
194+
ERROR: Coverage for statements (75.76%) does not meet global threshold (95%)
195195
"
196196
`;
197197

@@ -274,13 +274,13 @@ exports[`c8 report generates report from existing temporary files 1`] = `
274274
",--------------------------|---------|----------|---------|---------|--------------------------------
275275
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
276276
--------------------------|---------|----------|---------|---------|--------------------------------
277-
All files | 75.69 | 58.23 | 66.67 | 75.69 |
277+
All files | 75.76 | 58.23 | 66.67 | 75.76 |
278278
bin | 78.85 | 60 | 66.67 | 78.85 |
279279
c8.js | 78.85 | 60 | 66.67 | 78.85 | 22,27-29,32-33,41-43,50-51
280-
lib | 80.67 | 51.85 | 83.33 | 80.67 |
280+
lib | 80.75 | 51.85 | 83.33 | 80.75 |
281281
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
282282
parse-args.js | 96.13 | 45.45 | 100 | 96.13 | 109-110,118-119,132-133
283-
report.js | 75.17 | 58.82 | 83.33 | 75.17 | ...206,236-237,264-265,271-273
283+
report.js | 75.35 | 58.82 | 83.33 | 75.35 | ...208,238-239,266-267,273-275
284284
source-map-from-file.js | 44 | 100 | 0 | 44 | 10-23
285285
lib/commands | 44.44 | 75 | 16.67 | 44.44 |
286286
check-coverage.js | 21.31 | 100 | 0 | 21.31 | 9-11,14-27,30-44,46-61
@@ -296,13 +296,13 @@ exports[`c8 report supports --check-coverage, when generating reports 1`] = `
296296
",--------------------------|---------|----------|---------|---------|--------------------------------
297297
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
298298
--------------------------|---------|----------|---------|---------|--------------------------------
299-
All files | 75.69 | 58.23 | 66.67 | 75.69 |
299+
All files | 75.76 | 58.23 | 66.67 | 75.76 |
300300
bin | 78.85 | 60 | 66.67 | 78.85 |
301301
c8.js | 78.85 | 60 | 66.67 | 78.85 | 22,27-29,32-33,41-43,50-51
302-
lib | 80.67 | 51.85 | 83.33 | 80.67 |
302+
lib | 80.75 | 51.85 | 83.33 | 80.75 |
303303
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
304304
parse-args.js | 96.13 | 45.45 | 100 | 96.13 | 109-110,118-119,132-133
305-
report.js | 75.17 | 58.82 | 83.33 | 75.17 | ...206,236-237,264-265,271-273
305+
report.js | 75.35 | 58.82 | 83.33 | 75.35 | ...208,238-239,266-267,273-275
306306
source-map-from-file.js | 44 | 100 | 0 | 44 | 10-23
307307
lib/commands | 44.44 | 75 | 16.67 | 44.44 |
308308
check-coverage.js | 21.31 | 100 | 0 | 21.31 | 9-11,14-27,30-44,46-61
@@ -311,9 +311,9 @@ All files | 75.69 | 58.23 | 66.67 | 75.69 |
311311
async.js | 100 | 100 | 100 | 100 |
312312
normal.js | 75 | 66.67 | 33.33 | 75 | 14-16,18-20
313313
--------------------------|---------|----------|---------|---------|--------------------------------
314-
,ERROR: Coverage for lines (75.69%) does not meet global threshold (101%)
314+
,ERROR: Coverage for lines (75.76%) does not meet global threshold (101%)
315315
ERROR: Coverage for branches (58.23%) does not meet global threshold (82%)
316-
ERROR: Coverage for statements (75.69%) does not meet global threshold (95%)
316+
ERROR: Coverage for statements (75.76%) does not meet global threshold (95%)
317317
"
318318
`;
319319

0 commit comments

Comments
 (0)