Skip to content

Commit d73dd3b

Browse files
branchseerclaude
andcommitted
test(e2e): add comprehensive output-cache-test fixture
Add 5 e2e test cases covering output restoration: - Auto output detection: files restored on cache hit - Glob output: only matched files restored (dist/ yes, tmp/ no) - Auto output with non-auto input: output auto works independently - Negative output globs: excluded files not restored - Output config change: invalidates cache with descriptive message Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2a08d90 commit d73dd3b

File tree

9 files changed

+314
-0
lines changed

9 files changed

+314
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "output-cache-test",
3+
"private": true
4+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Test output restoration when cached tasks are replayed
2+
3+
# 1. Auto output detection (default): output files written by the task are restored on cache hit
4+
[[e2e]]
5+
name = "auto output - files restored on cache hit"
6+
steps = [
7+
# First run - writes dist/out.txt
8+
["vt", "run", "auto-output"],
9+
# Verify output exists
10+
["vtt", "print-file", "dist/out.txt"],
11+
# Delete the output file
12+
["vtt", "rm", "-rf", "dist"],
13+
# Second run - cache hit, should restore dist/out.txt
14+
["vt", "run", "auto-output"],
15+
# Verify output was restored
16+
["vtt", "print-file", "dist/out.txt"],
17+
]
18+
19+
# 2. Glob output: only files matching output globs are restored
20+
[[e2e]]
21+
name = "glob output - only matched files restored"
22+
steps = [
23+
# First run - writes to dist/ and tmp/
24+
[
25+
"vt",
26+
"run",
27+
"glob-output",
28+
],
29+
# Delete both output directories
30+
[
31+
"vtt",
32+
"rm",
33+
"-rf",
34+
"dist",
35+
],
36+
[
37+
"vtt",
38+
"rm",
39+
"-rf",
40+
"tmp",
41+
],
42+
# Second run - cache hit, should restore dist/ but not tmp/
43+
[
44+
"vt",
45+
"run",
46+
"glob-output",
47+
],
48+
# dist/out.txt should be restored
49+
[
50+
"vtt",
51+
"print-file",
52+
"dist/out.txt",
53+
],
54+
# tmp/temp.txt should NOT exist (not in output globs)
55+
{ argv = [
56+
"vtt",
57+
"print-file",
58+
"tmp/temp.txt",
59+
], comment = "should fail - tmp not in output globs" },
60+
]
61+
62+
# 3. Auto output works independently of input auto
63+
[[e2e]]
64+
name = "auto output with non-auto input"
65+
steps = [
66+
# First run - input: ["src/**"] (no auto), output: default (auto)
67+
["vt", "run", "auto-output-no-auto-input"],
68+
# Delete output
69+
["vtt", "rm", "-rf", "dist"],
70+
# Cache hit - output files should still be restored
71+
["vt", "run", "auto-output-no-auto-input"],
72+
# Verify output was restored
73+
["vtt", "print-file", "dist/out.txt"],
74+
]
75+
76+
# 4. Negative output globs exclude files from restoration
77+
[[e2e]]
78+
name = "negative output - excluded files not restored"
79+
steps = [
80+
# First run - writes to dist/out.txt and dist/cache/tmp.txt
81+
[
82+
"vt",
83+
"run",
84+
"negative-output",
85+
],
86+
# Delete all outputs
87+
[
88+
"vtt",
89+
"rm",
90+
"-rf",
91+
"dist",
92+
],
93+
# Cache hit - should restore dist/out.txt but NOT dist/cache/tmp.txt
94+
[
95+
"vt",
96+
"run",
97+
"negative-output",
98+
],
99+
# dist/out.txt should be restored
100+
[
101+
"vtt",
102+
"print-file",
103+
"dist/out.txt",
104+
],
105+
# dist/cache/tmp.txt should NOT exist (excluded by !dist/cache/**)
106+
{ argv = [
107+
"vtt",
108+
"print-file",
109+
"dist/cache/tmp.txt",
110+
], comment = "should fail - excluded by negative glob" },
111+
]
112+
113+
# 5. Changing output config invalidates cache
114+
[[e2e]]
115+
name = "output config change invalidates cache"
116+
steps = [
117+
# First run
118+
["vt", "run", "output-config-change"],
119+
# Change output config
120+
["vtt", "replace-file-content", "vite-task.json", 'REPLACE_ME', 'dist/**'],
121+
# Should be a cache miss due to output config change
122+
{ argv = ["vt", "run", "output-config-change"], comment = "cache miss: output config changed" },
123+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vt run auto-output
6+
$ vtt mkdir -p dist
7+
8+
$ vtt write-file dist/out.txt built
9+
10+
$ vtt print done
11+
done
12+
13+
---
14+
vt run: 0/3 cache hit (0%). (Run `vt run --last-details` for full details)
15+
> vtt print-file dist/out.txt
16+
built
17+
> vtt rm -rf dist
18+
19+
> vt run auto-output
20+
$ vtt mkdir -p distcache hit, replaying
21+
22+
$ vtt write-file dist/out.txt builtcache hit, replaying
23+
24+
$ vtt print donecache hit, replaying
25+
done
26+
27+
---
28+
vt run: 3/3 cache hit (100%). (Run `vt run --last-details` for full details)
29+
> vtt print-file dist/out.txt
30+
built
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vt run auto-output-no-auto-input
6+
$ vtt mkdir -p dist
7+
8+
$ vtt write-file dist/out.txt built
9+
10+
$ vtt print done
11+
done
12+
13+
---
14+
vt run: 0/3 cache hit (0%). (Run `vt run --last-details` for full details)
15+
> vtt rm -rf dist
16+
17+
> vt run auto-output-no-auto-input
18+
$ vtt mkdir -p distcache hit, replaying
19+
20+
$ vtt write-file dist/out.txt builtcache hit, replaying
21+
22+
$ vtt print donecache hit, replaying
23+
done
24+
25+
---
26+
vt run: 3/3 cache hit (100%). (Run `vt run --last-details` for full details)
27+
> vtt print-file dist/out.txt
28+
built
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vt run glob-output
6+
$ vtt mkdir -p dist
7+
8+
$ vtt write-file dist/out.txt built
9+
10+
$ vtt mkdir -p tmp
11+
12+
$ vtt write-file tmp/temp.txt temp
13+
14+
$ vtt print done
15+
done
16+
17+
---
18+
vt run: 0/5 cache hit (0%). (Run `vt run --last-details` for full details)
19+
> vtt rm -rf dist
20+
21+
> vtt rm -rf tmp
22+
23+
> vt run glob-output
24+
$ vtt mkdir -p distcache hit, replaying
25+
26+
$ vtt write-file dist/out.txt builtcache hit, replaying
27+
28+
$ vtt mkdir -p tmpcache hit, replaying
29+
30+
$ vtt write-file tmp/temp.txt tempcache hit, replaying
31+
32+
$ vtt print donecache hit, replaying
33+
done
34+
35+
---
36+
vt run: 5/5 cache hit (100%). (Run `vt run --last-details` for full details)
37+
> vtt print-file dist/out.txt
38+
built
39+
> vtt print-file tmp/temp.txt # should fail - tmp not in output globs
40+
tmp/temp.txt: not found
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vt run negative-output
6+
$ vtt mkdir -p dist/cache
7+
8+
$ vtt write-file dist/out.txt built
9+
10+
$ vtt write-file dist/cache/tmp.txt temp
11+
12+
$ vtt print done
13+
done
14+
15+
---
16+
vt run: 0/4 cache hit (0%). (Run `vt run --last-details` for full details)
17+
> vtt rm -rf dist
18+
19+
> vt run negative-output
20+
$ vtt mkdir -p dist/cachecache hit, replaying
21+
22+
$ vtt write-file dist/out.txt builtcache hit, replaying
23+
24+
$ vtt write-file dist/cache/tmp.txt tempcache hit, replaying
25+
26+
$ vtt print donecache hit, replaying
27+
done
28+
29+
---
30+
vt run: 4/4 cache hit (100%). (Run `vt run --last-details` for full details)
31+
> vtt print-file dist/out.txt
32+
built
33+
> vtt print-file dist/cache/tmp.txt # should fail - excluded by negative glob
34+
dist/cache/tmp.txt: not found
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vt run output-config-change
6+
$ vtt mkdir -p dist
7+
8+
$ vtt write-file dist/out.txt built
9+
10+
$ vtt print done
11+
done
12+
13+
---
14+
vt run: 0/3 cache hit (0%). (Run `vt run --last-details` for full details)
15+
> vtt replace-file-content vite-task.json REPLACE_ME dist/**
16+
17+
> vt run output-config-change # cache miss: output config changed
18+
$ vtt mkdir -p dist ○ cache miss: output configuration changed, executing
19+
20+
$ vtt write-file dist/out.txt built ○ cache miss: output configuration changed, executing
21+
22+
$ vtt print done ○ cache miss: output configuration changed, executing
23+
done
24+
25+
---
26+
vt run: 0/3 cache hit (0%). (Run `vt run --last-details` for full details)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const main = 'initial';
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"tasks": {
3+
"auto-output": {
4+
"command": "vtt mkdir -p dist && vtt write-file dist/out.txt built && vtt print done",
5+
"cache": true
6+
},
7+
"glob-output": {
8+
"command": "vtt mkdir -p dist && vtt write-file dist/out.txt built && vtt mkdir -p tmp && vtt write-file tmp/temp.txt temp && vtt print done",
9+
"output": ["dist/**"],
10+
"cache": true
11+
},
12+
"auto-output-no-auto-input": {
13+
"command": "vtt mkdir -p dist && vtt write-file dist/out.txt built && vtt print done",
14+
"input": ["src/**"],
15+
"cache": true
16+
},
17+
"negative-output": {
18+
"command": "vtt mkdir -p dist/cache && vtt write-file dist/out.txt built && vtt write-file dist/cache/tmp.txt temp && vtt print done",
19+
"output": [{ "auto": true }, "!dist/cache/**"],
20+
"cache": true
21+
},
22+
"output-config-change": {
23+
"command": "vtt mkdir -p dist && vtt write-file dist/out.txt built && vtt print done",
24+
"output": ["REPLACE_ME"],
25+
"cache": true
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)