/
githubmirror
/
deno
Обзор
Документация
Войти
/
githubmirror
/
deno
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tests/specs/task/input_cache/__test__.jsonc
178 строк
5 KB
Bartek Iwańczuk
feat(task): input-based caching with files/output/env (#34509)
24 июн 2026, 09:33
Не верифицирован
24 июн 2026, 09:33
72497f3
Код
Авторство
О чём код?
{ "tempDir": true, "tests": { // Changing the contents of an input file invalidates the cache; an // unchanged re-run hits. "content_change": { "steps": [ { "args": "task build", "output": "first.out" }, { "args": "task build", "output": "cached.out" }, { "args": [ "eval", "Deno.writeTextFileSync('src/in.ts', 'console.log(2)')" ], "output": "" }, { "args": "task build", "output": "changed.out" }, { "args": "task build", "output": "cached.out" } ] }, // Arguments appended on the CLI are part of the fingerprint: re-running // with the same args hits, but different args miss and run again. "args_are_fingerprinted": { "steps": [ { "args": "task build foo", "output": "Task build deno run src/in.ts 'foo'\n1\n" }, { "args": "task build foo", "output": "Task build deno run src/in.ts 'foo' (cached, inputs unchanged)\n" }, { "args": "task build bar", "output": "Task build deno run src/in.ts 'bar'\n1\n" }, { "args": "task build bar", "output": "Task build deno run src/in.ts 'bar' (cached, inputs unchanged)\n" } ] }, // A listed env var's value is part of the fingerprint: same value hits, // a changed value misses. "env_is_fingerprinted": { "steps": [ { "args": "task with_env", "envs": { "MY_VAR": "a" }, "output": "Task with_env deno run src/in.ts\n1\n" }, { "args": "task with_env", "envs": { "MY_VAR": "a" }, "output": "Task with_env deno run src/in.ts (cached, inputs unchanged)\n" }, { "args": "task with_env", "envs": { "MY_VAR": "b" }, "output": "Task with_env deno run src/in.ts\n1\n" } ] }, // Changing the command itself invalidates the cache even when inputs are // untouched. "command_change_invalidates": { "steps": [ { "args": "task build", "output": "first.out" }, { "args": [ "eval", "Deno.writeTextFileSync('deno.json', JSON.stringify({tasks:{build:{command:'deno run -q src/in.ts',files:['src/**/*.ts']}}}))" ], "output": "" }, { "args": "task build", "output": "Task build deno run -q src/in.ts\n1\n" } ] }, // An input glob that matches nothing is treated as non-cacheable, so the // task runs on every invocation instead of always hitting. "glob_matching_nothing_never_caches": { "steps": [ { "args": "task no_inputs", "output": "Task no_inputs deno run src/in.ts\n1\n" }, { "args": "task no_inputs", "output": "Task no_inputs deno run src/in.ts\n1\n" } ] }, // Declared outputs are captured on a successful run and restored on a hit, // so deleting them and re-running regenerates them from the cache instead // of leaving them missing. "output_restored_on_hit": { "steps": [ { "args": "task build_out", "output": "Task build_out deno run -A src/gen.ts\ngenerated\n" }, { "args": [ "eval", "console.log(Deno.readTextFileSync('dist/out.txt'))" ], "output": "artifact\n" }, { "args": ["eval", "Deno.removeSync('dist', { recursive: true })"], "output": "" }, { "args": "task build_out", "output": "Task build_out deno run -A src/gen.ts (cached, inputs unchanged)\n" }, // The deleted output is back, restored from the cache. { "args": [ "eval", "console.log(Deno.readTextFileSync('dist/out.txt'))" ], "output": "artifact\n" } ] }, // A task that depends on another invalidates when the upstream task // re-runs, even if its own inputs are unchanged (dependency cascade). "dependency_cascade_invalidates": { "steps": [ { "args": "task downstream", "output": "Task dep deno run src/dep_in.ts\ndep\nTask downstream deno run src/down_in.ts\ndown\n" }, { "args": "task downstream", "output": "Task dep deno run src/dep_in.ts (cached, inputs unchanged)\nTask downstream deno run src/down_in.ts (cached, inputs unchanged)\n" }, { "args": [ "eval", "Deno.writeTextFileSync('src/dep_in.ts', 'console.log(\"dep2\")')" ], "output": "" }, // `dep` re-runs because its input changed; `downstream` re-runs too, // even though `src/down_in.ts` is untouched, because `dep`'s // fingerprint is part of `downstream`'s cache key. { "args": "task downstream", "output": "Task dep deno run src/dep_in.ts\ndep2\nTask downstream deno run src/down_in.ts\ndown\n" }, { "args": "task downstream", "output": "Task dep deno run src/dep_in.ts (cached, inputs unchanged)\nTask downstream deno run src/down_in.ts (cached, inputs unchanged)\n" } ] } } }