Skip to content

Commit

Permalink
Merge pull request #135 from dvente/master
Browse files Browse the repository at this point in the history
add timeout functionality for bisecting hangs
  • Loading branch information
ehuss committed Oct 8, 2021
2 parents 63a18d8 + 615f70c commit 34b0328
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
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

0 comments on commit 34b0328

Please sign in to comment.