Skip to content

Commit 90f0ac8

Browse files
committed
refactored code to add stage that can process output to decide outcome based on more subtle predicate than just exit_status.success().
1 parent 8f11321 commit 90f0ac8

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/main.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,16 @@ impl Toolchain {
495495
fn test(&self, cfg: &Config) -> TestOutcome {
496496
let outcome = if cfg.args.prompt {
497497
loop {
498-
let status = self.run_test(cfg);
498+
let output = self.run_test(cfg);
499+
let status = output.status();
499500

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

504+
// FIXME: should this use `Config::default_outcome_of_output`
505+
// for inferring the default below, rather than always
506+
// defaulting to "mark regressed"?
507+
503508
match Select::new()
504509
.items(&["mark regressed", "mark baseline", "retry"])
505510
.default(0)
@@ -513,17 +518,27 @@ impl Toolchain {
513518
}
514519
}
515520
} else {
516-
if self.run_test(cfg).success() {
517-
TestOutcome::Baseline
518-
} else {
519-
TestOutcome::Regressed
520-
}
521+
let output = self.run_test(cfg);
522+
cfg.default_outcome_of_output(output)
521523
};
522524

523525
outcome
524526
}
527+
}
525528

526-
fn run_test(&self, cfg: &Config) -> process::ExitStatus {
529+
impl Config {
530+
fn default_outcome_of_output(&self, process::Output) -> TestOutcome {
531+
let status = output.status();
532+
if status.success() {
533+
TestOutcome::Baseline
534+
} else {
535+
TestOutcome::Regressed
536+
}
537+
}
538+
}
539+
540+
impl Toolchain {
541+
fn run_test(&self, cfg: &Config) -> process::Output {
527542
if !cfg.args.preserve_target {
528543
let _ = fs::remove_dir_all(
529544
cfg.args
@@ -557,14 +572,14 @@ impl Toolchain {
557572
cmd.stdout(Stdio::null());
558573
cmd.stderr(Stdio::null());
559574
}
560-
let status = match cmd.status() {
561-
Ok(status) => status,
575+
let output = match cmd.output() {
576+
Ok(output) => output,
562577
Err(err) => {
563578
panic!("failed to run {:?}: {:?}", cmd, err);
564579
}
565580
};
566581

567-
status
582+
output
568583
}
569584

570585
fn install(&self, client: &Client, dl_params: &DownloadParams) -> Result<(), InstallError> {

0 commit comments

Comments
 (0)