Skip to content

Commit 90fdf91

Browse files
committed
test(e2e): inline step comments + assert skip.txt is not restored
- Move the descriptive comments out of TOML `#` lines (invisible to snapshots) and into per-step `comment =` fields, so the rendered snapshot describes what each step is doing. - In the negative-excludes scenario, follow the restoration step with a `vtt print-file dist/skip.txt` to assert that the excluded file is reported as "not found" — proving the negative glob keeps the file out of the archive, not just out of the initial walk.
1 parent 015a9a6 commit 90fdf91

4 files changed

Lines changed: 136 additions & 34 deletions

File tree

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

Lines changed: 94 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,73 @@ With explicit output globs (`dist/**`), the first run writes a file to
66
cache hit and the archived output file is restored.
77
"""
88
steps = [
9-
# First run - cache miss, writes dist/output.txt
10-
["vt", "run", "build"],
11-
# Verify file was written
12-
["vtt", "print-file", "dist/output.txt"],
13-
# Delete dist/ to prove restoration is real
14-
["vtt", "rm", "-rf", "dist"],
15-
# Second run - cache hit, restores dist/output.txt from archive
16-
["vt", "run", "build"],
17-
# File should be restored
18-
["vtt", "print-file", "dist/output.txt"],
9+
{ argv = [
10+
"vt",
11+
"run",
12+
"build",
13+
], comment = "first run — cache miss, writes dist/output.txt" },
14+
{ argv = [
15+
"vtt",
16+
"print-file",
17+
"dist/output.txt",
18+
], comment = "file is on disk after the run" },
19+
{ argv = [
20+
"vtt",
21+
"rm",
22+
"-rf",
23+
"dist",
24+
], comment = "delete dist/ to prove the restore is real" },
25+
{ argv = [
26+
"vt",
27+
"run",
28+
"build",
29+
], comment = "second run — cache hit, restores from archive" },
30+
{ argv = [
31+
"vtt",
32+
"print-file",
33+
"dist/output.txt",
34+
], comment = "file restored from archive" },
1935
]
2036

2137
[[e2e]]
2238
name = "output_globs___old_archive_removed_on_rewrite"
2339
comment = """
2440
When a cached task re-runs (cache miss because an input changed), it
2541
writes a new archive and the previous archive file is cleaned up. After
26-
two runs of the same task the cache directory still contains only one
27-
\\\".tar.zst\\\" file.
42+
two cache-missing runs of the same task the cache directory still
43+
contains only one `.tar.zst` archive.
2844
"""
2945
steps = [
30-
# First run - cache miss, produces archive A
31-
["vt", "run", "build"],
32-
# Exactly one archive on disk
33-
["vtt", "list-dir", "node_modules/.vite/task-cache", "--ext", ".tar.zst"],
34-
# Modify the input so the next run is a cache miss
35-
["vtt", "write-file", "src/main.ts", "changed"],
36-
# Second run - cache miss, produces archive B; archive A is deleted
37-
["vt", "run", "build"],
38-
# Still only one archive on disk (A removed, B written)
39-
["vtt", "list-dir", "node_modules/.vite/task-cache", "--ext", ".tar.zst"],
46+
{ argv = [
47+
"vt",
48+
"run",
49+
"build",
50+
], comment = "first run — cache miss, writes archive A" },
51+
{ argv = [
52+
"vtt",
53+
"list-dir",
54+
"node_modules/.vite/task-cache",
55+
"--ext",
56+
".tar.zst",
57+
], comment = "exactly one archive on disk" },
58+
{ argv = [
59+
"vtt",
60+
"write-file",
61+
"src/main.ts",
62+
"changed",
63+
], comment = "modify an input so the next run is a cache miss" },
64+
{ argv = [
65+
"vt",
66+
"run",
67+
"build",
68+
], comment = "second run — cache miss, writes archive B and removes A" },
69+
{ argv = [
70+
"vtt",
71+
"list-dir",
72+
"node_modules/.vite/task-cache",
73+
"--ext",
74+
".tar.zst",
75+
], comment = "still exactly one archive — A was cleaned up" },
4076
]
4177

4278
[[e2e]]
@@ -46,14 +82,40 @@ A file matched by a negative output glob is not archived, so it is not
4682
restored on cache hit.
4783
"""
4884
steps = [
49-
# First run - writes both dist/keep.txt and dist/skip.txt
50-
["vt", "run", "build-with-negative"],
51-
# Both files exist after the run
52-
["vtt", "print-file", "dist/keep.txt"],
53-
["vtt", "print-file", "dist/skip.txt"],
54-
# Delete dist/ to prove restoration is real
55-
["vtt", "rm", "-rf", "dist"],
56-
# Second run - cache hit, only dist/keep.txt is restored
57-
["vt", "run", "build-with-negative"],
58-
["vtt", "print-file", "dist/keep.txt"],
85+
{ argv = [
86+
"vt",
87+
"run",
88+
"build-with-negative",
89+
], comment = "first run — writes dist/keep.txt and dist/skip.txt" },
90+
{ argv = [
91+
"vtt",
92+
"print-file",
93+
"dist/keep.txt",
94+
], comment = "keep.txt was written" },
95+
{ argv = [
96+
"vtt",
97+
"print-file",
98+
"dist/skip.txt",
99+
], comment = "skip.txt was written" },
100+
{ argv = [
101+
"vtt",
102+
"rm",
103+
"-rf",
104+
"dist",
105+
], comment = "delete dist/ to prove the restore is real" },
106+
{ argv = [
107+
"vt",
108+
"run",
109+
"build-with-negative",
110+
], comment = "second run — cache hit, restores from archive" },
111+
{ argv = [
112+
"vtt",
113+
"print-file",
114+
"dist/keep.txt",
115+
], comment = "keep.txt restored from archive" },
116+
{ argv = [
117+
"vtt",
118+
"print-file",
119+
"dist/skip.txt",
120+
], comment = "skip.txt is NOT restored — it was excluded by the negative glob" },
59121
]

crates/vite_task_bin/tests/e2e_snapshots/fixtures/output_cache_test/snapshots/output_globs___files_restored_on_cache_hit.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,31 @@ cache hit and the archived output file is restored.
66

77
## `vt run build`
88

9+
first run — cache miss, writes dist/output.txt
10+
911
```
1012
$ vtt write-file dist/output.txt built
1113
```
1214

1315
## `vtt print-file dist/output.txt`
1416

17+
file is on disk after the run
18+
1519
```
1620
built
1721
```
1822

1923
## `vtt rm -rf dist`
2024

25+
delete dist/ to prove the restore is real
26+
2127
```
2228
```
2329

2430
## `vt run build`
2531

32+
second run — cache hit, restores from archive
33+
2634
```
2735
$ vtt write-file dist/output.txt built ◉ cache hit, replaying
2836
@@ -32,6 +40,8 @@ vt run: cache hit.
3240

3341
## `vtt print-file dist/output.txt`
3442

43+
file restored from archive
44+
3545
```
3646
built
3747
```

crates/vite_task_bin/tests/e2e_snapshots/fixtures/output_cache_test/snapshots/output_globs___negative_excludes_files_from_archive.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ restored on cache hit.
55

66
## `vt run build-with-negative`
77

8+
first run — writes dist/keep.txt and dist/skip.txt
9+
810
```
911
$ vtt write-file dist/keep.txt keep
1012
@@ -16,23 +18,31 @@ vt run: 0/2 cache hit (0%). (Run `vt run --last-details` for full details)
1618

1719
## `vtt print-file dist/keep.txt`
1820

21+
keep.txt was written
22+
1923
```
2024
keep
2125
```
2226

2327
## `vtt print-file dist/skip.txt`
2428

29+
skip.txt was written
30+
2531
```
2632
skip
2733
```
2834

2935
## `vtt rm -rf dist`
3036

37+
delete dist/ to prove the restore is real
38+
3139
```
3240
```
3341

3442
## `vt run build-with-negative`
3543

44+
second run — cache hit, restores from archive
45+
3646
```
3747
$ vtt write-file dist/keep.txt keep ◉ cache hit, replaying
3848
@@ -44,6 +54,16 @@ vt run: 2/2 cache hit (100%). (Run `vt run --last-details` for full details)
4454

4555
## `vtt print-file dist/keep.txt`
4656

57+
keep.txt restored from archive
58+
4759
```
4860
keep
4961
```
62+
63+
## `vtt print-file dist/skip.txt`
64+
65+
skip.txt is NOT restored — it was excluded by the negative glob
66+
67+
```
68+
dist/skip.txt: not found
69+
```

crates/vite_task_bin/tests/e2e_snapshots/fixtures/output_cache_test/snapshots/output_globs___old_archive_removed_on_rewrite.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,44 @@
22

33
When a cached task re-runs (cache miss because an input changed), it
44
writes a new archive and the previous archive file is cleaned up. After
5-
two runs of the same task the cache directory still contains only one
6-
\".tar.zst\" file.
5+
two cache-missing runs of the same task the cache directory still
6+
contains only one `.tar.zst` archive.
77

88
## `vt run build`
99

10+
first run — cache miss, writes archive A
11+
1012
```
1113
$ vtt write-file dist/output.txt built
1214
```
1315

1416
## `vtt list-dir node_modules/.vite/task-cache --ext .tar.zst`
1517

18+
exactly one archive on disk
19+
1620
```
1721
<uuid>.tar.zst
1822
```
1923

2024
## `vtt write-file src/main.ts changed`
2125

26+
modify an input so the next run is a cache miss
27+
2228
```
2329
```
2430

2531
## `vt run build`
2632

33+
second run — cache miss, writes archive B and removes A
34+
2735
```
2836
$ vtt write-file dist/output.txt built ○ cache miss: 'src/main.ts' modified, executing
2937
```
3038

3139
## `vtt list-dir node_modules/.vite/task-cache --ext .tar.zst`
3240

41+
still exactly one archive — A was cleaned up
42+
3343
```
3444
<uuid>.tar.zst
3545
```

0 commit comments

Comments
 (0)