@@ -29,7 +29,7 @@ const fs = require('fs');
29
29
// Do not require 'os' until needed so that test-os-checked-function can
30
30
// monkey patch it. If 'os' is required here, that test will fail.
31
31
const path = require ( 'path' ) ;
32
- const util = require ( 'util' ) ;
32
+ const { inspect } = require ( 'util' ) ;
33
33
const { isMainThread } = require ( 'worker_threads' ) ;
34
34
35
35
const tmpdir = require ( './tmpdir' ) ;
@@ -97,7 +97,7 @@ if (process.argv.length === 2 &&
97
97
( process . features . inspector || ! flag . startsWith ( '--inspect' ) ) ) {
98
98
console . log (
99
99
'NOTE: The test started as a child_process using these flags:' ,
100
- util . inspect ( flags ) ,
100
+ inspect ( flags ) ,
101
101
'Use NODE_SKIP_FLAG_CHECK to run the test with the original flags.'
102
102
) ;
103
103
const args = [ ...flags , ...process . execArgv , ...process . argv . slice ( 1 ) ] ;
@@ -149,7 +149,7 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
149
149
process . on ( 'exit' , ( ) => {
150
150
// Iterate through handles to make sure nothing crashes
151
151
for ( const k in initHandles )
152
- util . inspect ( initHandles [ k ] ) ;
152
+ inspect ( initHandles [ k ] ) ;
153
153
} ) ;
154
154
155
155
const _queueDestroyAsyncId = async_wrap . queueDestroyAsyncId ;
@@ -159,7 +159,7 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
159
159
process . _rawDebug ( ) ;
160
160
throw new Error ( `same id added to destroy list twice (${ id } )` ) ;
161
161
}
162
- destroyListList [ id ] = util . inspect ( new Error ( ) ) ;
162
+ destroyListList [ id ] = inspect ( new Error ( ) ) ;
163
163
_queueDestroyAsyncId ( id ) ;
164
164
} ;
165
165
@@ -173,7 +173,7 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
173
173
}
174
174
initHandles [ id ] = {
175
175
resource,
176
- stack : util . inspect ( new Error ( ) ) . substr ( 6 )
176
+ stack : inspect ( new Error ( ) ) . substr ( 6 )
177
177
} ;
178
178
} ,
179
179
before ( ) { } ,
@@ -184,7 +184,7 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
184
184
process . _rawDebug ( ) ;
185
185
throw new Error ( `destroy called for same id (${ id } )` ) ;
186
186
}
187
- destroydIdsList [ id ] = util . inspect ( new Error ( ) ) ;
187
+ destroydIdsList [ id ] = inspect ( new Error ( ) ) ;
188
188
} ,
189
189
} ) . enable ( ) ;
190
190
}
@@ -424,7 +424,7 @@ function _mustCallInner(fn, criteria = 1, field) {
424
424
const context = {
425
425
[ field ] : criteria ,
426
426
actual : 0 ,
427
- stack : util . inspect ( new Error ( ) ) ,
427
+ stack : inspect ( new Error ( ) ) ,
428
428
name : fn . name || '<anonymous>'
429
429
} ;
430
430
@@ -512,7 +512,7 @@ function mustNotCall(msg) {
512
512
const callSite = getCallSite ( mustNotCall ) ;
513
513
return function mustNotCall ( ...args ) {
514
514
const argsInfo = args . length > 0 ?
515
- `\ncalled with arguments: ${ args . map ( util . inspect ) . join ( ', ' ) } ` : '' ;
515
+ `\ncalled with arguments: ${ args . map ( ( arg ) => inspect ( arg ) ) . join ( ', ' ) } ` : '' ;
516
516
assert . fail (
517
517
`${ msg || 'function should not have been called' } at ${ callSite } ` +
518
518
argsInfo ) ;
@@ -614,7 +614,7 @@ function expectWarning(nameOrMap, expected, code) {
614
614
if ( ! catchWarning [ warning . name ] ) {
615
615
throw new TypeError (
616
616
`"${ warning . name } " was triggered without being expected.\n` +
617
- util . inspect ( warning )
617
+ inspect ( warning )
618
618
) ;
619
619
}
620
620
catchWarning [ warning . name ] ( warning ) ;
@@ -635,7 +635,7 @@ function expectsError(validator, exact) {
635
635
if ( args . length !== 1 ) {
636
636
// Do not use `assert.strictEqual()` to prevent `inspect` from
637
637
// always being called.
638
- assert . fail ( `Expected one argument, got ${ util . inspect ( args ) } ` ) ;
638
+ assert . fail ( `Expected one argument, got ${ inspect ( args ) } ` ) ;
639
639
}
640
640
const error = args . pop ( ) ;
641
641
const descriptor = Object . getOwnPropertyDescriptor ( error , 'message' ) ;
@@ -740,9 +740,9 @@ function invalidArgTypeHelper(input) {
740
740
if ( input . constructor && input . constructor . name ) {
741
741
return ` Received an instance of ${ input . constructor . name } ` ;
742
742
}
743
- return ` Received ${ util . inspect ( input , { depth : - 1 } ) } ` ;
743
+ return ` Received ${ inspect ( input , { depth : - 1 } ) } ` ;
744
744
}
745
- let inspected = util . inspect ( input , { colors : false } ) ;
745
+ let inspected = inspect ( input , { colors : false } ) ;
746
746
if ( inspected . length > 25 )
747
747
inspected = `${ inspected . slice ( 0 , 25 ) } ...` ;
748
748
return ` Received type ${ typeof input } (${ inspected } )` ;
0 commit comments