Skip to content

add timeout functionality for bisecting hangs #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2021
Merged
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
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ struct Opts {
)]
prompt: bool,

#[structopt(
long = "timeout",
short = "t",
help = "Assume failure after specified number of seconds (for bisecting hangs)"
)]
timeout: Option<usize>,

#[structopt(short = "v", long = "verbose", parse(from_occurrences))]
verbosity: usize,

Expand Down
35 changes: 32 additions & 3 deletions src/toolchains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,15 @@ impl Toolchain {
.join(&format!("target-{}", self.rustup_name())),
);
}
let mut cmd = match cfg.args.script {
Some(ref script) => {

let mut cmd = match (cfg.args.script.as_ref(), cfg.args.timeout) {
(Some(script), None) => {
let mut cmd = Command::new(script);
cmd.env("RUSTUP_TOOLCHAIN", self.rustup_name());
cmd.args(&cfg.args.command_args);
cmd
}
None => {
(None, None) => {
let mut cmd = Command::new("cargo");
cmd.arg(&format!("+{}", self.rustup_name()));
if cfg.args.command_args.is_empty() {
Expand All @@ -334,6 +335,26 @@ impl Toolchain {
}
cmd
}
(Some(script), Some(timeout)) => {
let mut cmd = Command::new("timeout");
cmd.arg(timeout.to_string());
cmd.arg(script);
cmd.args(&cfg.args.command_args);
cmd.env("RUSTUP_TOOLCHAIN", self.rustup_name());
cmd
}
(None, Some(timeout)) => {
let mut cmd = Command::new("timeout");
cmd.arg(timeout.to_string());
cmd.arg("cargo");
cmd.arg(format!("+{}", self.rustup_name()));
if cfg.args.command_args.is_empty() {
cmd.arg("build");
} else {
cmd.args(&cfg.args.command_args);
}
cmd
}
};
cmd.current_dir(&cfg.args.test_dir);
cmd.env("CARGO_TARGET_DIR", format!("target-{}", self.rustup_name()));
Expand Down Expand Up @@ -377,6 +398,14 @@ impl Toolchain {
let output = self.run_test(cfg);
let status = output.status;

//timeout returns exit code 124 on expiration
if status.code() == Some(124) {
match cfg.args.timeout {
Some(_) => break TestOutcome::Regressed,
None => panic!("Process timed out but no timeout was specified. Please check host configuration for timeouts and try again.")
}
}

eprintln!("\n\n{} finished with exit code {:?}.", self, status.code());
eprintln!("please select an action to take:");

Expand Down