From 9138d3bb80e2368062c58fad19cbd02ee65e7197 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 3 Nov 2019 11:47:07 +0100 Subject: [PATCH 1/4] when Miri tests are not passing, do not add Miri component --- Cargo.lock | 1 + src/tools/build-manifest/Cargo.toml | 1 + src/tools/build-manifest/src/main.rs | 20 +++++++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 46480aeb4476d..873f5da053787 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -208,6 +208,7 @@ name = "build-manifest" version = "0.1.0" dependencies = [ "serde", + "serde_json", "toml", ] diff --git a/src/tools/build-manifest/Cargo.toml b/src/tools/build-manifest/Cargo.toml index c364479d8db13..0bbbabd29989e 100644 --- a/src/tools/build-manifest/Cargo.toml +++ b/src/tools/build-manifest/Cargo.toml @@ -7,3 +7,4 @@ edition = "2018" [dependencies] toml = "0.5" serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index fca57eec79fc6..afe170fe9032b 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -11,10 +11,11 @@ use serde::Serialize; use std::collections::BTreeMap; use std::env; -use std::fs; +use std::fs::{self, File}; use std::io::{self, Read, Write}; use std::path::{PathBuf, Path}; use std::process::{Command, Stdio}; +use std::collections::HashMap; static HOSTS: &[&str] = &[ "aarch64-unknown-linux-gnu", @@ -366,6 +367,7 @@ impl Builder { self.lldb_git_commit_hash = self.git_commit_hash("lldb", "x86_64-unknown-linux-gnu"); self.miri_git_commit_hash = self.git_commit_hash("miri", "x86_64-unknown-linux-gnu"); + self.check_toolstate(); self.digest_and_sign(); let manifest = self.build_manifest(); self.write_channel_files(&self.rust_release, &manifest); @@ -375,6 +377,22 @@ 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"); + // 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"); + self.miri_version = None; + self.miri_git_commit_hash = None; + } + } + /// Hash all files, compute their signatures, and collect the hashes in `self.digests`. fn digest_and_sign(&mut self) { for file in t!(self.input.read_dir()).map(|e| t!(e).path()) { From a675fd6f2e2fb623985fa87987a9c9ec22543279 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 3 Nov 2019 11:55:05 +0100 Subject: [PATCH 2/4] 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 afe170fe9032b..3822cccd63bd7 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"); From 2cf7c29675583b8362a9116397b297f6fc872678 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 4 Nov 2019 10:08:58 +0100 Subject: [PATCH 3/4] avoid using nightly features --- src/tools/build-manifest/src/main.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 3822cccd63bd7..373c72f9843c4 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -4,7 +4,6 @@ //! 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; @@ -381,10 +380,9 @@ 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) { - let toolstates: Option> = try { - let toolstates = File::open(self.input.join("toolstates-linux.json")).ok()?; - serde_json::from_reader(&toolstates).ok()? - }; + let toolstates: Option> = + File::open(self.input.join("toolstates-linux.json")).ok() + .and_then(|f| serde_json::from_reader(&f).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. From 224378cc6addb0b3f3d40b4fbad5a7f031fbf57b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 4 Nov 2019 10:10:40 +0100 Subject: [PATCH 4/4] more correct error msg --- src/tools/build-manifest/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 373c72f9843c4..d92924085e7c7 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -384,7 +384,8 @@ impl Builder { File::open(self.input.join("toolstates-linux.json")).ok() .and_then(|f| serde_json::from_reader(&f).ok()); let toolstates = toolstates.unwrap_or_else(|| { - println!("WARNING: `toolstates-linux.json` missing; assuming all tools failed"); + println!("WARNING: `toolstates-linux.json` missing/malformed; \ + assuming all tools failed"); HashMap::default() // Use empty map if anything went wrong. }); // Mark some tools as missing based on toolstate.