@@ -10,7 +10,7 @@ const stackFramesRegexp = /(?<=\n)(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?
1010const windowNewlineRegexp = / \r / g;
1111
1212function replaceNodeVersion ( str ) {
13- return str . replaceAll ( process . version , '* ' ) ;
13+ return str . replaceAll ( process . version , '<node-version> ' ) ;
1414}
1515
1616function replaceStackTrace ( str , replacement = '$1*$7$8\n' ) {
@@ -31,10 +31,27 @@ function replaceWindowsPaths(str) {
3131 return common . isWindows ? str . replaceAll ( path . win32 . sep , path . posix . sep ) : str ;
3232}
3333
34+ function replaceTrailingSpaces ( str ) {
35+ return str . replaceAll ( / [ \t ] + \n / g, '\n' ) ;
36+ }
37+
38+ // Replaces customized or platform specific executable names to be `node`.
39+ function generalizeExeName ( str ) {
40+ const baseName = path . basename ( process . argv0 || 'node' , '.exe' ) ;
41+ return str . replaceAll ( `${ baseName } --` , 'node --' ) ;
42+ }
43+
44+ function replaceWarningPid ( str ) {
45+ return str . replaceAll ( / \( n o d e : \d + \) / g, '(node:<pid>)' ) ;
46+ }
47+
3448function transformProjectRoot ( replacement = '' ) {
3549 const projectRoot = path . resolve ( __dirname , '../..' ) ;
50+ const urlEncoded = encodeURIComponent ( projectRoot ) ;
3651 return ( str ) => {
37- return str . replaceAll ( '\\\'' , "'" ) . replaceAll ( projectRoot , replacement ) ;
52+ return str . replaceAll ( '\\\'' , "'" )
53+ . replaceAll ( projectRoot , replacement )
54+ . replaceAll ( urlEncoded , replacement ) ;
3855 } ;
3956}
4057
@@ -152,32 +169,41 @@ function pickTestFileFromLcov(str) {
152169 ) ;
153170}
154171
155- const defaultTransform = transform (
172+ // Transforms basic patterns like:
173+ // - platform specific path and line endings,
174+ // - line trailing spaces,
175+ // - executable specific path and versions.
176+ const basicTransform = transform (
156177 replaceWindowsLineEndings ,
157- replaceStackTrace ,
178+ replaceTrailingSpaces ,
158179 removeWindowsPathEscaping ,
159- transformProjectRoot ( ) ,
160180 replaceWindowsPaths ,
181+ replaceNodeVersion ,
182+ generalizeExeName ,
183+ replaceWarningPid ,
184+ ) ;
185+
186+ const defaultTransform = transform (
187+ basicTransform ,
188+ replaceStackTrace ,
189+ transformProjectRoot ( ) ,
161190 replaceTestDuration ,
162191 replaceTestLocationLine ,
163192) ;
164193const specTransform = transform (
165194 replaceSpecDuration ,
166- replaceWindowsLineEndings ,
195+ basicTransform ,
167196 replaceStackTrace ,
168- replaceWindowsPaths ,
169197) ;
170198const junitTransform = transform (
171199 replaceJunitDuration ,
172- replaceWindowsLineEndings ,
200+ basicTransform ,
173201 replaceStackTrace ,
174- replaceWindowsPaths ,
175202) ;
176203const lcovTransform = transform (
177- replaceWindowsLineEndings ,
204+ basicTransform ,
178205 replaceStackTrace ,
179206 transformProjectRoot ( ) ,
180- replaceWindowsPaths ,
181207 pickTestFileFromLcov ,
182208) ;
183209
@@ -204,6 +230,7 @@ module.exports = {
204230 transform,
205231 transformProjectRoot,
206232 replaceTestDuration,
233+ basicTransform,
207234 defaultTransform,
208235 specTransform,
209236 junitTransform,
0 commit comments