Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.

Commit dd20187

Browse files
committed
Add command line support on Windows
This change adds the command line to NodeReport on Windows. It uses the Windows GetCommandLine() API to obtain the command line. Also includes a minor change to print "Command line:" rather than "Command line arguments:" in the report as prefix, plus updates to the testcases.
1 parent 1294c2a commit dd20187

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/node_report.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,9 @@ void SetCommandLine() {
364364
separator = " ";
365365
}
366366
}
367-
#endif // _AIX
367+
#elif _WIN32
368+
commandline_string = GetCommandLine();
369+
#endif
368370
}
369371

370372
/*******************************************************************************
@@ -541,7 +543,7 @@ void TriggerNodeReport(Isolate* isolate, DumpEvent event, const char* message, c
541543
******************************************************************************/
542544
static void PrintCommandLine(FILE* fp) {
543545
if (commandline_string != "") {
544-
fprintf(fp, "Command line arguments: %s\n", commandline_string.c_str());
546+
fprintf(fp, "Command line: %s\n", commandline_string.c_str());
545547
}
546548
}
547549

test/common.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ exports.validate = (t, report, options) => {
4545
'Checking report contains ' + section + ' section');
4646
});
4747

48-
// Check NodeReport section
48+
// Check NodeReport header section
4949
const nodeReportSection = getSection(reportContents, 'NodeReport');
5050
t.contains(nodeReportSection, new RegExp('Process ID: ' + pid),
5151
'NodeReport section contains expected process ID');
@@ -58,8 +58,17 @@ exports.validate = (t, report, options) => {
5858
'NodeReport section contains expected Node.js version');
5959
}
6060
if (options && options.commandline) {
61-
t.match(nodeReportSection, new RegExp('Command line arguments: ' + options.commandline),
62-
'NodeReport section contains expected command line');
61+
if (this.isWindows()) {
62+
// On Windows we need to strip out double quotes from the command line in the
63+
// report, and escape the backslashes in the regex comparison string.
64+
t.match(nodeReportSection.replace(/"/g,''),
65+
new RegExp('Command line: ' + (options.commandline).replace(/\\/g,'\\\\')),
66+
'Checking report contains expected command line');
67+
} else {
68+
t.match(nodeReportSection,
69+
new RegExp('Command line: ' + options.commandline),
70+
'Checking report contains expected command line');
71+
}
6372
}
6473
nodeComponents.forEach((c) => {
6574
if (c !== 'node') {

0 commit comments

Comments
 (0)