From a675fd6f2e2fb623985fa87987a9c9ec22543279 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 3 Nov 2019 11:55:05 +0100 Subject: [PATCH] don't fail manifest creation if the toolstate file is missing or mal-formed --- src/tools/build-manifest/src/main.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index afe170fe903..3822cccd63b 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -4,6 +4,7 @@ //! via `x.py dist hash-and-sign`; the cmdline arguments are set up //! by rustbuild (in `src/bootstrap/dist.rs`). +#![feature(try_blocks)] #![deny(warnings)] use toml; @@ -380,11 +381,14 @@ impl Builder { /// If a tool does not pass its tests, don't ship it. /// Right now, we do this only for Miri. fn check_toolstate(&mut self) { - // Get the toolstate for this rust revision. - let toolstates = File::open(self.input.join("toolstates-linux.json")) - .expect("failed to open toolstates file"); - let toolstates: HashMap = serde_json::from_reader(&toolstates) - .expect("toolstates file contains malformed JSON"); + let toolstates: Option> = try { + let toolstates = File::open(self.input.join("toolstates-linux.json")).ok()?; + serde_json::from_reader(&toolstates).ok()? + }; + let toolstates = toolstates.unwrap_or_else(|| { + println!("WARNING: `toolstates-linux.json` missing; assuming all tools failed"); + HashMap::default() // Use empty map if anything went wrong. + }); // Mark some tools as missing based on toolstate. if toolstates.get("miri").map(|s| &*s as &str) != Some("test-pass") { println!("Miri tests are not passing, removing component");