Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"scripts": {
"script1": "print hello",
"script2": "print hello"
}
}
Original file line number Diff line number Diff line change
@@ -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",
]
Original file line number Diff line number Diff line change
@@ -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, <duration> saved in total

Task Details:
────────────────────────────────────────────────
[1] script2: $ print hello ✓
→ Cache hit - output replayed - <duration> 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
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Empty JS file for oxlint
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Empty JS file for oxlint
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -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",
]
Original file line number Diff line number Diff line change
@@ -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 <duration> on 1 file with 90 rules using <n> 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 <duration> on 1 file with 90 rules using <n> 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 <duration> on 1 file with 90 rules using <n> 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 <duration> on 1 file with 90 rules using <n> threads.
Original file line number Diff line number Diff line change
@@ -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",
]
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"task": "print foo && print bar"
}
}
Original file line number Diff line number Diff line change
@@ -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",
]
Original file line number Diff line number Diff line change
@@ -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, <duration> saved in total

Task Details:
────────────────────────────────────────────────
[1] task: $ print baz ✓
→ Cache miss: args changed
·······················································
[2] task: $ print bar ✓
→ Cache hit - output replayed - <duration> 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, <duration> saved in total

Task Details:
────────────────────────────────────────────────
[1] task: $ print bar ✓
→ Cache hit - output replayed - <duration> saved
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Loading