From 98336f8f6e701ea99275f32d6e2127a621041994 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 11 Jul 2023 17:01:35 +0200 Subject: [PATCH] Don't fail early if `try_run` returns an error --- src/bootstrap/download.rs | 2 +- src/bootstrap/run.rs | 11 +++++------ src/bootstrap/test.rs | 36 ++++++++++++++++-------------------- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/bootstrap/download.rs b/src/bootstrap/download.rs index cb40521dda76..9478ac7d9cea 100644 --- a/src/bootstrap/download.rs +++ b/src/bootstrap/download.rs @@ -188,7 +188,7 @@ fn fix_bin_or_dylib(&self, fname: &Path) { patchelf.args(&["--set-interpreter", dynamic_linker.trim_end()]); } - self.try_run(patchelf.arg(fname)).unwrap(); + let _ = self.try_run(patchelf.arg(fname)); } fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) { diff --git a/src/bootstrap/run.rs b/src/bootstrap/run.rs index c97b75927371..70b917000433 100644 --- a/src/bootstrap/run.rs +++ b/src/bootstrap/run.rs @@ -27,8 +27,7 @@ fn run(self, builder: &Builder<'_>) { try_run( builder, &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("generate").arg(&builder.src), - ) - .unwrap(); + ); } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -40,17 +39,17 @@ fn make_run(run: RunConfig<'_>) { } } -fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> Result<(), ()> { +fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool { if !builder.fail_fast { - if let Err(e) = builder.try_run(cmd) { + if builder.try_run(cmd).is_err() { let mut failures = builder.delayed_failures.borrow_mut(); failures.push(format!("{:?}", cmd)); - return Err(e); + return false; } } else { builder.run(cmd); } - Ok(()) + true } #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 0907291b54da..13576aa787b6 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -48,17 +48,17 @@ // build for, so there is no entry for "aarch64-apple-darwin" here. ]; -fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> Result<(), ()> { +fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool { if !builder.fail_fast { - if let Err(e) = builder.try_run(cmd) { + if builder.try_run(cmd).is_err() { let mut failures = builder.delayed_failures.borrow_mut(); failures.push(format!("{:?}", cmd)); - return Err(e); + return false; } } else { builder.run(cmd); } - Ok(()) + true } fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool { @@ -187,8 +187,7 @@ fn run(self, builder: &Builder<'_>) { try_run( builder, builder.tool_cmd(Tool::Linkchecker).arg(builder.out.join(host.triple).join("doc")), - ) - .unwrap(); + ); } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -241,8 +240,7 @@ fn run(self, builder: &Builder<'_>) { builder.default_doc(&[]); builder.ensure(crate::doc::Rustc::new(builder.top_stage, self.target, builder)); - try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target))) - .unwrap(); + try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target))); } } @@ -288,8 +286,7 @@ fn run(self, builder: &Builder<'_>) { .args(builder.config.test_args()) .env("RUSTC", builder.rustc(compiler)) .env("RUSTDOC", builder.rustdoc(compiler)), - ) - .unwrap(); + ); } } @@ -855,7 +852,7 @@ fn run(self, builder: &Builder<'_>) { util::lld_flag_no_threads(self.compiler.host.contains("windows")), ); } - try_run(builder, &mut cmd).unwrap(); + try_run(builder, &mut cmd); } } @@ -1106,7 +1103,7 @@ fn run(self, builder: &Builder<'_>) { } builder.info("tidy check"); - try_run(builder, &mut cmd).unwrap(); + try_run(builder, &mut cmd); builder.ensure(ExpandYamlAnchors); @@ -1154,8 +1151,7 @@ fn run(self, builder: &Builder<'_>) { try_run( builder, &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("check").arg(&builder.src), - ) - .unwrap(); + ); } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -1948,7 +1944,7 @@ fn run_ext_doc(self, builder: &Builder<'_>) { compiler.host, ); let _time = util::timeit(&builder); - let toolstate = if try_run(builder, &mut rustbook_cmd).is_ok() { + let toolstate = if try_run(builder, &mut rustbook_cmd) { ToolState::TestPass } else { ToolState::TestFail @@ -2106,7 +2102,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> cmd.arg("--test-args").arg(test_args); if builder.config.verbose_tests { - try_run(builder, &mut cmd).is_ok() + try_run(builder, &mut cmd) } else { try_run_quiet(builder, &mut cmd) } @@ -2134,7 +2130,7 @@ fn run(self, builder: &Builder<'_>) { let src = builder.src.join(relative_path); let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook); - let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)).is_ok() { + let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)) { ToolState::TestPass } else { ToolState::TestFail @@ -2684,7 +2680,7 @@ fn run(self, builder: &Builder<'_>) { .current_dir(builder.src.join("src/bootstrap/")); // NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible. // Use `python -m unittest` manually if you want to pass arguments. - try_run(builder, &mut check_bootstrap).unwrap(); + try_run(builder, &mut check_bootstrap); let host = builder.config.build; let compiler = builder.compiler(0, host); @@ -2756,7 +2752,7 @@ fn run(self, builder: &Builder<'_>) { } builder.info("platform support check"); - try_run(builder, &mut cargo.into()).unwrap(); + try_run(builder, &mut cargo.into()); } } @@ -2836,7 +2832,7 @@ fn run(self, builder: &Builder<'_>) { cmd.env("CARGO", &builder.initial_cargo); cmd.env("RUSTC", &builder.initial_rustc); cmd.env("TMP_DIR", &tmpdir); - try_run(builder, &mut cmd).unwrap(); + try_run(builder, &mut cmd); } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { -- 2.41.0