]> git.lizzy.rs Git - rust.git/commitdiff
Make test steps sortable
authorMark Simulacrum <mark.simulacrum@gmail.com>
Sat, 10 Mar 2018 14:01:06 +0000 (07:01 -0700)
committerMark Simulacrum <mark.simulacrum@gmail.com>
Tue, 3 Apr 2018 17:39:16 +0000 (11:39 -0600)
Ensures that test cases will be somewhat easier to write.

src/bootstrap/cache.rs
src/bootstrap/compile.rs
src/bootstrap/dist.rs
src/bootstrap/lib.rs

index c27493158826cf695c69586e0af896e91f9e35bd..cbc77ab5bf42e390f26d11b40a39d55accad16f9 100644 (file)
@@ -21,6 +21,7 @@
 use std::ops::Deref;
 use std::path::{Path, PathBuf};
 use std::sync::Mutex;
+use std::cmp::{PartialOrd, Ord, Ordering};
 
 use builder::Step;
 
@@ -154,6 +155,19 @@ fn as_ref(&self) -> &'static OsStr {
     }
 }
 
+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>,
index 54b0ed6bb35952d55d40926a41b7b76bb8c511c7..d1a6a8d12a7c394fbc4b1b32dfc7cc33dcb03dcc 100644 (file)
@@ -38,7 +38,7 @@
 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,
@@ -314,10 +314,10 @@ fn run(self, builder: &Builder) {
     }
 }
 
-#[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 {
@@ -430,10 +430,10 @@ fn run(self, builder: &Builder) {
     }
 }
 
-#[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 {
@@ -840,7 +840,7 @@ fn run(self, builder: &Builder) -> Interned<PathBuf> {
     }
 }
 
-#[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,
index 23b7b265a94bee5690e774586b366b1152d8980e..cfa0cdecca6b3837f216495b8a1405dd5cfed329 100644 (file)
@@ -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>,
@@ -320,9 +320,9 @@ fn copy_to_folder(src: &Path, dest_folder: &Path) {
     }
 }
 
-#[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 {
@@ -378,7 +378,7 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
     }
 }
 
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
 pub struct Rustc {
     pub compiler: Compiler,
 }
@@ -607,7 +607,7 @@ fn run(self, builder: &Builder) {
     }
 }
 
-#[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>,
@@ -800,7 +800,7 @@ fn filter_fn(exclude_dirs: &[&str], dir: &str, path: &Path) -> bool {
     }
 }
 
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
 pub struct Src;
 
 impl Step for Src {
@@ -894,7 +894,7 @@ fn run(self, builder: &Builder) -> PathBuf {
 
 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 {
@@ -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>,
@@ -1135,7 +1135,7 @@ fn run(self, builder: &Builder) -> PathBuf {
     }
 }
 
-#[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>,
@@ -1216,7 +1216,7 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
 }
 
 
-#[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>,
@@ -1298,7 +1298,7 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
     }
 }
 
-#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
 pub struct Extended {
     stage: u32,
     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;
 
 impl Step for HashSign {
index a4287df677e3fdfc598133bff7e22033b7f04cc1..cb3a9dfbf3c11949a366e0c09fbfacad68884d47 100644 (file)
@@ -198,7 +198,7 @@ pub unsafe fn setup(_build: &mut ::Build) {
 /// 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>,