summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-04-26 14:46:49 -0400
committerGitHub <noreply@github.com>2022-04-26 14:46:49 -0400
commita1b4aa2ae60d215e38c6871fae690e34964a27d7 (patch)
treec41baf3067ca2a618bd458f1101bf9cf98506dae /runtime
parentf07f246ae8a158e33e81aa4ccf225cd536795f50 (diff)
fix(test): capture inherited stdout and stderr for subprocesses in test output (#14395)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/ops/process.rs16
-rw-r--r--runtime/ops/spawn.rs11
2 files changed, 23 insertions, 4 deletions
diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs
index 8261e9eb4..e22ed3ac3 100644
--- a/runtime/ops/process.rs
+++ b/runtime/ops/process.rs
@@ -186,8 +186,20 @@ fn op_run(state: &mut OpState, run_args: RunArgs) -> Result<RunInfo, AnyError> {
// TODO: make this work with other resources, eg. sockets
c.stdin(run_args.stdin.as_stdio(state)?);
- c.stdout(run_args.stdout.as_stdio(state)?);
- c.stderr(run_args.stderr.as_stdio(state)?);
+ c.stdout(
+ match run_args.stdout {
+ StdioOrRid::Stdio(Stdio::Inherit) => StdioOrRid::Rid(1),
+ value => value,
+ }
+ .as_stdio(state)?,
+ );
+ c.stderr(
+ match run_args.stderr {
+ StdioOrRid::Stdio(Stdio::Inherit) => StdioOrRid::Rid(2),
+ value => value,
+ }
+ .as_stdio(state)?,
+ );
// We want to kill child when it's closed
c.kill_on_drop(true);
diff --git a/runtime/ops/spawn.rs b/runtime/ops/spawn.rs
index 9ec1937af..0f329e16e 100644
--- a/runtime/ops/spawn.rs
+++ b/runtime/ops/spawn.rs
@@ -4,6 +4,7 @@ use super::io::ChildStderrResource;
use super::io::ChildStdinResource;
use super::io::ChildStdoutResource;
use super::process::Stdio;
+use super::process::StdioOrRid;
use crate::permissions::Permissions;
use deno_core::error::AnyError;
use deno_core::op;
@@ -147,8 +148,14 @@ fn create_command(
}
command.stdin(args.stdio.stdin.as_stdio());
- command.stdout(args.stdio.stdout.as_stdio());
- command.stderr(args.stdio.stderr.as_stdio());
+ command.stdout(match args.stdio.stdout {
+ Stdio::Inherit => StdioOrRid::Rid(1).as_stdio(state)?,
+ value => value.as_stdio(),
+ });
+ command.stderr(match args.stdio.stderr {
+ Stdio::Inherit => StdioOrRid::Rid(2).as_stdio(state)?,
+ value => value.as_stdio(),
+ });
Ok(command)
}