File tree 3 files changed +41
-2
lines changed
3 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -120,8 +120,16 @@ function setupCoverageHooks(dir) {
120
120
const { resolve } = require ( 'path' ) ;
121
121
const coverageDirectory = resolve ( cwd , dir ) ;
122
122
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
+ }
125
133
return coverageDirectory ;
126
134
}
127
135
Original file line number Diff line number Diff line change @@ -651,6 +651,12 @@ function skipIfInspectorDisabled() {
651
651
}
652
652
}
653
653
654
+ function skipIfInspectorEnabled ( ) {
655
+ if ( process . features . inspector ) {
656
+ skip ( 'V8 inspector is enabled' ) ;
657
+ }
658
+ }
659
+
654
660
function skipIfReportDisabled ( ) {
655
661
if ( ! process . config . variables . node_report ) {
656
662
skip ( 'Diagnostic reporting is disabled' ) ;
@@ -783,6 +789,7 @@ module.exports = {
783
789
skipIf32Bits,
784
790
skipIfEslintMissing,
785
791
skipIfInspectorDisabled,
792
+ skipIfInspectorEnabled,
786
793
skipIfReportDisabled,
787
794
skipIfWorker,
788
795
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