Skip to content

Commit fde70b0

Browse files
Make test steps sortable
Ensures that test cases will be somewhat easier to write.
1 parent cd33d3a commit fde70b0

File tree

4 files changed

+33
-19
lines changed

4 files changed

+33
-19
lines changed

src/bootstrap/cache.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use std::mem;
2121
use std::ops::Deref;
2222
use std::path::{Path, PathBuf};
2323
use std::sync::Mutex;
24+
use std::cmp::{PartialOrd, Ord, Ordering};
2425

2526
use builder::Step;
2627

@@ -154,6 +155,19 @@ impl AsRef<OsStr> for Interned<String> {
154155
}
155156
}
156157

158+
impl PartialOrd<Interned<String>> for Interned<String> {
159+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
160+
let l = INTERNER.strs.lock().unwrap();
161+
l.get(*self).partial_cmp(l.get(*other))
162+
}
163+
}
164+
165+
impl Ord for Interned<String> {
166+
fn cmp(&self, other: &Self) -> Ordering {
167+
let l = INTERNER.strs.lock().unwrap();
168+
l.get(*self).cmp(l.get(*other))
169+
}
170+
}
157171

158172
struct TyIntern<T> {
159173
items: Vec<T>,

src/bootstrap/compile.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use tool;
3838
use cache::{INTERNER, Interned};
3939
use builder::{Step, RunConfig, ShouldRun, Builder};
4040

41-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
41+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, PartialEq, Eq, Hash)]
4242
pub struct Std {
4343
pub target: Interned<String>,
4444
pub compiler: Compiler,
@@ -314,10 +314,10 @@ impl Step for StartupObjects {
314314
}
315315
}
316316

317-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
317+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, PartialEq, Eq, Hash)]
318318
pub struct Test {
319-
pub compiler: Compiler,
320319
pub target: Interned<String>,
320+
pub compiler: Compiler,
321321
}
322322

323323
impl Step for Test {
@@ -430,10 +430,10 @@ impl Step for TestLink {
430430
}
431431
}
432432

433-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
433+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, PartialEq, Eq, Hash)]
434434
pub struct Rustc {
435-
pub compiler: Compiler,
436435
pub target: Interned<String>,
436+
pub compiler: Compiler,
437437
}
438438

439439
impl Step for Rustc {
@@ -840,7 +840,7 @@ impl Step for Sysroot {
840840
}
841841
}
842842

843-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
843+
#[derive(Debug, Copy, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)]
844844
pub struct Assemble {
845845
/// The compiler which we will produce in this step. Assemble itself will
846846
/// take care of ensuring that the necessary prerequisites to do so exist,

src/bootstrap/dist.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn rust_installer(builder: &Builder) -> Command {
6161
builder.tool_cmd(Tool::RustInstaller)
6262
}
6363

64-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
64+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
6565
pub struct Docs {
6666
pub stage: u32,
6767
pub host: Interned<String>,
@@ -320,9 +320,9 @@ fn make_win_dist(
320320
}
321321
}
322322

323-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
323+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
324324
pub struct Mingw {
325-
host: Interned<String>,
325+
pub host: Interned<String>,
326326
}
327327

328328
impl Step for Mingw {
@@ -378,7 +378,7 @@ impl Step for Mingw {
378378
}
379379
}
380380

381-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
381+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
382382
pub struct Rustc {
383383
pub compiler: Compiler,
384384
}
@@ -607,7 +607,7 @@ impl Step for DebuggerScripts {
607607
}
608608
}
609609

610-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
610+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
611611
pub struct Std {
612612
pub compiler: Compiler,
613613
pub target: Interned<String>,
@@ -800,7 +800,7 @@ fn copy_src_dirs(build: &Build, src_dirs: &[&str], exclude_dirs: &[&str], dst_di
800800
}
801801
}
802802

803-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
803+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
804804
pub struct Src;
805805

806806
impl Step for Src {
@@ -894,7 +894,7 @@ impl Step for Src {
894894

895895
const CARGO_VENDOR_VERSION: &str = "0.1.4";
896896

897-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
897+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
898898
pub struct PlainSourceTarball;
899899

900900
impl Step for PlainSourceTarball {
@@ -1048,7 +1048,7 @@ fn write_file(path: &Path, data: &[u8]) {
10481048
t!(vf.write_all(data));
10491049
}
10501050

1051-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
1051+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
10521052
pub struct Cargo {
10531053
pub stage: u32,
10541054
pub target: Interned<String>,
@@ -1135,7 +1135,7 @@ impl Step for Cargo {
11351135
}
11361136
}
11371137

1138-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
1138+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
11391139
pub struct Rls {
11401140
pub stage: u32,
11411141
pub target: Interned<String>,
@@ -1216,7 +1216,7 @@ impl Step for Rls {
12161216
}
12171217

12181218

1219-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
1219+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
12201220
pub struct Rustfmt {
12211221
pub stage: u32,
12221222
pub target: Interned<String>,
@@ -1298,7 +1298,7 @@ impl Step for Rustfmt {
12981298
}
12991299
}
13001300

1301-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
1301+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
13021302
pub struct Extended {
13031303
stage: u32,
13041304
host: Interned<String>,
@@ -1731,7 +1731,7 @@ fn add_env(build: &Build, cmd: &mut Command, target: Interned<String>) {
17311731
}
17321732
}
17331733

1734-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
1734+
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
17351735
pub struct HashSign;
17361736

17371737
impl Step for HashSign {

src/bootstrap/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ use toolstate::ToolState;
198198
/// Each compiler has a `stage` that it is associated with and a `host` that
199199
/// corresponds to the platform the compiler runs on. This structure is used as
200200
/// a parameter to many methods below.
201-
#[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)]
201+
#[derive(Eq, PartialOrd, Ord, PartialEq, Clone, Copy, Hash, Debug)]
202202
pub struct Compiler {
203203
stage: u32,
204204
host: Interned<String>,

0 commit comments

Comments
 (0)