Make test steps sortable

Ensures that test cases will be somewhat easier to write.
This commit is contained in:
Mark Simulacrum
2018-03-10 07:01:06 -07:00
parent cd33d3a0e4
commit fde70b0963
4 changed files with 33 additions and 19 deletions

View File

@@ -21,6 +21,7 @@ use std::mem;
use std::ops::Deref; use std::ops::Deref;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::sync::Mutex; use std::sync::Mutex;
use std::cmp::{PartialOrd, Ord, Ordering};
use builder::Step; use builder::Step;
@@ -154,6 +155,19 @@ impl AsRef<OsStr> for Interned<String> {
} }
} }
impl PartialOrd<Interned<String>> for Interned<String> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
let l = INTERNER.strs.lock().unwrap();
l.get(*self).partial_cmp(l.get(*other))
}
}
impl Ord for Interned<String> {
fn cmp(&self, other: &Self) -> Ordering {
let l = INTERNER.strs.lock().unwrap();
l.get(*self).cmp(l.get(*other))
}
}
struct TyIntern<T> { struct TyIntern<T> {
items: Vec<T>, items: Vec<T>,

View File

@@ -38,7 +38,7 @@ use tool;
use cache::{INTERNER, Interned}; use cache::{INTERNER, Interned};
use builder::{Step, RunConfig, ShouldRun, Builder}; use builder::{Step, RunConfig, ShouldRun, Builder};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Std { pub struct Std {
pub target: Interned<String>, pub target: Interned<String>,
pub compiler: Compiler, pub compiler: Compiler,
@@ -314,10 +314,10 @@ impl Step for StartupObjects {
} }
} }
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Test { pub struct Test {
pub compiler: Compiler,
pub target: Interned<String>, pub target: Interned<String>,
pub compiler: Compiler,
} }
impl Step for Test { impl Step for Test {
@@ -430,10 +430,10 @@ impl Step for TestLink {
} }
} }
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Rustc { pub struct Rustc {
pub compiler: Compiler,
pub target: Interned<String>, pub target: Interned<String>,
pub compiler: Compiler,
} }
impl Step for Rustc { impl Step for Rustc {
@@ -840,7 +840,7 @@ impl Step for Sysroot {
} }
} }
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Copy, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)]
pub struct Assemble { pub struct Assemble {
/// The compiler which we will produce in this step. Assemble itself will /// The compiler which we will produce in this step. Assemble itself will
/// take care of ensuring that the necessary prerequisites to do so exist, /// take care of ensuring that the necessary prerequisites to do so exist,

View File

@@ -61,7 +61,7 @@ fn rust_installer(builder: &Builder) -> Command {
builder.tool_cmd(Tool::RustInstaller) builder.tool_cmd(Tool::RustInstaller)
} }
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Docs { pub struct Docs {
pub stage: u32, pub stage: u32,
pub host: Interned<String>, pub host: Interned<String>,
@@ -320,9 +320,9 @@ fn make_win_dist(
} }
} }
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Mingw { pub struct Mingw {
host: Interned<String>, pub host: Interned<String>,
} }
impl Step for Mingw { impl Step for Mingw {
@@ -378,7 +378,7 @@ impl Step for Mingw {
} }
} }
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Rustc { pub struct Rustc {
pub compiler: Compiler, pub compiler: Compiler,
} }
@@ -607,7 +607,7 @@ impl Step for DebuggerScripts {
} }
} }
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Std { pub struct Std {
pub compiler: Compiler, pub compiler: Compiler,
pub target: Interned<String>, pub target: Interned<String>,
@@ -800,7 +800,7 @@ fn copy_src_dirs(build: &Build, src_dirs: &[&str], exclude_dirs: &[&str], dst_di
} }
} }
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Src; pub struct Src;
impl Step for Src { impl Step for Src {
@@ -894,7 +894,7 @@ impl Step for Src {
const CARGO_VENDOR_VERSION: &str = "0.1.4"; const CARGO_VENDOR_VERSION: &str = "0.1.4";
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct PlainSourceTarball; pub struct PlainSourceTarball;
impl Step for PlainSourceTarball { impl Step for PlainSourceTarball {
@@ -1048,7 +1048,7 @@ fn write_file(path: &Path, data: &[u8]) {
t!(vf.write_all(data)); t!(vf.write_all(data));
} }
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Cargo { pub struct Cargo {
pub stage: u32, pub stage: u32,
pub target: Interned<String>, pub target: Interned<String>,
@@ -1135,7 +1135,7 @@ impl Step for Cargo {
} }
} }
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Rls { pub struct Rls {
pub stage: u32, pub stage: u32,
pub target: Interned<String>, pub target: Interned<String>,
@@ -1216,7 +1216,7 @@ impl Step for Rls {
} }
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Rustfmt { pub struct Rustfmt {
pub stage: u32, pub stage: u32,
pub target: Interned<String>, pub target: Interned<String>,
@@ -1298,7 +1298,7 @@ impl Step for Rustfmt {
} }
} }
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Extended { pub struct Extended {
stage: u32, stage: u32,
host: Interned<String>, host: Interned<String>,
@@ -1731,7 +1731,7 @@ fn add_env(build: &Build, cmd: &mut Command, target: Interned<String>) {
} }
} }
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
pub struct HashSign; pub struct HashSign;
impl Step for HashSign { impl Step for HashSign {

View File

@@ -198,7 +198,7 @@ use toolstate::ToolState;
/// Each compiler has a `stage` that it is associated with and a `host` that /// Each compiler has a `stage` that it is associated with and a `host` that
/// corresponds to the platform the compiler runs on. This structure is used as /// corresponds to the platform the compiler runs on. This structure is used as
/// a parameter to many methods below. /// a parameter to many methods below.
#[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)] #[derive(Eq, PartialOrd, Ord, PartialEq, Clone, Copy, Hash, Debug)]
pub struct Compiler { pub struct Compiler {
stage: u32, stage: u32,
host: Interned<String>, host: Interned<String>,