Skip to content

Commit f4e6b3e

Browse files
committed
fix: suggest stdio mode by leaf graph path
1 parent 3661714 commit f4e6b3e

10 files changed

Lines changed: 299 additions & 141 deletions

File tree

crates/vite_task/src/session/reporter/labeled.rs

Lines changed: 154 additions & 140 deletions
Large diffs are not rendered by default.

crates/vite_task_bin/tests/e2e_snapshots/fixtures/stdin-inheritance/snapshots.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Tests stdin inheritance behavior for spawned tasks.
22
#
33
# Stdin is inherited from the parent process only when BOTH conditions are met:
4-
# 1. The reporter suggests inherited stdin (single spawn leaf in the graph, or synthetic execution)
4+
# 1. The reporter suggests inherited stdin (the leaf is in a single-node graph chain,
5+
# or the execution uses PlainReporter for synthetic execution)
56
# 2. Caching is disabled for the task (cache_metadata is None)
67
#
78
# Otherwise, stdin is set to /dev/null.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "stdio-graph-criteria-test",
3+
"private": true
4+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "other"
3+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"tasks": {
3+
"check-tty": {
4+
"command": "check-tty",
5+
"cache": false
6+
},
7+
"bar": {
8+
"command": "check-tty",
9+
"cache": false
10+
},
11+
"foo-nested": {
12+
"command": "vp run bar",
13+
"cache": false
14+
}
15+
}
16+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
packages:
2+
- packages/*
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Tests stdio suggestion criteria based on graph shape along each leaf path.
2+
#
3+
# Rules under test:
4+
# - Suggest piped when the leaf's containing graph has more than one node, or
5+
# any ancestor graph on its path has more than one node.
6+
# - Suggest inherited only when every graph on the path (root + nested Expanded
7+
# graphs) has exactly one node.
8+
9+
[[e2e]]
10+
name = "single-node chains inherit even with multi-node sibling graph"
11+
steps = [
12+
"vp run foo",
13+
]
14+
15+
[[e2e]]
16+
name = "multi-node ancestor forces piped for nested single-node graph"
17+
steps = [
18+
"vp run -r foo-nested",
19+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run -r foo-nested
6+
~/packages/other$ check-ttycache disabled: no cache config
7+
stdin:not-tty
8+
stdout:not-tty
9+
stderr:not-tty
10+
11+
$ check-ttycache disabled: no cache config
12+
stdin:not-tty
13+
stdout:not-tty
14+
stderr:not-tty
15+
16+
17+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
18+
Vite+ Task RunnerExecution Summary
19+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
20+
21+
Statistics: 2 tasks0 cache hits0 cache misses2 cache disabled
22+
Performance: 0% cache hit rate
23+
24+
Task Details:
25+
────────────────────────────────────────────────
26+
[1] other#bar: ~/packages/other$ check-tty
27+
Cache disabled in task configuration
28+
·······················································
29+
[2] stdio-graph-criteria-test#bar: $ check-tty
30+
Cache disabled in task configuration
31+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run foo
6+
$ check-ttycache disabled: no cache config
7+
stdin:tty
8+
stdout:tty
9+
stderr:tty
10+
11+
$ check-ttycache disabled: no cache config
12+
stdin:tty
13+
stdout:tty
14+
stderr:tty
15+
16+
~/packages/other$ check-ttycache disabled: no cache config
17+
stdin:not-tty
18+
stdout:not-tty
19+
stderr:not-tty
20+
21+
$ check-ttycache disabled: no cache config
22+
stdin:not-tty
23+
stdout:not-tty
24+
stderr:not-tty
25+
26+
27+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
28+
Vite+ Task RunnerExecution Summary
29+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
30+
31+
Statistics: 4 tasks0 cache hits0 cache misses4 cache disabled
32+
Performance: 0% cache hit rate
33+
34+
Task Details:
35+
────────────────────────────────────────────────
36+
[1] stdio-graph-criteria-test#foo: $ check-tty
37+
Cache disabled in task configuration
38+
·······················································
39+
[2] stdio-graph-criteria-test#bar: $ check-tty
40+
Cache disabled in task configuration
41+
·······················································
42+
[3] other#check-tty: ~/packages/other$ check-tty
43+
Cache disabled in task configuration
44+
·······················································
45+
[4] stdio-graph-criteria-test#check-tty: $ check-tty
46+
Cache disabled in task configuration
47+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"cacheScripts": true,
3+
"tasks": {
4+
"check-tty": {
5+
"command": "check-tty",
6+
"cache": false
7+
},
8+
"bar": {
9+
"command": "check-tty",
10+
"cache": false
11+
},
12+
"foo": {
13+
"command": "check-tty && vp run bar && vp run -r check-tty",
14+
"cache": false
15+
},
16+
"foo-nested": {
17+
"command": "vp run bar",
18+
"cache": false
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)