Skip to content

Commit 7586a26

Browse files
committed
add test for cd in scripts
1 parent 1dc0baa commit 7586a26

File tree

6 files changed

+306
-0
lines changed

6 files changed

+306
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"scripts": {
3+
"build": "print-file package.json",
4+
"cd-build": "cd src && vp run build",
5+
"cd-lint": "cd src && vp lint"
6+
}
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Tests that `cd` in scripts interacts correctly with nested vp commands
2+
3+
[[plan]]
4+
name = "cd before vp run should not affect expanded task cwd"
5+
args = ["run", "cd-build"]
6+
7+
[[plan]]
8+
name = "cd before vp lint should put synthetic task under cwd"
9+
args = ["run", "cd-lint"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
3+
expression: "&plan_json"
4+
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cd-in-scripts
5+
---
6+
{
7+
"root_node": {
8+
"Expanded": [
9+
{
10+
"key": [
11+
"<workspace>/",
12+
"cd-lint"
13+
],
14+
"node": {
15+
"task_display": {
16+
"package_name": "",
17+
"task_name": "cd-lint",
18+
"package_path": "<workspace>/"
19+
},
20+
"items": [
21+
{
22+
"execution_item_display": {
23+
"task_display": {
24+
"package_name": "",
25+
"task_name": "cd-lint",
26+
"package_path": "<workspace>/"
27+
},
28+
"command": "vp lint",
29+
"and_item_index": 1,
30+
"cwd": "<workspace>/src"
31+
},
32+
"kind": {
33+
"Leaf": {
34+
"Spawn": {
35+
"cache_metadata": {
36+
"spawn_fingerprint": {
37+
"cwd": "src",
38+
"program_fingerprint": {
39+
"OutsideWorkspace": {
40+
"program_name": "oxlint"
41+
}
42+
},
43+
"args": [],
44+
"env_fingerprints": {
45+
"fingerprinted_envs": {},
46+
"pass_through_env_config": [
47+
"<default pass-through envs>"
48+
]
49+
},
50+
"fingerprint_ignores": null
51+
},
52+
"execution_cache_key": {
53+
"UserTask": {
54+
"task_name": "cd-lint",
55+
"and_item_index": 1,
56+
"extra_args": [],
57+
"package_path": ""
58+
}
59+
}
60+
},
61+
"spawn_command": {
62+
"program_path": "<tools>/node_modules/.bin/oxlint",
63+
"args": [],
64+
"all_envs": {
65+
"NO_COLOR": "1",
66+
"PATH": "<workspace>/node_modules/.bin:<tools>/node_modules/.bin"
67+
},
68+
"cwd": "<workspace>/src"
69+
}
70+
}
71+
}
72+
}
73+
}
74+
]
75+
},
76+
"neighbors": []
77+
}
78+
]
79+
}
80+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
3+
expression: "&plan_json"
4+
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cd-in-scripts
5+
---
6+
{
7+
"root_node": {
8+
"Expanded": [
9+
{
10+
"key": [
11+
"<workspace>/",
12+
"cd-build"
13+
],
14+
"node": {
15+
"task_display": {
16+
"package_name": "",
17+
"task_name": "cd-build",
18+
"package_path": "<workspace>/"
19+
},
20+
"items": [
21+
{
22+
"execution_item_display": {
23+
"task_display": {
24+
"package_name": "",
25+
"task_name": "cd-build",
26+
"package_path": "<workspace>/"
27+
},
28+
"command": "vp run build",
29+
"and_item_index": 1,
30+
"cwd": "<workspace>/src"
31+
},
32+
"kind": {
33+
"Expanded": [
34+
{
35+
"key": [
36+
"<workspace>/",
37+
"build"
38+
],
39+
"node": {
40+
"task_display": {
41+
"package_name": "",
42+
"task_name": "build",
43+
"package_path": "<workspace>/"
44+
},
45+
"items": [
46+
{
47+
"execution_item_display": {
48+
"task_display": {
49+
"package_name": "",
50+
"task_name": "build",
51+
"package_path": "<workspace>/"
52+
},
53+
"command": "print-file package.json",
54+
"and_item_index": null,
55+
"cwd": "<workspace>/"
56+
},
57+
"kind": {
58+
"Leaf": {
59+
"Spawn": {
60+
"cache_metadata": {
61+
"spawn_fingerprint": {
62+
"cwd": "",
63+
"program_fingerprint": {
64+
"OutsideWorkspace": {
65+
"program_name": "print-file"
66+
}
67+
},
68+
"args": [
69+
"package.json"
70+
],
71+
"env_fingerprints": {
72+
"fingerprinted_envs": {},
73+
"pass_through_env_config": [
74+
"<default pass-through envs>"
75+
]
76+
},
77+
"fingerprint_ignores": null
78+
},
79+
"execution_cache_key": {
80+
"UserTask": {
81+
"task_name": "build",
82+
"and_item_index": 0,
83+
"extra_args": [],
84+
"package_path": ""
85+
}
86+
}
87+
},
88+
"spawn_command": {
89+
"program_path": "<tools>/node_modules/.bin/print-file",
90+
"args": [
91+
"package.json"
92+
],
93+
"all_envs": {
94+
"NO_COLOR": "1",
95+
"PATH": "<workspace>/node_modules/.bin:<tools>/node_modules/.bin"
96+
},
97+
"cwd": "<workspace>/"
98+
}
99+
}
100+
}
101+
}
102+
}
103+
]
104+
},
105+
"neighbors": []
106+
}
107+
]
108+
}
109+
}
110+
]
111+
},
112+
"neighbors": []
113+
}
114+
]
115+
}
116+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
3+
expression: task_graph_json
4+
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cd-in-scripts
5+
---
6+
[
7+
{
8+
"key": [
9+
"<workspace>/",
10+
"build"
11+
],
12+
"node": {
13+
"task_display": {
14+
"package_name": "",
15+
"task_name": "build",
16+
"package_path": "<workspace>/"
17+
},
18+
"resolved_config": {
19+
"command": "print-file package.json",
20+
"resolved_options": {
21+
"cwd": "<workspace>/",
22+
"cache_config": {
23+
"env_config": {
24+
"fingerprinted_envs": [],
25+
"pass_through_envs": [
26+
"<default pass-through envs>"
27+
]
28+
}
29+
}
30+
}
31+
}
32+
},
33+
"neighbors": []
34+
},
35+
{
36+
"key": [
37+
"<workspace>/",
38+
"cd-build"
39+
],
40+
"node": {
41+
"task_display": {
42+
"package_name": "",
43+
"task_name": "cd-build",
44+
"package_path": "<workspace>/"
45+
},
46+
"resolved_config": {
47+
"command": "cd src && vp run build",
48+
"resolved_options": {
49+
"cwd": "<workspace>/",
50+
"cache_config": {
51+
"env_config": {
52+
"fingerprinted_envs": [],
53+
"pass_through_envs": [
54+
"<default pass-through envs>"
55+
]
56+
}
57+
}
58+
}
59+
}
60+
},
61+
"neighbors": []
62+
},
63+
{
64+
"key": [
65+
"<workspace>/",
66+
"cd-lint"
67+
],
68+
"node": {
69+
"task_display": {
70+
"package_name": "",
71+
"task_name": "cd-lint",
72+
"package_path": "<workspace>/"
73+
},
74+
"resolved_config": {
75+
"command": "cd src && vp lint",
76+
"resolved_options": {
77+
"cwd": "<workspace>/",
78+
"cache_config": {
79+
"env_config": {
80+
"fingerprinted_envs": [],
81+
"pass_through_envs": [
82+
"<default pass-through envs>"
83+
]
84+
}
85+
}
86+
}
87+
}
88+
},
89+
"neighbors": []
90+
}
91+
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"cacheScripts": true
3+
}

0 commit comments

Comments
 (0)