Skip to content

Commit f50f05e

Browse files
branchseerclaude
andcommitted
fix: use @yarnpkg/shell for cross-platform e2e tests
- Replace platform-specific shell (cmd.exe/sh) with @yarnpkg/shell for consistent cross-platform behavior in e2e tests - Add Node.js experimental warning filtering in redact.rs to handle Type Stripping warnings from newer Node.js versions - Add @yarnpkg/shell 4.1.3 dependency to test_bins - Use `which` crate to locate shell executable in test_bins Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6f275f9 commit f50f05e

6 files changed

Lines changed: 240 additions & 15 deletions

File tree

crates/vite_task_bin/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ which = { workspace = true }
2424
[dev-dependencies]
2525
copy_dir = { workspace = true }
2626
cow-utils = { workspace = true }
27+
which = { workspace = true }
2728
insta = { workspace = true, features = ["glob", "json", "redactions", "filters", "ron"] }
2829
regex = { workspace = true }
2930
serde = { workspace = true, features = ["derive", "rc"] }

crates/vite_task_bin/test_bins/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"replace-file-content": "./src/replace-file-content.ts"
1010
},
1111
"dependencies": {
12+
"@yarnpkg/shell": "catalog:",
1213
"cross-env": "^10.1.0",
1314
"oxlint": "catalog:",
1415
"vite-task-test-bins": "link:"

crates/vite_task_bin/tests/test_snapshots/main.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) {
8282
.into_os_string(),
8383
);
8484

85+
// Find @yarnpkg/shell executable in test_bins
86+
let shell_exe = which::which_in("shell", Some(&*test_bin_path), std::env::current_dir().unwrap())
87+
.expect("shell executable not found in test_bins/node_modules/.bin");
88+
8589
// Add test_bins to PATH so test programs (such as print-file) in fixtures can be found.
8690
let plan_envs: HashMap<Arc<OsStr>, Arc<OsStr>> = [
8791
(Arc::<OsStr>::from(OsStr::new("PATH")), Arc::clone(&test_bin_path)),
@@ -172,21 +176,8 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) {
172176

173177
let mut e2e_outputs = String::new();
174178
for step in e2e.steps {
175-
let mut cmd = if cfg!(windows) {
176-
let mut cmd = Command::new("cmd.exe");
177-
// https://github.com/nodejs/node/blob/dbd24b165128affb7468ca42f69edaf7e0d85a9a/lib/child_process.js#L633
178-
cmd.args(["/d", "/s", "/c"]);
179-
cmd
180-
} else {
181-
let mut cmd = Command::new("sh");
182-
cmd.args(["-c"]);
183-
cmd
184-
};
185-
// On Windows, env_clear() would break cmd.exe, so only set PATH
186-
// On Unix, clear all envs for reproducibility
187-
if !cfg!(windows) {
188-
cmd.env_clear();
189-
}
179+
// Use @yarnpkg/shell for cross-platform shell execution
180+
let mut cmd = Command::new(&shell_exe);
190181
cmd.arg(step.as_str())
191182
.env("PATH", &e2e_env_path)
192183
.env("NO_COLOR", "1")

crates/vite_task_bin/tests/test_snapshots/redact.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ pub fn redact_e2e_output(mut output: String, workspace_root: &str) -> String {
6767
let thread_regex = regex::Regex::new(r"using \d+ threads").unwrap();
6868
output = thread_regex.replace_all(&output, "using <n> threads").into_owned();
6969

70+
// Remove Node.js experimental warnings (e.g., Type Stripping warnings)
71+
let node_warning_regex =
72+
regex::Regex::new(r"(?m)^\(node:\d+\) ExperimentalWarning:.*\n?").unwrap();
73+
output = node_warning_regex.replace_all(&output, "").into_owned();
74+
let node_trace_warning_regex = regex::Regex::new(
75+
r"(?m)^\(Use `node --trace-warnings \.\.\.` to show where the warning was created\)\n?",
76+
)
77+
.unwrap();
78+
output = node_trace_warning_regex.replace_all(&output, "").into_owned();
79+
7080
output
7181
}
7282

0 commit comments

Comments
 (0)