@@ -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 ) ] ;
@@ -138,7 +138,7 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
138
138
process . on ( 'exit' , ( ) => {
139
139
// Iterate through handles to make sure nothing crashes
140
140
for ( const k in initHandles )
141
- util . inspect ( initHandles [ k ] ) ;
141
+ inspect ( initHandles [ k ] ) ;
142
142
} ) ;
143
143
144
144
const _queueDestroyAsyncId = async_wrap . queueDestroyAsyncId ;
@@ -148,7 +148,7 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
148
148
process . _rawDebug ( ) ;
149
149
throw new Error ( `same id added to destroy list twice (${ id } )` ) ;
150
150
}
151
- destroyListList [ id ] = util . inspect ( new Error ( ) ) ;
151
+ destroyListList [ id ] = inspect ( new Error ( ) ) ;
152
152
_queueDestroyAsyncId ( id ) ;
153
153
} ;
154
154
@@ -162,7 +162,7 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
162
162
}
163
163
initHandles [ id ] = {
164
164
resource,
165
- stack : util . inspect ( new Error ( ) ) . substr ( 6 )
165
+ stack : inspect ( new Error ( ) ) . substr ( 6 )
166
166
} ;
167
167
} ,
168
168
before ( ) { } ,
@@ -173,7 +173,7 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
173
173
process . _rawDebug ( ) ;
174
174
throw new Error ( `destroy called for same id (${ id } )` ) ;
175
175
}
176
- destroydIdsList [ id ] = util . inspect ( new Error ( ) ) ;
176
+ destroydIdsList [ id ] = inspect ( new Error ( ) ) ;
177
177
} ,
178
178
} ) . enable ( ) ;
179
179
}
@@ -397,7 +397,7 @@ function _mustCallInner(fn, criteria = 1, field) {
397
397
const context = {
398
398
[ field ] : criteria ,
399
399
actual : 0 ,
400
- stack : util . inspect ( new Error ( ) ) ,
400
+ stack : inspect ( new Error ( ) ) ,
401
401
name : fn . name || '<anonymous>'
402
402
} ;
403
403
@@ -485,7 +485,7 @@ function mustNotCall(msg) {
485
485
const callSite = getCallSite ( mustNotCall ) ;
486
486
return function mustNotCall ( ...args ) {
487
487
const argsInfo = args . length > 0 ?
488
- `\ncalled with arguments: ${ args . map ( util . inspect ) . join ( ', ' ) } ` : '' ;
488
+ `\ncalled with arguments: ${ args . map ( ( arg ) => inspect ( arg ) ) . join ( ', ' ) } ` : '' ;
489
489
assert . fail (
490
490
`${ msg || 'function should not have been called' } at ${ callSite } ` +
491
491
argsInfo ) ;
@@ -587,7 +587,7 @@ function expectWarning(nameOrMap, expected, code) {
587
587
if ( ! catchWarning [ warning . name ] ) {
588
588
throw new TypeError (
589
589
`"${ warning . name } " was triggered without being expected.\n` +
590
- util . inspect ( warning )
590
+ inspect ( warning )
591
591
) ;
592
592
}
593
593
catchWarning [ warning . name ] ( warning ) ;
@@ -608,7 +608,7 @@ function expectsError(validator, exact) {
608
608
if ( args . length !== 1 ) {
609
609
// Do not use `assert.strictEqual()` to prevent `inspect` from
610
610
// always being called.
611
- assert . fail ( `Expected one argument, got ${ util . inspect ( args ) } ` ) ;
611
+ assert . fail ( `Expected one argument, got ${ inspect ( args ) } ` ) ;
612
612
}
613
613
const error = args . pop ( ) ;
614
614
const descriptor = Object . getOwnPropertyDescriptor ( error , 'message' ) ;
@@ -713,9 +713,9 @@ function invalidArgTypeHelper(input) {
713
713
if ( input . constructor && input . constructor . name ) {
714
714
return ` Received an instance of ${ input . constructor . name } ` ;
715
715
}
716
- return ` Received ${ util . inspect ( input , { depth : - 1 } ) } ` ;
716
+ return ` Received ${ inspect ( input , { depth : - 1 } ) } ` ;
717
717
}
718
- let inspected = util . inspect ( input , { colors : false } ) ;
718
+ let inspected = inspect ( input , { colors : false } ) ;
719
719
if ( inspected . length > 25 )
720
720
inspected = `${ inspected . slice ( 0 , 25 ) } ...` ;
721
721
return ` Received type ${ typeof input } (${ inspected } )` ;
0 commit comments