File tree Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -120,8 +120,16 @@ function setupCoverageHooks(dir) {
120120 const { resolve } = require ( 'path' ) ;
121121 const coverageDirectory = resolve ( cwd , dir ) ;
122122 const { sourceMapCacheToObject } = require ( 'internal/source_map' ) ;
123- internalBinding ( 'profiler' ) . setCoverageDirectory ( coverageDirectory ) ;
124- internalBinding ( 'profiler' ) . setSourceMapCacheGetter ( sourceMapCacheToObject ) ;
123+
124+ if ( process . features . inspector ) {
125+ internalBinding ( 'profiler' ) . setCoverageDirectory ( coverageDirectory ) ;
126+ internalBinding ( 'profiler' ) . setSourceMapCacheGetter ( sourceMapCacheToObject ) ;
127+ } else {
128+ process . emitWarning ( 'The inspector is disabled, ' +
129+ 'coverage could not be collected' ,
130+ 'Warning' ) ;
131+ return '' ;
132+ }
125133 return coverageDirectory ;
126134}
127135
Original file line number Diff line number Diff line change @@ -651,6 +651,12 @@ function skipIfInspectorDisabled() {
651651 }
652652}
653653
654+ function skipIfInspectorEnabled ( ) {
655+ if ( process . features . inspector ) {
656+ skip ( 'V8 inspector is enabled' ) ;
657+ }
658+ }
659+
654660function skipIfReportDisabled ( ) {
655661 if ( ! process . config . variables . node_report ) {
656662 skip ( 'Diagnostic reporting is disabled' ) ;
@@ -783,6 +789,7 @@ module.exports = {
783789 skipIf32Bits,
784790 skipIfEslintMissing,
785791 skipIfInspectorDisabled,
792+ skipIfInspectorEnabled,
786793 skipIfReportDisabled,
787794 skipIfWorker,
788795
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const common = require ( '../common' ) ;
4+ common . skipIfInspectorEnabled ( ) ;
5+
6+ const fixtures = require ( '../common/fixtures' ) ;
7+ const assert = require ( 'assert' ) ;
8+ const { spawnSync } = require ( 'child_process' ) ;
9+ const env = { ...process . env , NODE_V8_COVERAGE : '/foo/bar' } ;
10+ const childPath = fixtures . path ( 'v8-coverage/subprocess' ) ;
11+ const { status, stderr } = spawnSync (
12+ process . execPath ,
13+ [ childPath ] ,
14+ { env }
15+ ) ;
16+
17+ const warningMessage = 'The inspector is disabled, ' +
18+ 'coverage could not be collected' ;
19+
20+ assert . strictEqual ( status , 0 ) ;
21+ assert . strictEqual (
22+ stderr . toString ( ) . includes ( `Warning: ${ warningMessage } ` ) ,
23+ true
24+ ) ;
You can’t perform that action at this time.
0 commit comments