55// This depends on perfetto's `trace_processor_shell` converts to pftrace format
66// to JSON format. Run `make tools/perfetto/trace_processor_shell` to download
77// it (`vcbuild test` does so on Windows), or point `TRACE_PROCESSOR_SHELL_PATH`
8- // at an existing build of it.
8+ // at an existing build of it. Point it at the null device (`/dev/null`, or
9+ // `NUL` on Windows) to skip the tests that need it.
910
1011const assert = require ( 'assert' ) ;
1112const { spawnSync } = require ( 'child_process' ) ;
1213const fs = require ( 'fs' ) ;
14+ const { devNull } = require ( 'os' ) ;
1315const path = require ( 'path' ) ;
1416const common = require ( './' ) ;
1517
16- const traceProcessor = path . resolve (
17- __dirname , '..' , '..' ,
18- process . env . TRACE_PROCESSOR_SHELL_PATH ||
19- `tools/perfetto/trace_processor_shell${ common . isWindows ? '.exe' : '' } ` ) ;
18+ const traceProcessor = ( ( p ) => {
19+ if ( p !== undefined && common . isWindows && / ^ (?: \\ \\ \. \\ ) ? n u l $ / i. test ( p ) ) {
20+ return false ;
21+ }
22+ return p !== devNull && path . resolve (
23+ __dirname , '..' , '..' ,
24+ p || `tools/perfetto/trace_processor_shell${ common . isWindows ? '.exe' : '' } ` ) ;
25+ } ) ( process . env . TRACE_PROCESSOR_SHELL_PATH ) ;
2026
2127// The JSON form of a trace runs about three times the size of the trace it was
2228// converted from, and the traces these tests produce are a few hundred KiB at
@@ -29,9 +35,14 @@ const defaultTraceFileName = `node_trace.1.${traceFileExt}`;
2935// Only perfetto traces need converting, so a missing `trace_processor_shell`
3036// does not stop anything on a legacy build.
3137function checkTraceProcessor ( ) {
32- if ( common . hasPerfetto && ! fs . existsSync ( traceProcessor ) ) {
38+ if ( ! common . hasPerfetto ) return ;
39+ if ( ! traceProcessor ) {
40+ common . skip ( 'TRACE_PROCESSOR_SHELL_PATH points to the null device' ) ;
41+ }
42+ if ( ! fs . existsSync ( traceProcessor ) ) {
3343 assert . fail ( 'trace_processor_shell is missing, ' +
34- 'run `python3 tools/perfetto/get_trace_processor.py` to download it' ) ;
44+ 'run `python3 tools/perfetto/get_trace_processor.py` to download it, ' +
45+ 'or set TRACE_PROCESSOR_SHELL_PATH to the null device to skip this test' ) ;
3546 }
3647}
3748
0 commit comments