diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/associate-existing-cache/package.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/associate-existing-cache/package.json new file mode 100644 index 00000000..ab3f4d17 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/associate-existing-cache/package.json @@ -0,0 +1,6 @@ +{ + "scripts": { + "script1": "print hello", + "script2": "print hello" + } +} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/associate-existing-cache/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/associate-existing-cache/snapshots.toml new file mode 100644 index 00000000..43e7d26d --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/associate-existing-cache/snapshots.toml @@ -0,0 +1,10 @@ +# Tests that tasks with identical commands share cache + +[[e2e]] +name = "associate existing cache" +steps = [ + "vite run script1 # cache miss", + "vite run script2 # cache hit, same command as script1", + "json-edit package.json '_.scripts.script2 = \"print world\"' # change script2", + "vite run script2 # cache miss", +] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/associate-existing-cache/snapshots/associate existing cache.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/associate-existing-cache/snapshots/associate existing cache.snap new file mode 100644 index 00000000..57a2f9b1 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/associate-existing-cache/snapshots/associate existing cache.snap @@ -0,0 +1,61 @@ +--- +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 +expression: e2e_outputs +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/associate-existing-cache +--- +> vite run script1 # cache miss +$ print hello +hello + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 0 cache hits • 1 cache misses +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] script1: $ print hello ✓ + → Cache miss: no previous cache entry found +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> vite run script2 # cache hit, same command as script1 +$ print hello ✓ cache hit, replaying +hello + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 1 cache hits • 0 cache misses +Performance: 100% cache hit rate, saved in total + +Task Details: +──────────────────────────────────────────────── + [1] script2: $ print hello ✓ + → Cache hit - output replayed - saved +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> json-edit package.json '_.scripts.script2 = "print world"' # change script2 + +> vite run script2 # cache miss +$ print world ✗ cache miss: args changed, executing +world + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 0 cache hits • 1 cache misses +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] script2: $ print world ✓ + → Cache miss: args changed +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/folder1/a.js b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/folder1/a.js new file mode 100644 index 00000000..dddcb9f2 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/folder1/a.js @@ -0,0 +1 @@ +// Empty JS file for oxlint diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/folder2/a.js b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/folder2/a.js new file mode 100644 index 00000000..dddcb9f2 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/folder2/a.js @@ -0,0 +1 @@ +// Empty JS file for oxlint diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/package.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/package.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/package.json @@ -0,0 +1 @@ +{} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/snapshots.toml new file mode 100644 index 00000000..b92b3f66 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/snapshots.toml @@ -0,0 +1,11 @@ +# Tests that builtin commands have separate cache per cwd + +[[e2e]] +name = "builtin different cwd" +steps = [ + "cd folder1 && vite lint # cache miss in folder1", + "cd folder2 && vite lint # cache miss in folder2", + "echo 'console.log(1);' > folder2/a.js # modify folder2", + "cd folder1 && vite lint # cache hit", + "cd folder2 && vite lint # cache miss", +] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/snapshots/builtin different cwd.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/snapshots/builtin different cwd.snap new file mode 100644 index 00000000..a049bf4b --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/snapshots/builtin different cwd.snap @@ -0,0 +1,52 @@ +--- +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 +expression: e2e_outputs +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd +--- +> cd folder1 && vite lint # cache miss in folder1 + + ! eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. + ,-[a.js:1:1] + 1 | // Empty JS file for oxlint + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + help: Delete this file or add some code to it. + +Found 1 warning and 0 errors. +Finished in on 1 file with 90 rules using threads. + + +> cd folder2 && vite lint # cache miss in folder2 + + ! eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. + ,-[a.js:1:1] + 1 | // Empty JS file for oxlint + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + help: Delete this file or add some code to it. + +Found 1 warning and 0 errors. +Finished in on 1 file with 90 rules using threads. + + +> echo 'console.log(1);' > folder2/a.js # modify folder2 + +> cd folder1 && vite lint # cache hit +✓ cache hit, replaying + + ! eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. + ,-[a.js:1:1] + 1 | // Empty JS file for oxlint + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + help: Delete this file or add some code to it. + +Found 1 warning and 0 errors. +Finished in on 1 file with 90 rules using threads. + + +> cd folder2 && vite lint # cache miss +✗ cache miss: content of input 'folder2/a.js' changed, executing +Found 0 warnings and 0 errors. +Finished in on 1 file with 90 rules using threads. diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots.toml index b7eb50a3..245063b6 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots.toml +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots.toml @@ -1,13 +1,15 @@ +# Tests that cache: false in task config disables caching + [[e2e]] name = "task with cache disabled" steps = [ - "vite run no-cache-task", - "vite run no-cache-task", + "vite run no-cache-task # cache miss", + "vite run no-cache-task # cache disabled, runs again", ] [[e2e]] name = "task with cache enabled" steps = [ - "vite run cached-task", - "vite run cached-task", + "vite run cached-task # cache miss", + "vite run cached-task # cache hit", ] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots/task with cache disabled.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots/task with cache disabled.snap index faf73395..393064a3 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots/task with cache disabled.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots/task with cache disabled.snap @@ -1,9 +1,10 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-disabled +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled --- -> vite run no-cache-task +> vite run no-cache-task # cache miss $ print-file test.txt ⊘ cache disabled: no cache config test content @@ -21,7 +22,7 @@ Task Details: → Cache disabled in task configuration ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -> vite run no-cache-task +> vite run no-cache-task # cache disabled, runs again $ print-file test.txt ⊘ cache disabled: no cache config test content diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots/task with cache enabled.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots/task with cache enabled.snap index a89dfa2a..bc1bd572 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots/task with cache enabled.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots/task with cache enabled.snap @@ -1,9 +1,10 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-disabled +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled --- -> vite run cached-task +> vite run cached-task # cache miss $ print-file test.txt test content @@ -21,7 +22,7 @@ Task Details: → Cache miss: no previous cache entry found ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -> vite run cached-task +> vite run cached-task # cache hit $ print-file test.txt ✓ cache hit, replaying test content diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-command-change/package.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-command-change/package.json new file mode 100644 index 00000000..73a11332 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-command-change/package.json @@ -0,0 +1,5 @@ +{ + "scripts": { + "task": "print foo && print bar" + } +} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-command-change/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-command-change/snapshots.toml new file mode 100644 index 00000000..048da0cb --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-command-change/snapshots.toml @@ -0,0 +1,11 @@ +# Tests cache behavior when command changes partially + +[[e2e]] +name = "cache miss command change" +steps = [ + "vite run task # cache miss", + "json-edit package.json '_.scripts.task = \"print baz && print bar\"' # change first subtask", + "vite run task # first: cache miss, second: cache hit", + "json-edit package.json '_.scripts.task = \"print bar\"' # remove first subtask", + "vite run task # cache hit", +] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-command-change/snapshots/cache miss command change.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-command-change/snapshots/cache miss command change.snap new file mode 100644 index 00000000..ced2ee4b --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-command-change/snapshots/cache miss command change.snap @@ -0,0 +1,75 @@ +--- +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 +expression: e2e_outputs +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-command-change +--- +> vite run task # cache miss +$ print foo +foo + +$ print bar +bar + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 2 tasks • 0 cache hits • 2 cache misses +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] task: $ print foo ✓ + → Cache miss: no previous cache entry found + ······················································· + [2] task: $ print bar ✓ + → Cache miss: no previous cache entry found +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> json-edit package.json '_.scripts.task = "print baz && print bar"' # change first subtask + +> vite run task # first: cache miss, second: cache hit +$ print baz ✗ cache miss: args changed, executing +baz + +$ print bar ✓ cache hit, replaying +bar + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 2 tasks • 1 cache hits • 1 cache misses +Performance: 50% cache hit rate, saved in total + +Task Details: +──────────────────────────────────────────────── + [1] task: $ print baz ✓ + → Cache miss: args changed + ······················································· + [2] task: $ print bar ✓ + → Cache hit - output replayed - saved +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> json-edit package.json '_.scripts.task = "print bar"' # remove first subtask + +> vite run task # cache hit +$ print bar ✓ cache hit, replaying +bar + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 1 cache hits • 0 cache misses +Performance: 100% cache hit rate, saved in total + +Task Details: +──────────────────────────────────────────────── + [1] task: $ print bar ✓ + → Cache hit - output replayed - saved +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots.toml index 7c325dc9..1a2e321a 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots.toml +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots.toml @@ -3,71 +3,55 @@ [[e2e]] name = "env value changed" steps = [ - # Initial run - "cross-env MY_ENV=1 vite run test", - # Cache miss: env value changed - "cross-env MY_ENV=2 vite run test", + "cross-env MY_ENV=1 vite run test # cache miss", + "cross-env MY_ENV=2 vite run test # cache miss: env value changed", ] [[e2e]] name = "env added" steps = [ - # Initial run without env - "vite run test", - # Cache miss: env added - "cross-env MY_ENV=1 vite run test", + "vite run test # cache miss", + "cross-env MY_ENV=1 vite run test # cache miss: env added", ] [[e2e]] name = "env removed" steps = [ - # Initial run with env - "cross-env MY_ENV=1 vite run test", - # Cache miss: env removed - "vite run test", + "cross-env MY_ENV=1 vite run test # cache miss", + "vite run test # cache miss: env removed", ] [[e2e]] name = "pass-through env added" steps = [ - "vite run test", - # Add pass-through env - "json-edit vite.config.json \"_.tasks.test.passThroughEnvs = ['MY_PASSTHROUGH']\"", - # Cache miss: pass-through env added - "vite run test", + "vite run test # cache miss", + "json-edit vite.config.json \"_.tasks.test.passThroughEnvs = ['MY_PASSTHROUGH']\" # add pass-through env", + "vite run test # cache miss: pass-through env added", ] [[e2e]] name = "pass-through env removed" steps = [ - # Setup: task with pass-through env - "json-edit vite.config.json \"_.tasks.test.passThroughEnvs = ['MY_PASSTHROUGH']\"", - "vite run test", - # Remove pass-through env - "json-edit vite.config.json \"delete _.tasks.test.passThroughEnvs\"", - # Cache miss: pass-through env removed - "vite run test", + "json-edit vite.config.json \"_.tasks.test.passThroughEnvs = ['MY_PASSTHROUGH']\" # setup", + "vite run test # cache miss", + "json-edit vite.config.json \"delete _.tasks.test.passThroughEnvs\" # remove pass-through env", + "vite run test # cache miss: pass-through env removed", ] [[e2e]] name = "cwd changed" steps = [ - "vite run test", - # Create subfolder and copy test.txt there + "vite run test # cache miss", "mkdir -p subfolder", "cp test.txt subfolder/test.txt", - # Change cwd to subfolder - "json-edit vite.config.json \"_.tasks.test.cwd = 'subfolder'\"", - # Cache miss: working directory changed - "vite run test", + "json-edit vite.config.json \"_.tasks.test.cwd = 'subfolder'\" # change cwd", + "vite run test # cache miss: cwd changed", ] [[e2e]] name = "input content changed" steps = [ - "vite run test", - # Modify input file - "replace-file-content test.txt initial modified", - # Cache miss: input content changed - "vite run test", + "vite run test # cache miss", + "replace-file-content test.txt initial modified # modify input", + "vite run test # cache miss: input changed", ] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/cwd changed.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/cwd changed.snap index 9fe41194..fe831b27 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/cwd changed.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/cwd changed.snap @@ -1,9 +1,10 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-miss-reasons +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons --- -> vite run test +> vite run test # cache miss $ print-file test.txt initial content @@ -25,9 +26,9 @@ Task Details: > cp test.txt subfolder/test.txt -> json-edit vite.config.json "_.tasks.test.cwd = 'subfolder'" +> json-edit vite.config.json "_.tasks.test.cwd = 'subfolder'" # change cwd -> vite run test +> vite run test # cache miss: cwd changed ~/subfolder$ print-file test.txt ✗ cache miss: working directory changed, executing initial content diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/env added.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/env added.snap index 9c53f533..353df5f3 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/env added.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/env added.snap @@ -1,9 +1,10 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-miss-reasons +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons --- -> vite run test +> vite run test # cache miss $ print-file test.txt initial content @@ -21,7 +22,7 @@ Task Details: → Cache miss: no previous cache entry found ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -> cross-env MY_ENV=1 vite run test +> cross-env MY_ENV=1 vite run test # cache miss: env added $ print-file test.txt ✗ cache miss: envs changed, executing initial content diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/env removed.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/env removed.snap index 3dfaaa5a..991d5f49 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/env removed.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/env removed.snap @@ -1,9 +1,10 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-miss-reasons +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons --- -> cross-env MY_ENV=1 vite run test +> cross-env MY_ENV=1 vite run test # cache miss $ print-file test.txt initial content @@ -21,7 +22,7 @@ Task Details: → Cache miss: no previous cache entry found ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -> vite run test +> vite run test # cache miss: env removed $ print-file test.txt ✗ cache miss: envs changed, executing initial content diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/env value changed.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/env value changed.snap index 72b0cc8b..af8288a6 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/env value changed.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/env value changed.snap @@ -1,9 +1,10 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-miss-reasons +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons --- -> cross-env MY_ENV=1 vite run test +> cross-env MY_ENV=1 vite run test # cache miss $ print-file test.txt initial content @@ -21,7 +22,7 @@ Task Details: → Cache miss: no previous cache entry found ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -> cross-env MY_ENV=2 vite run test +> cross-env MY_ENV=2 vite run test # cache miss: env value changed $ print-file test.txt ✗ cache miss: envs changed, executing initial content diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/input content changed.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/input content changed.snap index 3008fc14..0bdc5517 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/input content changed.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/input content changed.snap @@ -1,9 +1,10 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-miss-reasons +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons --- -> vite run test +> vite run test # cache miss $ print-file test.txt initial content @@ -21,9 +22,9 @@ Task Details: → Cache miss: no previous cache entry found ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -> replace-file-content test.txt initial modified +> replace-file-content test.txt initial modified # modify input -> vite run test +> vite run test # cache miss: input changed $ print-file test.txt ✗ cache miss: content of input 'test.txt' changed, executing modified content diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/pass-through env added.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/pass-through env added.snap index c491c4e8..805fc64c 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/pass-through env added.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/pass-through env added.snap @@ -1,9 +1,10 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-miss-reasons +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons --- -> vite run test +> vite run test # cache miss $ print-file test.txt initial content @@ -21,9 +22,9 @@ Task Details: → Cache miss: no previous cache entry found ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -> json-edit vite.config.json "_.tasks.test.passThroughEnvs = ['MY_PASSTHROUGH']" +> json-edit vite.config.json "_.tasks.test.passThroughEnvs = ['MY_PASSTHROUGH']" # add pass-through env -> vite run test +> vite run test # cache miss: pass-through env added $ print-file test.txt ✗ cache miss: pass-through env config changed, executing initial content diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/pass-through env removed.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/pass-through env removed.snap index dd278721..b5b4596f 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/pass-through env removed.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/pass-through env removed.snap @@ -1,11 +1,12 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-miss-reasons +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons --- -> json-edit vite.config.json "_.tasks.test.passThroughEnvs = ['MY_PASSTHROUGH']" +> json-edit vite.config.json "_.tasks.test.passThroughEnvs = ['MY_PASSTHROUGH']" # setup -> vite run test +> vite run test # cache miss $ print-file test.txt initial content @@ -23,9 +24,9 @@ Task Details: → Cache miss: no previous cache entry found ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -> json-edit vite.config.json "delete _.tasks.test.passThroughEnvs" +> json-edit vite.config.json "delete _.tasks.test.passThroughEnvs" # remove pass-through env -> vite run test +> vite run test # cache miss: pass-through env removed $ print-file test.txt ✗ cache miss: pass-through env config changed, executing initial content diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/package.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/package.json new file mode 100644 index 00000000..fde0ba16 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/package.json @@ -0,0 +1,5 @@ +{ + "scripts": { + "read_colon_in_name": "node read_node_fs.js" + } +} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/read_node_fs.js b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/read_node_fs.js new file mode 100644 index 00000000..8184bed3 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/read_node_fs.js @@ -0,0 +1,3 @@ +try { + require('node:fs').readFileSync('node:fs'); +} catch {} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/snapshots.toml new file mode 100644 index 00000000..a229bf3f --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/snapshots.toml @@ -0,0 +1,8 @@ +# Tests that fs.read('node:fs') with colon in filename works correctly + +[[e2e]] +name = "read file with colon in name" +steps = [ + "vite run read_colon_in_name # cache miss", + "vite run read_colon_in_name # cache hit", +] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/snapshots/read file with colon in name.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/snapshots/read file with colon in name.snap new file mode 100644 index 00000000..862bfd25 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name/snapshots/read file with colon in name.snap @@ -0,0 +1,39 @@ +--- +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 +expression: e2e_outputs +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/colon-in-name +--- +> vite run read_colon_in_name # cache miss +$ node read_node_fs.js + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 0 cache hits • 1 cache misses +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] read_colon_in_name: $ node read_node_fs.js ✓ + → Cache miss: no previous cache entry found +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> vite run read_colon_in_name # cache hit +$ node read_node_fs.js ✓ cache hit, replaying + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 1 cache hits • 0 cache misses +Performance: 100% cache hit rate, saved in total + +Task Details: +──────────────────────────────────────────────── + [1] read_colon_in_name: $ node read_node_fs.js ✓ + → Cache hit - output replayed - saved +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots.toml index d711d565..94a6dfdf 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots.toml +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots.toml @@ -1,12 +1,14 @@ +# Tests env-test synthetic command + [[e2e]] name = "env-test prints value from additional_envs" steps = [ - "vite env-test SYNTHETIC_ENV_VAR test_value_from_synthesizer", + "vite env-test SYNTHETIC_ENV_VAR test_value_from_synthesizer # prints env value", ] [[e2e]] name = "env-test with different values" steps = [ - "vite env-test FOO bar", - "vite env-test BAZ qux", + "vite env-test FOO bar # sets FOO=bar", + "vite env-test BAZ qux # sets BAZ=qux", ] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test prints value from additional_envs.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test prints value from additional_envs.snap index 267e8e6d..caf589c6 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test prints value from additional_envs.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test prints value from additional_envs.snap @@ -1,8 +1,8 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs -assertion_line: 152 +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/e2e-env-test +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test --- -> vite env-test SYNTHETIC_ENV_VAR test_value_from_synthesizer +> vite env-test SYNTHETIC_ENV_VAR test_value_from_synthesizer # prints env value test_value_from_synthesizer diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test with different values.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test with different values.snap index 2b651adb..375b1f1f 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test with different values.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test with different values.snap @@ -1,12 +1,12 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs -assertion_line: 152 +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/e2e-env-test +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test --- -> vite env-test FOO bar +> vite env-test FOO bar # sets FOO=bar bar -> vite env-test BAZ qux +> vite env-test BAZ qux # sets BAZ=qux qux diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-lint-cache/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-lint-cache/snapshots.toml index 653e74b1..1ad17a2d 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-lint-cache/snapshots.toml +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-lint-cache/snapshots.toml @@ -1,7 +1,9 @@ +# Tests lint caching with file changes + [[e2e]] name = "direct lint" steps = [ - "vite lint", - "echo debugger > main.js", - "vite lint", + "vite lint # cache miss", + "echo debugger > main.js # add lint error", + "vite lint # cache miss, lint fails", ] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-lint-cache/snapshots/direct lint.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-lint-cache/snapshots/direct lint.snap index 6fd04a41..74f9c786 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-lint-cache/snapshots/direct lint.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-lint-cache/snapshots/direct lint.snap @@ -1,17 +1,17 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs -assertion_line: 152 +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/e2e-lint-cache +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-lint-cache --- -> vite lint +> vite lint # cache miss Found 0 warnings and 0 errors. Finished in on 0 files with 90 rules using threads. -> echo debugger > main.js +> echo debugger > main.js # add lint error -> vite lint +> vite lint # cache miss, lint fails ✗ cache miss: content of input '' changed, executing ! eslint(no-debugger): `debugger` statement is not allowed diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/error_cycle_dependency/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/error_cycle_dependency/snapshots.toml index 6cee5513..cc0778b3 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/error_cycle_dependency/snapshots.toml +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/error_cycle_dependency/snapshots.toml @@ -1,5 +1,7 @@ +# Tests error message for cyclic task dependencies + [[e2e]] name = "cycle dependency error" steps = [ - "vite run task-a", + "vite run task-a # task-a -> task-b -> task-a cycle", ] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/error_cycle_dependency/snapshots/cycle dependency error.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/error_cycle_dependency/snapshots/cycle dependency error.snap index fc95a358..5b49aab8 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/error_cycle_dependency/snapshots/cycle dependency error.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/error_cycle_dependency/snapshots/cycle dependency error.snap @@ -1,10 +1,10 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/error_cycle_dependency +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/error_cycle_dependency --- -[1]> vite run task-a +[1]> vite run task-a # task-a -> task-b -> task-a cycle ⊘ cache disabled: cycle detected ✗ Cycle dependencies detected: Cycle(NodeIndex(ExecutionIx(1))) diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes/snapshots.toml index aa7b2bb1..2c124b69 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes/snapshots.toml +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes/snapshots.toml @@ -1,11 +1,13 @@ +# Tests exit code behavior for task failures + [[e2e]] name = "single task failure returns task exit code" steps = [ - "vite run pkg-a#fail", + "vite run pkg-a#fail # exits with code 42", ] [[e2e]] name = "multiple task failures returns exit code 1" steps = [ - "vite run -r fail", + "vite run -r fail # multiple failures -> exit code 1", ] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes/snapshots/multiple task failures returns exit code 1.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes/snapshots/multiple task failures returns exit code 1.snap index 8f95da73..27126371 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes/snapshots/multiple task failures returns exit code 1.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes/snapshots/multiple task failures returns exit code 1.snap @@ -1,9 +1,10 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/exit-codes +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes --- -[1]> vite run -r fail +[1]> vite run -r fail # multiple failures -> exit code 1 ~/packages/pkg-b$ node -e "process.exit(7)" ~/packages/pkg-a$ node -e "process.exit(42)" diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes/snapshots/single task failure returns task exit code.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes/snapshots/single task failure returns task exit code.snap index a068a2c7..97dde56a 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes/snapshots/single task failure returns task exit code.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes/snapshots/single task failure returns task exit code.snap @@ -1,9 +1,10 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/exit-codes +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/exit-codes --- -[42]> vite run pkg-a#fail +[42]> vite run pkg-a#fail # exits with code 42 ~/packages/pkg-a$ node -e "process.exit(42)" diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-adt-args/package.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-adt-args/package.json new file mode 100644 index 00000000..9df11742 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-adt-args/package.json @@ -0,0 +1,5 @@ +{ + "scripts": { + "say": "print" + } +} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-adt-args/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-adt-args/snapshots.toml new file mode 100644 index 00000000..f67ee553 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-adt-args/snapshots.toml @@ -0,0 +1,10 @@ +# Tests that different extra args get separate cache entries + +[[e2e]] +name = "individual cache for extra args" +steps = [ + "vite run say a # cache miss", + "vite run say b # cache miss, different args", + "vite run say a # cache hit", + "vite run say b # cache hit", +] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-adt-args/snapshots/individual cache for extra args.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-adt-args/snapshots/individual cache for extra args.snap new file mode 100644 index 00000000..6d2bda66 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-adt-args/snapshots/individual cache for extra args.snap @@ -0,0 +1,77 @@ +--- +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 +expression: e2e_outputs +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-adt-args +--- +> vite run say a # cache miss +$ print a +a + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 0 cache hits • 1 cache misses +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] say: $ print a ✓ + → Cache miss: no previous cache entry found +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> vite run say b # cache miss, different args +$ print b +b + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 0 cache hits • 1 cache misses +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] say: $ print b ✓ + → Cache miss: no previous cache entry found +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> vite run say a # cache hit +$ print a ✓ cache hit, replaying +a + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 1 cache hits • 0 cache misses +Performance: 100% cache hit rate, saved in total + +Task Details: +──────────────────────────────────────────────── + [1] say: $ print a ✓ + → Cache hit - output replayed - saved +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> vite run say b # cache hit +$ print b ✓ cache hit, replaying +b + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 1 cache hits • 0 cache misses +Performance: 100% cache hit rate, saved in total + +Task Details: +──────────────────────────────────────────────── + [1] say: $ print b ✓ + → Cache hit - output replayed - saved +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-envs/package.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-envs/package.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-envs/package.json @@ -0,0 +1 @@ +{} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-envs/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-envs/snapshots.toml new file mode 100644 index 00000000..9f37ef97 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-envs/snapshots.toml @@ -0,0 +1,10 @@ +# Tests that different env values get separate cache entries + +[[e2e]] +name = "individual cache for envs" +steps = [ + "FOO=1 vite run hello # cache miss", + "FOO=2 vite run hello # cache miss, different env", + "FOO=1 vite run hello # cache hit", + "FOO=2 vite run hello # cache hit", +] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-envs/snapshots/individual cache for envs.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-envs/snapshots/individual cache for envs.snap new file mode 100644 index 00000000..e4b1dab9 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-envs/snapshots/individual cache for envs.snap @@ -0,0 +1,77 @@ +--- +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 +expression: e2e_outputs +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-envs +--- +> FOO=1 vite run hello # cache miss +$ print-env FOO +1 + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 0 cache hits • 1 cache misses +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] hello: $ print-env FOO ✓ + → Cache miss: no previous cache entry found +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> FOO=2 vite run hello # cache miss, different env +$ print-env FOO ✗ cache miss: envs changed, executing +2 + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 0 cache hits • 1 cache misses +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] hello: $ print-env FOO ✓ + → Cache miss: env FOO value changed from '1' to '2' +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> FOO=1 vite run hello # cache hit +$ print-env FOO ✓ cache hit, replaying +1 + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 1 cache hits • 0 cache misses +Performance: 100% cache hit rate, saved in total + +Task Details: +──────────────────────────────────────────────── + [1] hello: $ print-env FOO ✓ + → Cache hit - output replayed - saved +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> FOO=2 vite run hello # cache hit +$ print-env FOO ✓ cache hit, replaying +2 + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 1 cache hits • 0 cache misses +Performance: 100% cache hit rate, saved in total + +Task Details: +──────────────────────────────────────────────── + [1] hello: $ print-env FOO ✓ + → Cache hit - output replayed - saved +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-envs/vite.config.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-envs/vite.config.json new file mode 100644 index 00000000..8ef0caca --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/individual-cache-for-envs/vite.config.json @@ -0,0 +1,9 @@ +{ + "tasks": { + "hello": { + "command": "print-env FOO", + "envs": ["FOO"], + "cache": true + } + } +} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/lint-dot-git/a.js b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/lint-dot-git/a.js new file mode 100644 index 00000000..dddcb9f2 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/lint-dot-git/a.js @@ -0,0 +1 @@ +// Empty JS file for oxlint diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/lint-dot-git/package.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/lint-dot-git/package.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/lint-dot-git/package.json @@ -0,0 +1 @@ +{} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/lint-dot-git/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/lint-dot-git/snapshots.toml new file mode 100644 index 00000000..134dc2e5 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/lint-dot-git/snapshots.toml @@ -0,0 +1,10 @@ +# Tests that .git directory is ignored by lint + +[[e2e]] +name = "lint dot git" +steps = [ + "mkdir .git", + "vite lint # cache miss", + "echo hello > .git/foo.txt # add file inside .git", + "vite lint # cache hit, .git is ignored", +] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/lint-dot-git/snapshots/lint dot git.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/lint-dot-git/snapshots/lint dot git.snap new file mode 100644 index 00000000..e3b0d98d --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/lint-dot-git/snapshots/lint dot git.snap @@ -0,0 +1,35 @@ +--- +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 +expression: e2e_outputs +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/lint-dot-git +--- +> mkdir .git + +> vite lint # cache miss + + ! eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. + ,-[a.js:1:1] + 1 | // Empty JS file for oxlint + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + help: Delete this file or add some code to it. + +Found 1 warning and 0 errors. +Finished in on 1 file with 90 rules using threads. + + +> echo hello > .git/foo.txt # add file inside .git + +> vite lint # cache hit, .git is ignored +✓ cache hit, replaying + + ! eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. + ,-[a.js:1:1] + 1 | // Empty JS file for oxlint + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + help: Delete this file or add some code to it. + +Found 1 warning and 0 errors. +Finished in on 1 file with 90 rules using threads. diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/build.js b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/build.js new file mode 100644 index 00000000..53493e04 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/build.js @@ -0,0 +1,97 @@ +import { spawn } from 'node:child_process'; +import { scheduler } from 'node:timers/promises'; + +async function main() { + const commands = [ + ['node', ['echo.js', '1'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '2'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '3'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '4'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '5'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '6'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '7'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '8'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '9'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '10'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '11'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '12'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '13'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '14'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '15'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '16'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '17'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '18'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '19'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '20'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '21'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '22'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '23'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '24'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '25'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '26'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '27'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '28'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '29'.repeat(100)], { stdio: 'inherit' }], + ['node', ['echo.js', '30'.repeat(100)], { stdio: 'inherit' }], + ]; + + console.log('[build.js] --------------------------------'); + console.log('[build.js] start'); + + for (const command of commands) { + await exec(...command); + } + + // Wait for 100ms to ensure all child process output streams are fully flushed + await scheduler.wait(100); + console.log('[build.js] main process end'); +} + +main().catch(console.error); + +/** + * @param {string} command + * @param {ReadonlyArray} args + * @param {object} [options] + */ +export async function exec(command, args, options) { + return new Promise((resolve, reject) => { + const _process = spawn(command, args, { + stdio: [ + 'ignore', // stdin + 'pipe', // stdout + 'pipe', // stderr + ], + ...options, + shell: process.platform === 'win32', + }); + + const stderrChunks = []; + const stdoutChunks = []; + + _process.stderr?.on('data', (chunk) => { + stderrChunks.push(chunk); + }); + + _process.stdout?.on('data', (chunk) => { + stdoutChunks.push(chunk); + }); + + _process.on('error', (error) => { + reject(error); + }); + + _process.on('exit', (code) => { + const ok = code === 0; + const stderr = Buffer.concat(stderrChunks).toString().trim(); + const stdout = Buffer.concat(stdoutChunks).toString().trim(); + + if (ok) { + const result = { ok, code, stderr, stdout }; + resolve(result); + } else { + reject(new Error(`Failed to execute command: ${command} ${args.join(' ')}: ${stderr}`)); + } + }); + }); +} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/echo.js b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/echo.js new file mode 100644 index 00000000..7ad9d54b --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/echo.js @@ -0,0 +1,4 @@ +const args = process.argv.slice(2); +console.warn('[echo.js] --------------------------------'); +console.warn('[echo.js] ' + args.join(' ')); +console.warn('[echo.js] --------------------------------'); diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/package.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/package.json new file mode 100644 index 00000000..e670719a --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/package.json @@ -0,0 +1,6 @@ +{ + "type": "module", + "scripts": { + "build": "node build.js" + } +} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/snapshots.toml new file mode 100644 index 00000000..99614af9 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/snapshots.toml @@ -0,0 +1,9 @@ +# Tests that replayed logs maintain chronological order + +[[e2e]] +name = "replay logs chronological order" +steps = [ + "vite run build # cache miss", + "vite run build # cache hit", + "vite run build # cache hit", +] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/snapshots/replay logs chronological order.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/snapshots/replay logs chronological order.snap new file mode 100644 index 00000000..799bc7c5 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order/snapshots/replay logs chronological order.snap @@ -0,0 +1,335 @@ +--- +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 +expression: e2e_outputs +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/replay-logs-chronological-order +--- +> vite run build # cache miss +$ node build.js +[build.js] -------------------------------- +[build.js] start +[echo.js] -------------------------------- +[echo.js] 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 5555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 6666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 13131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 14141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 15151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 16161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 17171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 18181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 19191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 23232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 24242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 25252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 26262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 27272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 28282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 29292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 30303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030 +[echo.js] -------------------------------- +[build.js] main process end + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 0 cache hits • 1 cache misses +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] build: $ node build.js ✓ + → Cache miss: no previous cache entry found +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> vite run build # cache hit +$ node build.js ✓ cache hit, replaying +[build.js] -------------------------------- +[build.js] start +[echo.js] -------------------------------- +[echo.js] 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 5555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 6666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 13131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 14141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 15151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 16161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 17171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 18181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 19191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 23232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 24242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 25252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 26262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 27272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 28282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 29292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 30303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030 +[echo.js] -------------------------------- +[build.js] main process end + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 1 cache hits • 0 cache misses +Performance: 100% cache hit rate, saved in total + +Task Details: +──────────────────────────────────────────────── + [1] build: $ node build.js ✓ + → Cache hit - output replayed - saved +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> vite run build # cache hit +$ node build.js ✓ cache hit, replaying +[build.js] -------------------------------- +[build.js] start +[echo.js] -------------------------------- +[echo.js] 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 5555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 6666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 13131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 14141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 15151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 16161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 17171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 18181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818181818 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 19191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 23232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 24242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 25252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 26262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626262626 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 27272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727272727 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 28282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 29292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929292929 +[echo.js] -------------------------------- +[echo.js] -------------------------------- +[echo.js] 30303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030 +[echo.js] -------------------------------- +[build.js] main process end + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 1 cache hits • 0 cache misses +Performance: 100% cache hit rate, saved in total + +Task Details: +──────────────────────────────────────────────── + [1] build: $ node build.js ✓ + → Cache hit - output replayed - saved +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/same-name-as-builtin/a.js b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/same-name-as-builtin/a.js new file mode 100644 index 00000000..dddcb9f2 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/same-name-as-builtin/a.js @@ -0,0 +1 @@ +// Empty JS file for oxlint diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/same-name-as-builtin/package.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/same-name-as-builtin/package.json new file mode 100644 index 00000000..008774dd --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/same-name-as-builtin/package.json @@ -0,0 +1,5 @@ +{ + "scripts": { + "lint": "echo custom lint script" + } +} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/same-name-as-builtin/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/same-name-as-builtin/snapshots.toml new file mode 100644 index 00000000..dc6a58f1 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/same-name-as-builtin/snapshots.toml @@ -0,0 +1,11 @@ +# Tests that user task named "lint" doesn't conflict with builtin lint + +[[e2e]] +name = "same name as builtin" +steps = [ + "vite lint # runs builtin oxlint", + "vite run lint # runs user-defined lint script", + "echo 'console.log(1);' > a.js # add valid JS file", + "vite lint # builtin lint: cache miss", + "vite run lint # user lint: cache miss", +] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/same-name-as-builtin/snapshots/same name as builtin.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/same-name-as-builtin/snapshots/same name as builtin.snap new file mode 100644 index 00000000..fadad306 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/same-name-as-builtin/snapshots/same name as builtin.snap @@ -0,0 +1,62 @@ +--- +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 +expression: e2e_outputs +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/same-name-as-builtin +--- +> vite lint # runs builtin oxlint + + ! eslint-plugin-unicorn(no-empty-file): Empty files are not allowed. + ,-[a.js:1:1] + 1 | // Empty JS file for oxlint + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + help: Delete this file or add some code to it. + +Found 1 warning and 0 errors. +Finished in on 1 file with 90 rules using threads. + + +> vite run lint # runs user-defined lint script +$ echo custom lint script ⊘ cache disabled: built-in command +custom lint script + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 0 cache hits • 0 cache misses • 1 cache disabled +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] lint: $ echo custom lint script ✓ + → Cache disabled for built-in command +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> echo 'console.log(1);' > a.js # add valid JS file + +> vite lint # builtin lint: cache miss +✗ cache miss: content of input 'a.js' changed, executing +Found 0 warnings and 0 errors. +Finished in on 1 file with 90 rules using threads. + + +> vite run lint # user lint: cache miss +$ echo custom lint script ⊘ cache disabled: built-in command +custom lint script + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 0 cache hits • 0 cache misses • 1 cache disabled +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] lint: $ echo custom lint script ✓ + → Cache disabled for built-in command +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/shared-caching-inputs/foo.txt b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/shared-caching-inputs/foo.txt new file mode 100644 index 00000000..f2376e2b --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/shared-caching-inputs/foo.txt @@ -0,0 +1 @@ +initial content diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/shared-caching-inputs/package.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/shared-caching-inputs/package.json new file mode 100644 index 00000000..3ced4721 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/shared-caching-inputs/package.json @@ -0,0 +1,6 @@ +{ + "scripts": { + "script1": "print-file foo.txt", + "script2": "print-file foo.txt" + } +} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/shared-caching-inputs/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/shared-caching-inputs/snapshots.toml new file mode 100644 index 00000000..33fc6cca --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/shared-caching-inputs/snapshots.toml @@ -0,0 +1,11 @@ +# Tests that tasks with identical commands share cache entries + +[[e2e]] +name = "shared caching inputs" +steps = [ + "vite run script1 # cache miss", + "vite run script2 # cache hit, same command as script1", + "replace-file-content foo.txt initial modified # modify shared input", + "vite run script2 # cache miss, input changed", + "vite run script1 # cache hit, script2 already warmed cache", +] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/shared-caching-inputs/snapshots/shared caching inputs.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/shared-caching-inputs/snapshots/shared caching inputs.snap new file mode 100644 index 00000000..6045254e --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/shared-caching-inputs/snapshots/shared caching inputs.snap @@ -0,0 +1,79 @@ +--- +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 +expression: e2e_outputs +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/shared-caching-inputs +--- +> vite run script1 # cache miss +$ print-file foo.txt +initial content + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 0 cache hits • 1 cache misses +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] script1: $ print-file foo.txt ✓ + → Cache miss: no previous cache entry found +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> vite run script2 # cache hit, same command as script1 +$ print-file foo.txt ✓ cache hit, replaying +initial content + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 1 cache hits • 0 cache misses +Performance: 100% cache hit rate, saved in total + +Task Details: +──────────────────────────────────────────────── + [1] script2: $ print-file foo.txt ✓ + → Cache hit - output replayed - saved +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> replace-file-content foo.txt initial modified # modify shared input + +> vite run script2 # cache miss, input changed +$ print-file foo.txt ✗ cache miss: content of input 'foo.txt' changed, executing +modified content + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 0 cache hits • 1 cache misses +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] script2: $ print-file foo.txt ✓ + → Cache miss: content of input 'foo.txt' changed +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +> vite run script1 # cache hit, script2 already warmed cache +$ print-file foo.txt ✓ cache hit, replaying +modified content + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 1 cache hits • 0 cache misses +Performance: 100% cache hit rate, saved in total + +Task Details: +──────────────────────────────────────────────── + [1] script1: $ print-file foo.txt ✓ + → Cache hit - output replayed - saved +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/stdin-passthrough/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/stdin-passthrough/snapshots.toml index abfae9a3..a3e84b79 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/stdin-passthrough/snapshots.toml +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/stdin-passthrough/snapshots.toml @@ -1,3 +1,5 @@ +# Tests that stdin is passed through to tasks + [[e2e]] name = "stdin passthrough to single task" steps = [ diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-no-trailing-newline/package.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-no-trailing-newline/package.json new file mode 100644 index 00000000..3807c88c --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-no-trailing-newline/package.json @@ -0,0 +1,5 @@ +{ + "scripts": { + "hello": "echo -n foo && echo bar" + } +} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-no-trailing-newline/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-no-trailing-newline/snapshots.toml new file mode 100644 index 00000000..f38b4537 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-no-trailing-newline/snapshots.toml @@ -0,0 +1,7 @@ +# Tests output handling when task has no trailing newline + +[[e2e]] +name = "no trailing newline" +steps = [ + "vite run hello # runs echo -n hello", +] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-no-trailing-newline/snapshots/no trailing newline.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-no-trailing-newline/snapshots/no trailing newline.snap new file mode 100644 index 00000000..2679290d --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-no-trailing-newline/snapshots/no trailing newline.snap @@ -0,0 +1,28 @@ +--- +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 +expression: e2e_outputs +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-no-trailing-newline +--- +> vite run hello # runs echo -n hello +$ echo -n foo ⊘ cache disabled: built-in command +foo +$ echo bar ⊘ cache disabled: built-in command +bar + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 2 tasks • 0 cache hits • 0 cache misses • 2 cache disabled +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] hello: $ echo -n foo ✓ + → Cache disabled for built-in command + ······················································· + [2] hello: $ echo bar ✓ + → Cache disabled for built-in command +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/vite-task-smoke/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/vite-task-smoke/snapshots.toml index 94c8d2dc..ee750c39 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/vite-task-smoke/snapshots.toml +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/vite-task-smoke/snapshots.toml @@ -1,7 +1,9 @@ +# Tests cache miss when input file is modified + [[e2e]] name = "cache hit after file modification" steps = [ - "vite run test-task", - "replace-file-content main.js foo bar", - "vite run test-task", + "vite run test-task # cache miss", + "replace-file-content main.js foo bar # modify input file", + "vite run test-task # cache miss, main.js changed", ] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/vite-task-smoke/snapshots/cache hit after file modification.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/vite-task-smoke/snapshots/cache hit after file modification.snap index 9dec4fc7..7a3a6061 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/vite-task-smoke/snapshots/cache hit after file modification.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/vite-task-smoke/snapshots/cache hit after file modification.snap @@ -1,9 +1,10 @@ --- -source: crates/vite_task_bin/tests/test_snapshots/main.rs +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 203 expression: e2e_outputs -input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/vite-task-smoke +input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/vite-task-smoke --- -> vite run test-task +> vite run test-task # cache miss $ echo hello ⊘ cache disabled: built-in command hello @@ -27,9 +28,9 @@ Task Details: → Cache miss: no previous cache entry found ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -> replace-file-content main.js foo bar +> replace-file-content main.js foo bar # modify input file -> vite run test-task +> vite run test-task # cache miss, main.js changed $ echo hello ⊘ cache disabled: built-in command hello diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/additional-envs/snapshots.toml b/crates/vite_task_plan/tests/plan_snapshots/fixtures/additional-envs/snapshots.toml index 1b5b1613..ac268dc8 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/additional-envs/snapshots.toml +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/additional-envs/snapshots.toml @@ -1,3 +1,5 @@ +# Tests env-test synthetic command with additional_envs + [[plan]] name = "direct env-test synthetic task" args = ["env-test", "TEST_VAR", "hello_world"] @@ -5,12 +7,12 @@ args = ["env-test", "TEST_VAR", "hello_world"] [[e2e]] name = "env-test prints value from additional_envs" steps = [ - "vite env-test SYNTHETIC_ENV_VAR test_value_from_synthesizer", + "vite env-test SYNTHETIC_ENV_VAR test_value_from_synthesizer # prints env value", ] [[e2e]] name = "env-test with different values" steps = [ - "vite env-test FOO bar", - "vite env-test BAZ qux", + "vite env-test FOO bar # sets FOO=bar", + "vite env-test BAZ qux # sets BAZ=qux", ] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-keys/snapshots.toml b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-keys/snapshots.toml index 65b5943f..c4e8c96d 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-keys/snapshots.toml +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-keys/snapshots.toml @@ -1,3 +1,5 @@ +# Tests cache key generation for various task configurations + [[plan]] name = "synthetic task in user task" args = ["run", "lint"] @@ -34,7 +36,7 @@ args = ["run", "echo-and-lint", "--fix"] [[e2e]] name = "direct lint" steps = [ - "vite lint", - "echo debugger > main.js", - "vite lint", + "vite lint # cache miss", + "echo debugger > main.js # add lint error", + "vite lint # cache miss, lint fails", ] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/package.json b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/package.json new file mode 100644 index 00000000..c61ceb5f --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/package.json @@ -0,0 +1,6 @@ +{ + "scripts": { + "script1": "echo hello", + "script2": "vite run script1" + } +} diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/snapshots.toml b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/snapshots.toml new file mode 100644 index 00000000..98229c1b --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/snapshots.toml @@ -0,0 +1,5 @@ +# Tests nested vite run resolution + +[[plan]] +name = "nested vite run" +args = ["run", "script2"] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/snapshots/query - nested vite run.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/snapshots/query - nested vite run.snap new file mode 100644 index 00000000..b7635aeb --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/snapshots/query - nested vite run.snap @@ -0,0 +1,86 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +assertion_line: 139 +expression: "&plan_json" +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks +--- +{ + "root_node": { + "Expanded": [ + { + "key": [ + "/", + "script2" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "script2", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "", + "task_name": "script2", + "package_path": "/" + }, + "command": "vite run script1", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Expanded": [ + { + "key": [ + "/", + "script1" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "script1", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "", + "task_name": "script1", + "package_path": "/" + }, + "command": "echo hello", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "InProcess": { + "kind": { + "Echo": { + "strings": [ + "hello" + ], + "trailing_newline": true + } + } + } + } + } + } + ] + }, + "neighbors": [] + } + ] + } + } + ] + }, + "neighbors": [] + } + ] + } +} diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/snapshots/task graph.snap new file mode 100644 index 00000000..43cb206e --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/snapshots/task graph.snap @@ -0,0 +1,64 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +assertion_line: 106 +expression: task_graph_json +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks +--- +[ + { + "key": [ + "/", + "script1" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "script1", + "package_path": "/" + }, + "resolved_config": { + "command": "echo hello", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/", + "script2" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "script2", + "package_path": "/" + }, + "resolved_config": { + "command": "vite run script1", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/shell-fallback/snapshots.toml b/crates/vite_task_plan/tests/plan_snapshots/fixtures/shell-fallback/snapshots.toml index 706f5837..b295df5c 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/shell-fallback/snapshots.toml +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/shell-fallback/snapshots.toml @@ -1,3 +1,5 @@ +# Tests shell fallback for pipe commands + [[plan]] name = "shell fallback for pipe command" args = ["run", "pipe-test"] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-in-subpackage/snapshots.toml b/crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-in-subpackage/snapshots.toml index 786c3fe6..3537f624 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-in-subpackage/snapshots.toml +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-in-subpackage/snapshots.toml @@ -1,3 +1,5 @@ +# Tests synthetic task in subpackage + [[plan]] name = "synthetic-in-subpackage" args = ["run", "lint"] diff --git a/packages/tools/package.json b/packages/tools/package.json index 3e530d79..7e746efe 100644 --- a/packages/tools/package.json +++ b/packages/tools/package.json @@ -3,6 +3,7 @@ "type": "module", "private": true, "bin": { + "print": "./src/print.ts", "print-file": "./src/print-file.ts", "print-env": "./src/print-env.js", "json-edit": "./src/json-edit.ts", diff --git a/packages/tools/src/print.ts b/packages/tools/src/print.ts new file mode 100755 index 00000000..40159157 --- /dev/null +++ b/packages/tools/src/print.ts @@ -0,0 +1,6 @@ +#!/usr/bin/env node + +// Simple tool that prints arguments, like echo +// Used for testing caching behavior since built-in echo is not cached +const args = process.argv.slice(2); +console.log(args.join(' '));