about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2019-11-03 11:55:05 +0100
committerRalf Jung <post@ralfj.de>2019-11-03 11:55:05 +0100
commita675fd6f2e2fb623985fa87987a9c9ec22543279 (patch)
treeaeb8e675548123fefc5c8ed8deb5d40e348e24ba
parent9138d3bb80e2368062c58fad19cbd02ee65e7197 (diff)
don't fail manifest creation if the toolstate file is missing or mal-formed
-rw-r--r--src/tools/build-manifest/src/main.rs14
1 files 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<String, String> = serde_json::from_reader(&toolstates)
-            .expect("toolstates file contains malformed JSON");
+        let toolstates: Option<HashMap<String, String>> = 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");