Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit662bf52

Browse files
aduh95marco-ippolito
authored andcommitted
test: do not assume cwd in snapshot tests
PR-URL:#53146Reviewed-By: Luigi Pinca <luigipinca@gmail.com>Reviewed-By: Chemi Atlow <chemi@atlow.co.il>Reviewed-By: Moshe Atlow <moshe@atlow.co.il>Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent0312065 commit662bf52

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

‎test/common/assertSnapshot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function replaceWindowsPaths(str) {
2525
}
2626

2727
functionreplaceFullPaths(str){
28-
returnstr.replaceAll(process.cwd(),'');
28+
returnstr.replaceAll(path.resolve(__dirname,'../..'),'');
2929
}
3030

3131
functiontransform(...args){
@@ -78,7 +78,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
7878
return;
7979
}
8080
constflags=common.parseTestFlags(filename);
81-
constexecutable=tty ?'tools/pseudo-tty.py' :process.execPath;
81+
constexecutable=tty ?path.join(__dirname,'../..','tools/pseudo-tty.py') :process.execPath;
8282
constargs=tty ?[process.execPath, ...flags,filename] :[...flags,filename];
8383
const{ stdout, stderr}=awaitcommon.spawnPromisified(executable,args,options);
8484
awaitassertSnapshot(transform(`${stdout}${stderr}`),filename);

‎test/parallel/test-runner-output.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import * as fixtures from '../common/fixtures.mjs';
33
import*assnapshotfrom'../common/assertSnapshot.js';
44
import{describe,it}from'node:test';
55
import{hostname}from'node:os';
6+
import{chdir,cwd}from'node:process';
7+
import{fileURLToPath}from'node:url';
68

79
constskipForceColors=
810
process.config.variables.icu_gyp_path!=='tools/icu/icu-generic.gyp'||
@@ -14,8 +16,10 @@ function replaceTestDuration(str) {
1416
.replaceAll(/duration_ms[0-9.]+/g,'duration_ms *');
1517
}
1618

19+
constroot=fileURLToPath(newURL('../..',import.meta.url)).slice(0,-1);
20+
1721
constcolor='(\\[\\d+m)';
18-
conststackTraceBasePath=newRegExp(`${color}\\(${process.cwd().replaceAll(/[\\^$*+?.()|[\]{}]/g,'\\$&')}/?${color}(.*)${color}\\)`,'g');
22+
conststackTraceBasePath=newRegExp(`${color}\\(${root.replaceAll(/[\\^$*+?.()|[\]{}]/g,'\\$&')}/?${color}(.*)${color}\\)`,'g');
1923

2024
functionreplaceSpecDuration(str){
2125
returnstr
@@ -149,6 +153,9 @@ const tests = [
149153
}),
150154
}));
151155

156+
if(cwd()!==root){
157+
chdir(root);
158+
}
152159
describe('test runner output',{concurrency:true},()=>{
153160
for(const{ name, fn}oftests){
154161
it(name,fn);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp