Skip to content

Commit

Permalink
Make test steps sortable
Browse files Browse the repository at this point in the history
Ensures that test cases will be somewhat easier to write.
  • Loading branch information
Mark-Simulacrum committed Apr 3, 2018
1 parent cd33d3a commit fde70b0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 deletions.
14 changes: 14 additions & 0 deletions src/bootstrap/cache.rs
Expand Up @@ -21,6 +21,7 @@ use std::mem;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::Mutex;
use std::cmp::{PartialOrd, Ord, Ordering};

use builder::Step;

Expand Down Expand Up @@ -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> {
items: Vec<T>,
Expand Down
12 changes: 6 additions & 6 deletions src/bootstrap/compile.rs
Expand Up @@ -38,7 +38,7 @@ use tool;
use cache::{INTERNER, Interned};
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 target: Interned<String>,
pub compiler: Compiler,
Expand Down Expand Up @@ -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 compiler: Compiler,
pub target: Interned<String>,
pub compiler: Compiler,
}

impl Step for Test {
Expand Down Expand Up @@ -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 compiler: Compiler,
pub target: Interned<String>,
pub compiler: Compiler,
}

impl Step for Rustc {
Expand Down Expand Up @@ -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 {
/// The compiler which we will produce in this step. Assemble itself will
/// take care of ensuring that the necessary prerequisites to do so exist,
Expand Down
24 changes: 12 additions & 12 deletions src/bootstrap/dist.rs
Expand Up @@ -61,7 +61,7 @@ fn rust_installer(builder: &Builder) -> Command {
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 stage: u32,
pub host: Interned<String>,
Expand Down Expand Up @@ -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 {
host: Interned<String>,
pub host: Interned<String>,
}

impl Step for Mingw {
Expand Down Expand Up @@ -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 compiler: Compiler,
}
Expand Down Expand Up @@ -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 compiler: Compiler,
pub target: Interned<String>,
Expand Down Expand Up @@ -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;

impl Step for Src {
Expand Down Expand Up @@ -894,7 +894,7 @@ impl Step for Src {

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;

impl Step for PlainSourceTarball {
Expand Down Expand Up @@ -1048,7 +1048,7 @@ fn write_file(path: &Path, data: &[u8]) {
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 stage: u32,
pub target: Interned<String>,
Expand Down Expand Up @@ -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 stage: u32,
pub target: Interned<String>,
Expand Down Expand Up @@ -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 stage: u32,
pub target: Interned<String>,
Expand Down Expand Up @@ -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 {
stage: u32,
host: Interned<String>,
Expand Down Expand Up @@ -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;

impl Step for HashSign {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/lib.rs
Expand Up @@ -198,7 +198,7 @@ use toolstate::ToolState;
/// 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
/// 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 {
stage: u32,
host: Interned<String>,
Expand Down

0 comments on commit fde70b0

Please sign in to comment.