Skip to content
Open
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
5 changes: 3 additions & 2 deletions doc/hyperfine.1
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,10 @@ things like "sleep 0.1; sleep 0.2" are not possible without a shell.
.IP
An alias for '\-\-shell=none'.
.HP
\fB\-i\fR, \fB\-\-ignore\-failure\fR
\fB\-i\fR, \fB\-\-ignore\-exit\-code\fR, \fB\-\-ignore\-failure\fR
.IP
Ignore non\-zero exit codes of the benchmarked programs.
Ignore non\-zero exit codes of the benchmarked programs. \fB\-\-ignore\-exit\-code\fR is an alias for
\fB\-\-ignore\-failure\fR.
.HP
\fB\-\-style\fR \fITYPE\fP
.IP
Expand Down
2 changes: 1 addition & 1 deletion src/benchmark/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn run_command_and_measure_common(
BenchmarkIteration::Benchmark(i) => format!("benchmark iteration {i}"),
};
bail!(
"{cause} in {when}. Use the '-i'/'--ignore-failure' option if you want to ignore this. \
"{cause} in {when}. Use the '-i'/'--ignore-exit-code'/'--ignore-failure' option if you want to ignore this. \
Alternatively, use the '--show-output' option to debug what went wrong.",
cause=result.status.code().map_or(
"The process has been terminated by a signal".into(),
Expand Down
6 changes: 4 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,17 @@ fn build_command() -> Command {
.arg(
Arg::new("ignore-failure")
.long("ignore-failure")
.alias("ignore-exit-code")
.action(ArgAction::Set)
.value_name("MODE")
.num_args(0..=1)
.default_missing_value("all-non-zero")
.require_equals(true)
.short('i')
.help("Ignore failures of the benchmarked programs. Without a value or with \
.help("Ignore non-zero exit codes of the benchmarked programs. Without a value or with \
'all-non-zero', all non-zero exit codes are ignored. You can also provide \
a comma-separated list of exit codes to ignore (e.g., --ignore-failure=1,2)."),
a comma-separated list of exit codes to ignore (e.g., --ignore-exit-code=1,2). \
'--ignore-exit-code' is an alias for '--ignore-failure'."),
)
.arg(
Arg::new("style")
Expand Down
18 changes: 18 additions & 0 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,24 @@ fn fails_for_unknown_conclude_command() {
));
}

#[cfg(unix)]
#[test]
fn ignore_exit_code_is_an_alias_for_ignore_failure() {
hyperfine()
.arg("--runs=1")
.arg("--ignore-exit-code")
.arg("false")
.assert()
.success();

hyperfine()
.arg("--runs=1")
.arg("--ignore-exit-code=1")
.arg("exit 1")
.assert()
.success();
}

#[cfg(unix)]
#[test]
fn can_run_failing_commands_with_ignore_failure_option() {
Expand Down