Initial support for randomized environment variables

This commit is contained in:
sharkdp committed 2020-05-25 16:03:58 +02:00
1 parent 4d3dd42d89
commit 46e7e4152a
4 files changed
+273 -206

No files matched your search

+3 -4
View File
@@ -47,20 +47,19 @@ pub fn time_shell_command(
failure_action: CmdFailureAction,
shell_spawning_time: Option<TimingResult>,
) -> io::Result<(TimingResult, bool)> {
let wallclock_timer = WallClockTimer::start();
let (stdout, stderr) = if show_output {
(Stdio::inherit(), Stdio::inherit())
} else {
(Stdio::null(), Stdio::null())
};
let wallclock_timer = WallClockTimer::start();
let result = execute_and_time(stdout, stderr, &command.get_shell_command(), shell)?;
let mut time_real = wallclock_timer.stop();
let mut time_user = result.user_time;
let mut time_system = result.system_time;
let mut time_real = wallclock_timer.stop();
if failure_action == CmdFailureAction::RaiseError && !result.status.success() {
return Err(io::Error::new(
io::ErrorKind::Other,
+4
View File
@@ -69,6 +69,10 @@ fn run_shell_command(
Command::new(shell)
.arg("-c")
.arg(command)
.env(
"HYPERFINE_RANDOMIZED_ENVIRONMENT_OFFSET",
"X".repeat(rand::random::<usize>() % 4096usize),
)
.stdin(Stdio::null())
.stdout(stdout)
.stderr(stderr)