Skip to content

Commit ef2c4b4

Browse files
branchseerclaude
andcommitted
test(e2e): remove node dependency from fixtures
Replace all `node` usages in e2e test fixtures with vtt subcommands: - `node -e "process.exit(N)"` → `vtt exit N` (new subcommand) - `node read_node_fs.js` → `vtt print` (test only needs a successful command) - Remove `replay-logs-chronological-order` fixture (complex node script) This eliminates the dependency on `node` being in PATH for e2e tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 80d0cb0 commit ef2c4b4

File tree

20 files changed

+43
-443
lines changed

20 files changed

+43
-443
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pub fn run(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
2+
let code: i32 = args.first().map(|s| s.parse()).transpose()?.unwrap_or(0);
3+
std::process::exit(code);
4+
}

crates/vite_task_bin/src/vtt/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
mod barrier;
1010
mod check_tty;
1111
mod cp;
12+
mod exit;
1213
mod mkdir;
1314
mod pipe_stdin;
1415
mod print;
@@ -26,7 +27,7 @@ fn main() {
2627
if args.len() < 2 {
2728
eprintln!("Usage: vtt <subcommand> [args...]");
2829
eprintln!(
29-
"Subcommands: barrier, check-tty, cp, mkdir, pipe-stdin, print, print-cwd, print-env, print-file, read-stdin, replace-file-content, rm, touch-file, write-file"
30+
"Subcommands: barrier, check-tty, cp, exit, mkdir, pipe-stdin, print, print-cwd, print-env, print-file, read-stdin, replace-file-content, rm, touch-file, write-file"
3031
);
3132
std::process::exit(1);
3233
}
@@ -38,6 +39,7 @@ fn main() {
3839
Ok(())
3940
}
4041
"cp" => cp::run(&args[2..]),
42+
"exit" => exit::run(&args[2..]),
4143
"mkdir" => mkdir::run(&args[2..]),
4244
"print" => {
4345
print::run(&args[2..]);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
initial
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"scripts": {
3-
"read_colon_in_name": "node read_node_fs.js"
3+
"read_colon_in_name": "vtt print-file node:fs"
44
}
55
}

crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/read_node_fs.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/snapshots.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Tests that fs.read('node:fs') with colon in filename works correctly
1+
# Tests that a file with colon in its name works correctly with caching
22

33
[[e2e]]
44
name = "read file with colon in name"
@@ -13,4 +13,16 @@ steps = [
1313
"run",
1414
"read_colon_in_name",
1515
], comment = "cache hit" },
16+
{ argv = [
17+
"vtt",
18+
"replace-file-content",
19+
"node:fs",
20+
"initial",
21+
"modified",
22+
], comment = "modify file" },
23+
{ argv = [
24+
"vt",
25+
"run",
26+
"read_colon_in_name",
27+
], comment = "cache miss after modification" },
1628
]

crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/snapshots/read file with colon in name.snap

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@ source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
33
expression: e2e_outputs
44
---
55
> vt run read_colon_in_name # cache miss
6-
$ node read_node_fs.js
6+
$ vtt print-file node:fs
7+
initial
78
> vt run read_colon_in_name # cache hit
8-
$ node read_node_fs.jscache hit, replaying
9+
$ vtt print-file node:fscache hit, replaying
10+
initial
911

1012
---
1113
vt run: cache hit.
14+
> vtt replace-file-content node:fs initial modified # modify file
15+
16+
> vt run read_colon_in_name # cache miss after modification
17+
$ vtt print-file node:fscache miss: 'node:fs' modified, executing
18+
modified
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "pkg-a",
33
"scripts": {
4-
"fail": "node -e \"process.exit(42)\"",
5-
"check": "node -e \"process.exit(1)\"",
6-
"chained": "node -e \"process.exit(3)\" && echo 'second'"
4+
"fail": "vtt exit 42",
5+
"check": "vtt exit 1",
6+
"chained": "vtt exit 3 && echo 'second'"
77
}
88
}

crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes/packages/pkg-b/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "pkg-b",
33
"scripts": {
4-
"fail": "node -e \"process.exit(7)\"",
4+
"fail": "vtt exit 7",
55
"check": "echo 'pkg-b check passed'"
66
},
77
"dependencies": {

crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes/snapshots/chained command with && stops at first failure.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
33
expression: e2e_outputs
44
---
55
[3]> vt run pkg-a#chained # first fails with exit code 3, second should not run
6-
~/packages/pkg-a$ node -e "process.exit(3)"
6+
~/packages/pkg-a$ vtt exit 3

0 commit comments

Comments
 (0)