mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-10-28 08:08:58 +00:00
Move Stdio extraction to enum
This commit is contained in:
1 parent
e1da8ba00f
commit
9b8f2a9ee2
2 files changed
+12
-6
No files matched your search
@@ -1,7 +1,7 @@
|
||||
use std::process::{ExitStatus, Stdio};
|
||||
|
||||
use crate::command::Command;
|
||||
use crate::options::{CmdFailureAction, CommandOutputPolicy, Options, OutputStyleOption, Shell};
|
||||
use crate::options::{CmdFailureAction, Options, OutputStyleOption, Shell};
|
||||
use crate::output::progress_bar::get_progress_bar;
|
||||
use crate::timer::{execute_and_measure, wall_clock_timer::WallClockTimer};
|
||||
use crate::util::randomized_environment_offset;
|
||||
@@ -63,10 +63,7 @@ impl<'a> Executor for ShellExecutor<'a> {
|
||||
command: &Command<'_>,
|
||||
command_failure_action: Option<CmdFailureAction>,
|
||||
) -> Result<(TimingResult, ExitStatus)> {
|
||||
let (stdout, stderr) = match self.options.command_output_policy {
|
||||
CommandOutputPolicy::Discard => (Stdio::null(), Stdio::null()),
|
||||
CommandOutputPolicy::Forward => (Stdio::inherit(), Stdio::inherit()),
|
||||
};
|
||||
let (stdout, stderr) = self.options.command_output_policy.get_stdout_stderr();
|
||||
|
||||
let mut command_builder = self.shell.command();
|
||||
command_builder
|
||||
|
||||
+10
-1
@@ -1,4 +1,4 @@
|
||||
use std::process::Command;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::{cmp, fmt};
|
||||
|
||||
use anyhow::ensure;
|
||||
@@ -124,6 +124,15 @@ impl Default for CommandOutputPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandOutputPolicy {
|
||||
pub fn get_stdout_stderr(&self) -> (Stdio, Stdio) {
|
||||
match self {
|
||||
CommandOutputPolicy::Discard => (Stdio::null(), Stdio::null()),
|
||||
CommandOutputPolicy::Forward => (Stdio::inherit(), Stdio::inherit()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum ExecutorKind {
|
||||
Shell(Shell),
|
||||
Mock(Option<String>),
|
||||
|
||||
Reference in new issue
Block a user