Skip to content

Commit 3faa872

Browse files
claudebranchseer
authored andcommitted
test: add plan tests for --cache/--no-cache override rules and nested scope
Add two new plan snapshot test fixtures: - cache-cli-override: Tests CLI flag overriding rules - --cache enables task/script caching when globally disabled - --cache does not override per-task cache: false - --no-cache disables caching even with per-task cache: true - --cache and --no-cache conflict produces an error - nested-cache-override: Tests scope of nested vp run cache flags - nested --no-cache disables inner task caching - nested --cache enables inner task caching - nested run without flags inherits parent resolved cache - outer --no-cache does not propagate into nested --cache - outer --no-cache propagates to nested run without flags https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah
1 parent 12cea1c commit 3faa872

21 files changed

Lines changed: 1400 additions & 0 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "@test/cache-cli-override",
3+
"scripts": {
4+
"test": "print-file package.json",
5+
"lint": "print-file vite-task.json"
6+
}
7+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Tests --cache and --no-cache CLI flag overriding rules
2+
3+
# Baseline: without flags, tasks are not cached because cache.tasks is false
4+
[[plan]]
5+
name = "baseline - tasks not cached when cache.tasks is false"
6+
args = ["run", "build"]
7+
8+
# --cache enables caching for tasks that don't have explicit cache: false
9+
[[plan]]
10+
name = "--cache enables task caching even when cache.tasks is false"
11+
args = ["run", "--cache", "build"]
12+
13+
# --cache does NOT force-enable tasks with explicit cache: false
14+
[[plan]]
15+
name = "--cache does not override per-task cache false"
16+
args = ["run", "--cache", "deploy"]
17+
18+
# --cache enables script caching even when cache.scripts is not set
19+
[[plan]]
20+
name = "--cache enables script caching"
21+
args = ["run", "--cache", "test"]
22+
23+
# --no-cache disables caching for everything
24+
[[plan]]
25+
name = "--no-cache disables task caching"
26+
args = ["run", "--no-cache", "build"]
27+
28+
# --no-cache overrides per-task cache: true
29+
[[plan]]
30+
name = "--no-cache overrides per-task cache true"
31+
args = ["run", "--no-cache", "check"]
32+
33+
# --cache on task with per-task cache: true (redundant but valid)
34+
[[plan]]
35+
name = "--cache on task with per-task cache true enables caching"
36+
args = ["run", "--cache", "check"]
37+
38+
# --cache and --no-cache conflict
39+
[[plan]]
40+
name = "--cache and --no-cache conflict"
41+
args = ["run", "--cache", "--no-cache", "build"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
3+
expression: err
4+
info:
5+
args:
6+
- run
7+
- "--cache"
8+
- "--no-cache"
9+
- build
10+
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override
11+
---
12+
error: the argument '--cache' cannot be used with '--no-cache'
13+
14+
Usage: vp run --cache <TASK_SPECIFIER> [ADDITIONAL_ARGS]...
15+
16+
For more information, try '--help'.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
3+
expression: "&plan_json"
4+
info:
5+
args:
6+
- run
7+
- "--cache"
8+
- deploy
9+
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override
10+
---
11+
[
12+
{
13+
"key": [
14+
"<workspace>/",
15+
"deploy"
16+
],
17+
"node": {
18+
"task_display": {
19+
"package_name": "@test/cache-cli-override",
20+
"task_name": "deploy",
21+
"package_path": "<workspace>/"
22+
},
23+
"items": [
24+
{
25+
"execution_item_display": {
26+
"task_display": {
27+
"package_name": "@test/cache-cli-override",
28+
"task_name": "deploy",
29+
"package_path": "<workspace>/"
30+
},
31+
"command": "print-file vite-task.json",
32+
"and_item_index": null,
33+
"cwd": "<workspace>/"
34+
},
35+
"kind": {
36+
"Leaf": {
37+
"Spawn": {
38+
"cache_metadata": null,
39+
"spawn_command": {
40+
"program_path": "<tools>/node_modules/.bin/print-file",
41+
"args": [
42+
"vite-task.json"
43+
],
44+
"all_envs": {
45+
"NO_COLOR": "1",
46+
"PATH": "<workspace>/node_modules/.bin:<tools>/node_modules/.bin"
47+
},
48+
"cwd": "<workspace>/"
49+
}
50+
}
51+
}
52+
}
53+
}
54+
]
55+
},
56+
"neighbors": []
57+
}
58+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
3+
expression: "&plan_json"
4+
info:
5+
args:
6+
- run
7+
- "--cache"
8+
- test
9+
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override
10+
---
11+
[
12+
{
13+
"key": [
14+
"<workspace>/",
15+
"test"
16+
],
17+
"node": {
18+
"task_display": {
19+
"package_name": "@test/cache-cli-override",
20+
"task_name": "test",
21+
"package_path": "<workspace>/"
22+
},
23+
"items": [
24+
{
25+
"execution_item_display": {
26+
"task_display": {
27+
"package_name": "@test/cache-cli-override",
28+
"task_name": "test",
29+
"package_path": "<workspace>/"
30+
},
31+
"command": "print-file package.json",
32+
"and_item_index": null,
33+
"cwd": "<workspace>/"
34+
},
35+
"kind": {
36+
"Leaf": {
37+
"Spawn": {
38+
"cache_metadata": {
39+
"spawn_fingerprint": {
40+
"cwd": "",
41+
"program_fingerprint": {
42+
"OutsideWorkspace": {
43+
"program_name": "print-file"
44+
}
45+
},
46+
"args": [
47+
"package.json"
48+
],
49+
"env_fingerprints": {
50+
"fingerprinted_envs": {},
51+
"pass_through_env_config": [
52+
"<default pass-through envs>"
53+
]
54+
},
55+
"fingerprint_ignores": null
56+
},
57+
"execution_cache_key": {
58+
"UserTask": {
59+
"task_name": "test",
60+
"and_item_index": 0,
61+
"extra_args": [],
62+
"package_path": ""
63+
}
64+
}
65+
},
66+
"spawn_command": {
67+
"program_path": "<tools>/node_modules/.bin/print-file",
68+
"args": [
69+
"package.json"
70+
],
71+
"all_envs": {
72+
"NO_COLOR": "1",
73+
"PATH": "<workspace>/node_modules/.bin:<tools>/node_modules/.bin"
74+
},
75+
"cwd": "<workspace>/"
76+
}
77+
}
78+
}
79+
}
80+
}
81+
]
82+
},
83+
"neighbors": []
84+
}
85+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
3+
expression: "&plan_json"
4+
info:
5+
args:
6+
- run
7+
- "--cache"
8+
- build
9+
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override
10+
---
11+
[
12+
{
13+
"key": [
14+
"<workspace>/",
15+
"build"
16+
],
17+
"node": {
18+
"task_display": {
19+
"package_name": "@test/cache-cli-override",
20+
"task_name": "build",
21+
"package_path": "<workspace>/"
22+
},
23+
"items": [
24+
{
25+
"execution_item_display": {
26+
"task_display": {
27+
"package_name": "@test/cache-cli-override",
28+
"task_name": "build",
29+
"package_path": "<workspace>/"
30+
},
31+
"command": "print-file package.json",
32+
"and_item_index": null,
33+
"cwd": "<workspace>/"
34+
},
35+
"kind": {
36+
"Leaf": {
37+
"Spawn": {
38+
"cache_metadata": {
39+
"spawn_fingerprint": {
40+
"cwd": "",
41+
"program_fingerprint": {
42+
"OutsideWorkspace": {
43+
"program_name": "print-file"
44+
}
45+
},
46+
"args": [
47+
"package.json"
48+
],
49+
"env_fingerprints": {
50+
"fingerprinted_envs": {},
51+
"pass_through_env_config": [
52+
"<default pass-through envs>"
53+
]
54+
},
55+
"fingerprint_ignores": null
56+
},
57+
"execution_cache_key": {
58+
"UserTask": {
59+
"task_name": "build",
60+
"and_item_index": 0,
61+
"extra_args": [],
62+
"package_path": ""
63+
}
64+
}
65+
},
66+
"spawn_command": {
67+
"program_path": "<tools>/node_modules/.bin/print-file",
68+
"args": [
69+
"package.json"
70+
],
71+
"all_envs": {
72+
"NO_COLOR": "1",
73+
"PATH": "<workspace>/node_modules/.bin:<tools>/node_modules/.bin"
74+
},
75+
"cwd": "<workspace>/"
76+
}
77+
}
78+
}
79+
}
80+
}
81+
]
82+
},
83+
"neighbors": []
84+
}
85+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
3+
expression: "&plan_json"
4+
info:
5+
args:
6+
- run
7+
- "--cache"
8+
- check
9+
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override
10+
---
11+
[
12+
{
13+
"key": [
14+
"<workspace>/",
15+
"check"
16+
],
17+
"node": {
18+
"task_display": {
19+
"package_name": "@test/cache-cli-override",
20+
"task_name": "check",
21+
"package_path": "<workspace>/"
22+
},
23+
"items": [
24+
{
25+
"execution_item_display": {
26+
"task_display": {
27+
"package_name": "@test/cache-cli-override",
28+
"task_name": "check",
29+
"package_path": "<workspace>/"
30+
},
31+
"command": "print-file package.json",
32+
"and_item_index": null,
33+
"cwd": "<workspace>/"
34+
},
35+
"kind": {
36+
"Leaf": {
37+
"Spawn": {
38+
"cache_metadata": {
39+
"spawn_fingerprint": {
40+
"cwd": "",
41+
"program_fingerprint": {
42+
"OutsideWorkspace": {
43+
"program_name": "print-file"
44+
}
45+
},
46+
"args": [
47+
"package.json"
48+
],
49+
"env_fingerprints": {
50+
"fingerprinted_envs": {},
51+
"pass_through_env_config": [
52+
"<default pass-through envs>"
53+
]
54+
},
55+
"fingerprint_ignores": null
56+
},
57+
"execution_cache_key": {
58+
"UserTask": {
59+
"task_name": "check",
60+
"and_item_index": 0,
61+
"extra_args": [],
62+
"package_path": ""
63+
}
64+
}
65+
},
66+
"spawn_command": {
67+
"program_path": "<tools>/node_modules/.bin/print-file",
68+
"args": [
69+
"package.json"
70+
],
71+
"all_envs": {
72+
"NO_COLOR": "1",
73+
"PATH": "<workspace>/node_modules/.bin:<tools>/node_modules/.bin"
74+
},
75+
"cwd": "<workspace>/"
76+
}
77+
}
78+
}
79+
}
80+
}
81+
]
82+
},
83+
"neighbors": []
84+
}
85+
]

0 commit comments

Comments
 (0)