|
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 | 1 | [[e2e]] |
5 | 2 | name = "auto_output___files_restored_on_cache_hit" |
| 3 | +comment = """ |
| 4 | +Auto output detection (default): output files written by the task are |
| 5 | +restored on a cache hit. |
| 6 | +""" |
6 | 7 | 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 (keep directory to avoid fspy inferred-input miss on Windows) |
12 | | - ["vtt", "rm", "dist/out.txt"], |
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"], |
| 8 | + { argv = ["vt", "run", "auto-output"], comment = "first run writes dist/out.txt" }, |
| 9 | + { argv = ["vtt", "print-file", "dist/out.txt"], comment = "output exists after the build" }, |
| 10 | + { argv = ["vtt", "rm", "dist/out.txt"], comment = "delete only the file (keep dir to avoid an fspy inferred-input miss on Windows)" }, |
| 11 | + { argv = ["vt", "run", "auto-output"], comment = "cache hit, should restore dist/out.txt" }, |
| 12 | + { argv = ["vtt", "print-file", "dist/out.txt"], comment = "output was restored from the archive" }, |
17 | 13 | ] |
18 | 14 |
|
19 | | -# 2. Glob output: only files matching output globs are restored |
20 | 15 | [[e2e]] |
21 | 16 | name = "glob_output___only_matched_files_restored" |
| 17 | +comment = """ |
| 18 | +Glob output: only files matching the configured output globs are restored |
| 19 | +on a cache hit; files produced outside those globs are left alone. |
| 20 | +""" |
22 | 21 | steps = [ |
23 | | - [ |
24 | | - "vt", |
25 | | - "run", |
26 | | - "glob-output", |
27 | | - ], |
28 | | - [ |
29 | | - "vtt", |
30 | | - "rm", |
31 | | - "dist/out.txt", |
32 | | - ], |
33 | | - [ |
34 | | - "vtt", |
35 | | - "rm", |
36 | | - "tmp/temp.txt", |
37 | | - ], |
38 | | - # Second run - cache hit, should restore dist/out.txt but not tmp/temp.txt |
39 | | - [ |
40 | | - "vt", |
41 | | - "run", |
42 | | - "glob-output", |
43 | | - ], |
44 | | - [ |
45 | | - "vtt", |
46 | | - "print-file", |
47 | | - "dist/out.txt", |
48 | | - ], |
49 | | - # tmp/temp.txt should NOT exist (not in output globs) |
50 | | - { argv = [ |
51 | | - "vtt", |
52 | | - "print-file", |
53 | | - "tmp/temp.txt", |
54 | | - ], comment = "should fail - tmp not in output globs" }, |
| 22 | + { argv = ["vt", "run", "glob-output"], comment = "first run writes dist/out.txt and tmp/temp.txt" }, |
| 23 | + { argv = ["vtt", "rm", "dist/out.txt"], comment = "delete the glob-matched output" }, |
| 24 | + { argv = ["vtt", "rm", "tmp/temp.txt"], comment = "delete the non-matched output" }, |
| 25 | + { argv = ["vt", "run", "glob-output"], comment = "cache hit: should restore dist/out.txt but not tmp/temp.txt" }, |
| 26 | + { argv = ["vtt", "print-file", "dist/out.txt"], comment = "dist/out.txt was restored" }, |
| 27 | + { argv = ["vtt", "print-file", "tmp/temp.txt"], comment = "should fail - tmp not in output globs" }, |
55 | 28 | ] |
56 | 29 |
|
57 | | -# 3. Auto output works independently of input auto |
58 | 30 | [[e2e]] |
59 | 31 | name = "auto_output_with_non_auto_input" |
| 32 | +comment = """ |
| 33 | +Auto output works even when input tracking is explicit |
| 34 | +(`input: [\"src/**\"]`). Output auto-detection and input auto-detection |
| 35 | +are independent. |
| 36 | +""" |
60 | 37 | steps = [ |
61 | | - # First run - input: ["src/**"] (no auto), output: default (auto) |
62 | | - ["vt", "run", "auto-output-no-auto-input"], |
63 | | - ["vtt", "rm", "dist/out.txt"], |
64 | | - # Cache hit - output files should still be restored |
65 | | - ["vt", "run", "auto-output-no-auto-input"], |
66 | | - ["vtt", "print-file", "dist/out.txt"], |
| 38 | + { argv = ["vt", "run", "auto-output-no-auto-input"], comment = "first run: input src/** (no auto), output default (auto)" }, |
| 39 | + { argv = ["vtt", "rm", "dist/out.txt"], comment = "delete the output" }, |
| 40 | + { argv = ["vt", "run", "auto-output-no-auto-input"], comment = "cache hit - output files should still be restored" }, |
| 41 | + { argv = ["vtt", "print-file", "dist/out.txt"], comment = "output was restored" }, |
67 | 42 | ] |
68 | 43 |
|
69 | | -# 4. Negative output globs exclude files from restoration |
70 | 44 | [[e2e]] |
71 | 45 | name = "negative_output___excluded_files_not_restored" |
| 46 | +comment = """ |
| 47 | +Negative output globs exclude matching files from the cache archive, so |
| 48 | +they are not restored on a cache hit even though the task produced them. |
| 49 | +""" |
72 | 50 | steps = [ |
73 | | - [ |
74 | | - "vt", |
75 | | - "run", |
76 | | - "negative-output", |
77 | | - ], |
78 | | - [ |
79 | | - "vtt", |
80 | | - "rm", |
81 | | - "dist/out.txt", |
82 | | - ], |
83 | | - [ |
84 | | - "vtt", |
85 | | - "rm", |
86 | | - "dist/cache/tmp.txt", |
87 | | - ], |
88 | | - # Cache hit - should restore dist/out.txt but NOT dist/cache/tmp.txt |
89 | | - [ |
90 | | - "vt", |
91 | | - "run", |
92 | | - "negative-output", |
93 | | - ], |
94 | | - [ |
95 | | - "vtt", |
96 | | - "print-file", |
97 | | - "dist/out.txt", |
98 | | - ], |
99 | | - # dist/cache/tmp.txt should NOT exist (excluded by !dist/cache/**) |
100 | | - { argv = [ |
101 | | - "vtt", |
102 | | - "print-file", |
103 | | - "dist/cache/tmp.txt", |
104 | | - ], comment = "should fail - excluded by negative glob" }, |
| 51 | + { argv = ["vt", "run", "negative-output"], comment = "first run writes dist/out.txt and dist/cache/tmp.txt" }, |
| 52 | + { argv = ["vtt", "rm", "dist/out.txt"], comment = "delete the archived output" }, |
| 53 | + { argv = ["vtt", "rm", "dist/cache/tmp.txt"], comment = "delete the excluded output" }, |
| 54 | + { argv = ["vt", "run", "negative-output"], comment = "cache hit: should restore dist/out.txt but NOT dist/cache/tmp.txt" }, |
| 55 | + { argv = ["vtt", "print-file", "dist/out.txt"], comment = "dist/out.txt was restored" }, |
| 56 | + { argv = ["vtt", "print-file", "dist/cache/tmp.txt"], comment = "should fail - excluded by !dist/cache/**" }, |
105 | 57 | ] |
106 | 58 |
|
107 | | -# 5. Changing output config invalidates cache |
108 | 59 | [[e2e]] |
109 | 60 | name = "output_config_change_invalidates_cache" |
| 61 | +comment = """ |
| 62 | +Changing a task's output configuration invalidates the cache entry — |
| 63 | +the next run is a miss, not a hit of the stale archive. |
| 64 | +""" |
110 | 65 | steps = [ |
111 | | - ["vt", "run", "output-config-change"], |
112 | | - # Change output config |
113 | | - ["vtt", "replace-file-content", "vite-task.json", 'REPLACE_ME', 'dist/**'], |
114 | | - # Should be a cache miss due to output config change |
| 66 | + { argv = ["vt", "run", "output-config-change"], comment = "first run populates the cache" }, |
| 67 | + { argv = ["vtt", "replace-file-content", "vite-task.json", "REPLACE_ME", "dist/**"], comment = "change the output globs in the task config" }, |
115 | 68 | { argv = ["vt", "run", "output-config-change"], comment = "cache miss: output config changed" }, |
116 | 69 | ] |
117 | 70 |
|
118 | | -# 6. Input negative globs must not drop matching writes from the output archive. |
119 | | -# Here the user excludes `dist/**` from inferred inputs (so rewriting dist/ won't |
120 | | -# mark inputs as modified), but default auto output should still capture dist |
121 | | -# writes and restore them on a cache hit. |
122 | 71 | [[e2e]] |
123 | 72 | name = "input_negative_does_not_drop_output_writes" |
| 73 | +comment = """ |
| 74 | +Input negative globs must not drop matching writes from the output |
| 75 | +archive. Here the user excludes `dist/**` from inferred inputs (so |
| 76 | +rewriting dist/ won't mark inputs as modified), but default auto output |
| 77 | +should still capture dist writes and restore them on a cache hit. |
| 78 | +""" |
124 | 79 | steps = [ |
125 | | - ["vt", "run", "input-neg-dist-auto-output"], |
126 | | - ["vtt", "rm", "dist/out.txt"], |
127 | | - # Cache hit should restore dist/out.txt |
128 | | - ["vt", "run", "input-neg-dist-auto-output"], |
129 | | - ["vtt", "print-file", "dist/out.txt"], |
| 80 | + { argv = ["vt", "run", "input-neg-dist-auto-output"], comment = "first run writes dist/out.txt" }, |
| 81 | + { argv = ["vtt", "rm", "dist/out.txt"], comment = "delete the output" }, |
| 82 | + { argv = ["vt", "run", "input-neg-dist-auto-output"], comment = "cache hit should restore dist/out.txt" }, |
| 83 | + { argv = ["vtt", "print-file", "dist/out.txt"], comment = "output was restored despite dist/** being a negative input glob" }, |
130 | 84 | ] |
131 | 85 |
|
132 | | -# 7. When input auto is disabled (explicit globs only), unrelated reads tracked |
133 | | -# by fspy must NOT become inferred inputs. Default auto output still needs fspy |
134 | | -# for write tracking, but reads outside `input: ["src/**"]` should be ignored. |
135 | 86 | [[e2e]] |
136 | 87 | name = "explicit_input_ignores_fspy_reads" |
| 88 | +comment = """ |
| 89 | +When input auto is disabled (explicit globs only), unrelated reads |
| 90 | +tracked by fspy must NOT become inferred inputs. Default auto output |
| 91 | +still needs fspy for write tracking, but reads outside `input: [\"src/**\"]` |
| 92 | +should be ignored. |
| 93 | +""" |
137 | 94 | steps = [ |
138 | | - [ |
139 | | - "vt", |
140 | | - "run", |
141 | | - "explicit-input-auto-output", |
142 | | - ], |
143 | | - # Modify README.md (read by the task, NOT in input globs) |
144 | | - [ |
145 | | - "vtt", |
146 | | - "replace-file-content", |
147 | | - "README.md", |
148 | | - "v1", |
149 | | - "v2", |
150 | | - ], |
151 | | - # Should be a cache hit: README.md is not an input |
152 | | - { argv = [ |
153 | | - "vt", |
154 | | - "run", |
155 | | - "explicit-input-auto-output", |
156 | | - ], comment = "cache hit: README.md not in input globs" }, |
| 95 | + { argv = ["vt", "run", "explicit-input-auto-output"], comment = "first run reads README.md (not in input globs) and captures the output" }, |
| 96 | + { argv = ["vtt", "replace-file-content", "README.md", "v1", "v2"], comment = "modify README.md — not an input, so it must not invalidate the cache" }, |
| 97 | + { argv = ["vt", "run", "explicit-input-auto-output"], comment = "cache hit: README.md not in input globs" }, |
157 | 98 | ] |
0 commit comments