Skip to content

Commit

Permalink
test: fix snapshot tests when cwd contains spaces or
Browse files Browse the repository at this point in the history
Both are valid characters for file names on non-Windows systems.

PR-URL: nodejs/node#48959
Backport-PR-URL: nodejs/node#50669
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
sercher committed Apr 24, 2024
1 parent 36e65b4 commit 4d632c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions graal-nodejs/test/common/assertSnapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const test = require('node:test');
const fs = require('node:fs/promises');
const assert = require('node:assert/strict');

const stackFramesRegexp = /(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\[\d+m)?(\n|$)/g;
const stackFramesRegexp = /(?<=\n)(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\[\d+m)?(\n|$)/g;
const windowNewlineRegexp = /\r/g;

function replaceStackTrace(str, replacement = '$1*$7$8\n') {
Expand All @@ -17,7 +17,7 @@ function replaceWindowsLineEndings(str) {
}

function replaceWindowsPaths(str) {
return str.replaceAll(path.win32.sep, path.posix.sep);
return common.isWindows ? str.replaceAll(path.win32.sep, path.posix.sep) : str;
}

function transform(...args) {
Expand Down

0 comments on commit 4d632c9

Please sign in to comment.