Rollup merge of #66053 - RalfJung:miri-toolstate, r=pietroalbini

when Miri tests are not passing, do not add Miri component

Second attempt, this time based on the JSON files that exist since https://github.com/rust-lang/rust/pull/65274.

Fixes https://github.com/rust-lang/rust/issues/60301
r? @pietroalbini @alexcrichton
This commit is contained in:
Pietro Albini 2019-11-05 14:37:05 +01:00 committed by GitHub
commit 50035e8d84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View File

@ -208,6 +208,7 @@ name = "build-manifest"
version = "0.1.0"
dependencies = [
"serde",
"serde_json",
"toml",
]

View File

@ -7,3 +7,4 @@ edition = "2018"
[dependencies]
toml = "0.5"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

View File

@ -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,25 @@ 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<HashMap<String, String>> =
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/malformed; \
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");
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()) {