mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
lib: fix module print timing when specifier includes "
PR-URL: https://github.com/nodejs/node/pull/55150 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
This commit is contained in:
parent
accb239272
commit
78f421de88
@ -173,7 +173,7 @@ function formatTime(ms) {
|
||||
}
|
||||
|
||||
function safeTraceLabel(label) {
|
||||
return label.replace(/\\/g, '\\\\');
|
||||
return label.replace(/\\/g, '\\\\').replaceAll('"', '\\"');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,6 @@
|
||||
import '../common/index.mjs';
|
||||
import { isWindows } from '../common/index.mjs';
|
||||
import assert from 'node:assert';
|
||||
import { writeFileSync } from 'node:fs';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { it } from 'node:test';
|
||||
import tmpdir from '../common/tmpdir.js';
|
||||
@ -113,11 +114,19 @@ it('should support enable tracing dynamically', async () => {
|
||||
|
||||
|
||||
const outputFile = tmpdir.resolve('output-dynamic-trace.log');
|
||||
let requireFileWithDoubleQuote = '';
|
||||
if (!isWindows) {
|
||||
// Double quotes are not valid char for a path on Windows.
|
||||
const fileWithDoubleQuote = tmpdir.resolve('filename-with-"double"-quotes.cjs');
|
||||
writeFileSync(fileWithDoubleQuote, ';\n');
|
||||
requireFileWithDoubleQuote = `require(${JSON.stringify(fileWithDoubleQuote)});`;
|
||||
}
|
||||
const jsScript = `
|
||||
const traceEvents = require("trace_events");
|
||||
const tracing = traceEvents.createTracing({ categories: ["node.module_timer"] });
|
||||
|
||||
tracing.enable();
|
||||
${requireFileWithDoubleQuote}
|
||||
require("http");
|
||||
tracing.disable();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user