Skip to content

Commit a741fbf

Browse files
wan9chicodex
andcommitted
test(e2e): verify vite auto output restoration
Co-authored-by: GPT-5 Codex <codex@openai.com>
1 parent ae0da74 commit a741fbf

5 files changed

Lines changed: 96 additions & 10 deletions

File tree

crates/vite_task_bin/src/vtt/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ mod print_file;
2323
mod read_stdin;
2424
mod replace_file_content;
2525
mod rm;
26+
mod stat_file;
2627
mod touch_file;
2728
mod write_file;
2829

@@ -31,7 +32,7 @@ fn main() {
3132
if args.len() < 2 {
3233
eprintln!("Usage: vtt <subcommand> [args...]");
3334
eprintln!(
34-
"Subcommands: barrier, check-tty, cp, exit, exit-on-ctrlc, grep-file, list-dir, mkdir, pipe-stdin, print, print-color, print-cwd, print-env, print-file, read-stdin, replace-file-content, rm, touch-file, write-file"
35+
"Subcommands: barrier, check-tty, cp, exit, exit-on-ctrlc, grep-file, list-dir, mkdir, pipe-stdin, print, print-color, print-cwd, print-env, print-file, read-stdin, replace-file-content, rm, stat-file, touch-file, write-file"
3536
);
3637
std::process::exit(1);
3738
}
@@ -63,6 +64,10 @@ fn main() {
6364
"read-stdin" => read_stdin::run(),
6465
"replace-file-content" => replace_file_content::run(&args[2..]),
6566
"rm" => rm::run(&args[2..]),
67+
"stat-file" => {
68+
stat_file::run(&args[2..]);
69+
Ok(())
70+
}
6671
"touch-file" => touch_file::run(&args[2..]),
6772
"write-file" => write_file::run(&args[2..]),
6873
other => {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub fn run(args: &[String]) {
2+
for file in args {
3+
if std::fs::metadata(file).is_ok() {
4+
println!("{file}: exists");
5+
} else {
6+
println!("{file}: missing");
7+
}
8+
}
9+
}

crates/vite_task_bin/tests/e2e_snapshots/fixtures/vite_build_cache/snapshots.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
[[e2e]]
2+
name = "vite_build_caches_and_restores_outputs"
3+
comment = """
4+
`vt run --cache build` must produce a cache hit on the second run without any manual input/output configuration. Vite reports non-semantic reads and writes through `@voidzero-dev/vite-task-client`, so fspy can infer real inputs and outputs while the cache restores `dist/` on hit.
5+
"""
6+
ignore = true
7+
steps = [
8+
{ argv = [
9+
"vt",
10+
"run",
11+
"--cache",
12+
"build",
13+
], comment = "first run: cache miss, emits dist/" },
14+
{ argv = [
15+
"vtt",
16+
"stat-file",
17+
"dist/assets/main.js",
18+
], comment = "existence check — content can drift across Vite versions" },
19+
{ argv = [
20+
"vtt",
21+
"rm",
22+
"dist/assets/main.js",
23+
], comment = "remove the artefact so the cache-hit restore is observable" },
24+
{ argv = [
25+
"vt",
26+
"run",
27+
"--cache",
28+
"build",
29+
], comment = "cache hit: outputs restored without manual config" },
30+
{ argv = [
31+
"vtt",
32+
"stat-file",
33+
"dist/assets/main.js",
34+
], comment = "restored from the cache archive" },
35+
]
36+
137
[[e2e]]
238
name = "vite_prefix_env_change_invalidates_cache"
339
comment = """
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# vite_build_caches_and_restores_outputs
2+
3+
`vt run --cache build` must produce a cache hit on the second run without any manual input/output configuration. Vite reports non-semantic reads and writes through `@voidzero-dev/vite-task-client`, so fspy can infer real inputs and outputs while the cache restores `dist/` on hit.
4+
5+
## `vt run --cache build`
6+
7+
first run: cache miss, emits dist/
8+
9+
```
10+
$ vite build
11+
```
12+
13+
## `vtt stat-file dist/assets/main.js`
14+
15+
existence check — content can drift across Vite versions
16+
17+
```
18+
dist/assets/main.js: exists
19+
```
20+
21+
## `vtt rm dist/assets/main.js`
22+
23+
remove the artefact so the cache-hit restore is observable
24+
25+
```
26+
```
27+
28+
## `vt run --cache build`
29+
30+
cache hit: outputs restored without manual config
31+
32+
```
33+
$ vite build ◉ cache hit, replaying
34+
35+
---
36+
vt run: cache hit.
37+
```
38+
39+
## `vtt stat-file dist/assets/main.js`
40+
41+
restored from the cache archive
42+
43+
```
44+
dist/assets/main.js: exists
45+
```

crates/vite_task_bin/tests/e2e_snapshots/fixtures/vite_build_cache/vite-task.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@
55
// No `"env": [...]` — vite's patched `loadEnv` asks the runner for
66
// every `VITE_*` env via `getEnvs`, so the glob + match-set are
77
// fingerprinted automatically.
8-
//
9-
// TODO(env-track): A later PR in this stack removes these manual
10-
// exclusions once output tracking stops Vite's own writes from becoming
11-
// inferred inputs.
12-
//
13-
// Excluding Vite's build output and config-timestamp temp files from
14-
// auto input inference keeps this env-focused fixture cacheable without
15-
// turning reads of files Vite just wrote into inferred inputs.
16-
"input": ["!dist/**", "!node_modules/.vite-temp/**", { "auto": true }],
178
"cache": true
189
}
1910
}

0 commit comments

Comments
 (0)