Skip to content
Closed
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
121 changes: 120 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ derive_more = "2.0.1"
diff-struct = "0.5.3"
directories = "6.0.0"
elf = { version = "0.8.0", default-features = false }
expectrl = "0.8.0"
flate2 = "1.0.35"
fspy = { path = "crates/fspy" }
fspy_detours_sys = { path = "crates/fspy_detours_sys" }
Expand Down
1 change: 1 addition & 0 deletions crates/vite_task_bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ which = { workspace = true }
[dev-dependencies]
copy_dir = { workspace = true }
cow-utils = { workspace = true }
expectrl = { workspace = true }
insta = { workspace = true, features = ["glob", "json", "redactions", "filters", "ron"] }
regex = { workspace = true }
serde = { workspace = true, features = ["derive", "rc"] }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Use writeSync to avoid buffering issues
const fs = require('fs');

// First, verify we're running in a TTY (should print "true" when using expectrl PTY)
fs.writeSync(1, 'TTY: ' + String(process.stdin.isTTY) + '\n');

// Signal the test runner to write "hello from stdin" to our stdin
fs.writeSync(1, '[write-stdin:hello from stdin]');

// Signal that we're done with stdin commands (this triggers EOF handling)
fs.writeSync(1, '[write-stdin:]');

// Read stdin asynchronously - the test runner will send data then EOF
process.stdin.setEncoding('utf8');
process.stdin.once('readable', () => {
const chunk = process.stdin.read();
if (chunk !== null) {
fs.writeSync(1, chunk);
}
fs.writeSync(1, 'Done\n');
process.exit(0);
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"name": "stdin-passthrough",
"scripts": {
"echo-stdin": "node -e \"process.stdin.pipe(process.stdout)\""
}
"name": "stdin-passthrough"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Tests that stdin is passed through to tasks
# Tests that stdin is passed through to tasks with interactive TTY

[[e2e]]
name = "stdin passthrough to single task"
steps = [
{ cmd = "vite run echo-stdin", stdin = "hello from stdin" },
{ cmd = "vite run echo-stdin", interactive = true },
]
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
---
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/stdin-passthrough
---
> vite run echo-stdin
$ node -e "process.stdin.pipe(process.stdout)"
hello from stdin
$ node echo-stdin.js
TTY: true
$ node echo-stdin.js
TTY: true
[write-stdin:hello from stdin][write-stdin:]hello from stdin
Done


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Vite+ Task Runner • Execution Summary
Expand All @@ -17,6 +21,6 @@ Performance: 0% cache hit rate

Task Details:
────────────────────────────────────────────────
[1] stdin-passthrough#echo-stdin: $ node -e "process.stdin.pipe(process.stdout)"
[1] stdin-passthrough#echo-stdin: $ node echo-stdin.js
→ Cache miss: no previous cache entry found
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tasks": {
"echo-stdin": {
"command": "node echo-stdin.js"
}
}
}
Loading
Loading