Skip to content

Commit 7f78666

Browse files
committed
test: add E2E tests for stdio detection across all task count and cache combinations
1 parent 24195b7 commit 7f78666

13 files changed

Lines changed: 307 additions & 0 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "stdio-detection-test",
3+
"private": true
4+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "other",
3+
"scripts": {
4+
"check-tty": "check-tty",
5+
"check-tty-cached": "check-tty"
6+
}
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
packages:
2+
- packages/*
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Tests stdio mode detection across all combinations of task count and cache state.
2+
#
3+
# `check-tty` prints whether each stdio stream is a TTY. In the PTY test
4+
# environment, inherited stdio shows as "tty"; piped/null shows as "not-tty".
5+
#
6+
# Only one combination produces inherited (TTY) stdio: a single task with
7+
# caching disabled. All other combinations use piped stdio — either because
8+
# multiple tasks require labeled output, or because caching needs to capture
9+
# or replay output.
10+
11+
# ─── Single task ─────────────────────────────────────────────────
12+
13+
[[e2e]]
14+
name = "single task, cache disabled"
15+
# Expect: all stdio inherited from terminal (tty)
16+
steps = [
17+
"vp run check-tty",
18+
]
19+
20+
[[e2e]]
21+
name = "single task, cache miss"
22+
# Expect: stdio piped for cache capture (not-tty)
23+
steps = [
24+
"vp run check-tty-cached",
25+
]
26+
27+
[[e2e]]
28+
name = "single task, cache hit"
29+
# Expect: first run is a miss (not-tty), second run replays cached output
30+
steps = [
31+
"vp run check-tty-cached",
32+
"vp run check-tty-cached",
33+
]
34+
35+
# ─── Multiple tasks (-r) ────────────────────────────────────────
36+
37+
[[e2e]]
38+
name = "multiple tasks, cache disabled"
39+
# Expect: stdio piped for labeled output (not-tty)
40+
steps = [
41+
"vp run -r check-tty",
42+
]
43+
44+
[[e2e]]
45+
name = "multiple tasks, cache miss"
46+
# Expect: stdio piped (not-tty)
47+
steps = [
48+
"vp run -r check-tty-cached",
49+
]
50+
51+
[[e2e]]
52+
name = "multiple tasks, cache hit"
53+
# Expect: first run is a miss (not-tty), second run replays cached output
54+
steps = [
55+
"vp run -r check-tty-cached",
56+
"vp run -r check-tty-cached",
57+
]
Lines changed: 31 additions & 0 deletions
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 check-tty
6+
~/packages/other$ check-tty
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 hits1 cache misses1 cache disabled
22+
Performance: 0% cache hit rate
23+
24+
Task Details:
25+
────────────────────────────────────────────────
26+
[1] other#check-tty: ~/packages/other$ check-tty
27+
Cache miss: no previous cache entry found
28+
·······················································
29+
[2] stdio-detection-test#check-tty: $ check-tty
30+
Cache disabled in task configuration
31+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run -r check-tty-cached
6+
~/packages/other$ check-tty
7+
stdin:not-tty
8+
stdout:not-tty
9+
stderr:not-tty
10+
11+
$ check-tty
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 hits2 cache misses
22+
Performance: 0% cache hit rate
23+
24+
Task Details:
25+
────────────────────────────────────────────────
26+
[1] other#check-tty-cached: ~/packages/other$ check-tty
27+
Cache miss: no previous cache entry found
28+
·······················································
29+
[2] stdio-detection-test#check-tty-cached: $ check-tty
30+
Cache miss: no previous cache entry found
31+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
32+
> vp run -r check-tty-cached
33+
~/packages/other$ check-ttycache hit, replaying
34+
stdin:not-tty
35+
stdout:not-tty
36+
stderr:not-tty
37+
38+
$ check-ttycache hit, replaying
39+
stdin:not-tty
40+
stdout:not-tty
41+
stderr:not-tty
42+
43+
44+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
45+
Vite+ Task RunnerExecution Summary
46+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
47+
48+
Statistics: 2 tasks2 cache hits0 cache misses
49+
Performance: 100% cache hit rate, <duration> saved in total
50+
51+
Task Details:
52+
────────────────────────────────────────────────
53+
[1] other#check-tty-cached: ~/packages/other$ check-tty ✓
54+
→ Cache hit - output replayed - <duration> saved
55+
·······················································
56+
[2] stdio-detection-test#check-tty-cached: $ check-tty ✓
57+
→ Cache hit - output replayed - <duration> saved
58+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Lines changed: 31 additions & 0 deletions
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 check-tty-cached
6+
~/packages/other$ check-tty
7+
stdin:not-tty
8+
stdout:not-tty
9+
stderr:not-tty
10+
11+
$ check-tty
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 hits2 cache misses
22+
Performance: 0% cache hit rate
23+
24+
Task Details:
25+
────────────────────────────────────────────────
26+
[1] other#check-tty-cached: ~/packages/other$ check-tty
27+
Cache miss: no previous cache entry found
28+
·······················································
29+
[2] stdio-detection-test#check-tty-cached: $ check-tty
30+
Cache miss: no previous cache entry found
31+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run check-tty
6+
$ check-ttycache disabled: no cache config
7+
stdin:tty
8+
stdout:tty
9+
stderr:tty
10+
11+
12+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
13+
Vite+ Task RunnerExecution Summary
14+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
15+
16+
Statistics: 1 tasks0 cache hits0 cache misses1 cache disabled
17+
Performance: 0% cache hit rate
18+
19+
Task Details:
20+
────────────────────────────────────────────────
21+
[1] stdio-detection-test#check-tty: $ check-tty
22+
Cache disabled in task configuration
23+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run check-tty-cached
6+
$ check-tty
7+
stdin:not-tty
8+
stdout:not-tty
9+
stderr:not-tty
10+
11+
12+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
13+
Vite+ Task RunnerExecution Summary
14+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
15+
16+
Statistics: 1 tasks0 cache hits1 cache misses
17+
Performance: 0% cache hit rate
18+
19+
Task Details:
20+
────────────────────────────────────────────────
21+
[1] stdio-detection-test#check-tty-cached: $ check-tty
22+
Cache miss: no previous cache entry found
23+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
24+
> vp run check-tty-cached
25+
$ check-ttycache hit, replaying
26+
stdin:not-tty
27+
stdout:not-tty
28+
stderr:not-tty
29+
30+
31+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
32+
Vite+ Task RunnerExecution Summary
33+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
34+
35+
Statistics: 1 tasks1 cache hits0 cache misses
36+
Performance: 100% cache hit rate, <duration> saved in total
37+
38+
Task Details:
39+
────────────────────────────────────────────────
40+
[1] stdio-detection-test#check-tty-cached: $ check-tty ✓
41+
→ Cache hit - output replayed - <duration> saved
42+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
expression: e2e_outputs
4+
---
5+
> vp run check-tty-cached
6+
$ check-tty
7+
stdin:not-tty
8+
stdout:not-tty
9+
stderr:not-tty
10+
11+
12+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
13+
Vite+ Task RunnerExecution Summary
14+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
15+
16+
Statistics: 1 tasks0 cache hits1 cache misses
17+
Performance: 0% cache hit rate
18+
19+
Task Details:
20+
────────────────────────────────────────────────
21+
[1] stdio-detection-test#check-tty-cached: $ check-tty
22+
Cache miss: no previous cache entry found
23+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

0 commit comments

Comments
 (0)