Skip to content

Commit

Permalink
Change how standard_lib tests work
Browse files Browse the repository at this point in the history
* Minimize the sysroot crates in play
* Don't use build scripts to inject args
* Use `RUSTC_WRAPPER` to dynamically switch `--sysroot` depending on
  whether we're building sysroot crates or not.
* Minimize dependency graph in sysroot, only have each crate depend on a
  dummy crates.io crate for testing and otherwise don't depend on
  anything to load the desired sysroot crate directly.
  • Loading branch information
alexcrichton committed Sep 23, 2019
1 parent 1ed8760 commit dead4d0
Show file tree
Hide file tree
Showing 17 changed files with 199 additions and 127 deletions.
9 changes: 4 additions & 5 deletions tests/testsuite/mock-std/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[workspace]
members = [
"src/liballoc",
"src/libcore",
"src/libproc_macro",
"src/libstd",
"src/libtest",
]

[patch.crates-io]
rustc-std-workspace-std = { path = 'src/tools/rustc-std-workspace-std' }
rustc-std-workspace-core = { path = 'src/tools/rustc-std-workspace-core' }
rustc-std-workspace-alloc = { path = 'src/tools/rustc-std-workspace-alloc' }
2 changes: 1 addition & 1 deletion tests/testsuite/mock-std/src/liballoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ edition = "2018"
path = "lib.rs"

[dependencies]
core = { path = "../libcore" }
registry-dep-using-core = { version = "*", features = ['mockbuild'] }
12 changes: 11 additions & 1 deletion tests/testsuite/mock-std/src/liballoc/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
pub fn custom_api() {}
#![feature(staged_api)]
#![stable(since = "1.0.0", feature = "dummy")]

extern crate alloc;

#[stable(since = "1.0.0", feature = "dummy")]
pub use alloc::*;

#[stable(since = "1.0.0", feature = "dummy")]
pub fn custom_api() {
}
3 changes: 0 additions & 3 deletions tests/testsuite/mock-std/src/libcompiler_builtins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ edition = "2018"

[lib]
path = "lib.rs"

[dependencies]
core = { path = "../libcore" }
23 changes: 0 additions & 23 deletions tests/testsuite/mock-std/src/libcore/build.rs

This file was deleted.

9 changes: 7 additions & 2 deletions tests/testsuite/mock-std/src/libcore/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#![no_std]
#![feature(staged_api)]
#![stable(since = "1.0.0", feature = "dummy")]

#[stable(since = "1.0.0", feature = "dummy")]
pub use core::*;

pub fn custom_api() {}
#[stable(since = "1.0.0", feature = "dummy")]
pub fn custom_api() {
}
3 changes: 0 additions & 3 deletions tests/testsuite/mock-std/src/libpanic_unwind/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ edition = "2018"

[lib]
path = "lib.rs"

[dependencies]
core = { path = "../libcore" }
3 changes: 0 additions & 3 deletions tests/testsuite/mock-std/src/libproc_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ edition = "2018"

[lib]
path = "lib.rs"

[dependencies]
std = { path = "../libstd" }
10 changes: 9 additions & 1 deletion tests/testsuite/mock-std/src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#![feature(staged_api)]
#![stable(since = "1.0.0", feature = "dummy")]

extern crate proc_macro;

#[stable(since = "1.0.0", feature = "dummy")]
pub use proc_macro::*;
pub fn custom_api() {}

#[stable(since = "1.0.0", feature = "dummy")]
pub fn custom_api() {
}
6 changes: 1 addition & 5 deletions tests/testsuite/mock-std/src/libstd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ edition = "2018"
path = "lib.rs"

[dependencies]
core = { path = "../libcore" }
compiler_builtins = { path = "../libcompiler_builtins" }
panic_unwind = { path = "../libpanic_unwind" }
registry-dep-using-core = { version = "1.0", features = ['mockbuild'] }
registry-dep-using-alloc = { version = "1.0", features = ['mockbuild'] }
registry-dep-using-alloc = { version = "*", features = ['mockbuild'] }
7 changes: 5 additions & 2 deletions tests/testsuite/mock-std/src/libstd/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#![feature(staged_api)]
#![stable(since = "1.0.0", feature = "dummy")]

#[stable(since = "1.0.0", feature = "dummy")]
pub use std::*;

#[stable(since = "1.0.0", feature = "dummy")]
pub fn custom_api() {
registry_dep_using_core::custom_api();
registry_dep_using_alloc::custom_api();
}
5 changes: 3 additions & 2 deletions tests/testsuite/mock-std/src/libtest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ path = "lib.rs"

[dependencies]
proc_macro = { path = "../libproc_macro" }
registry-dep-using-std = { version = "1.0", features = ['mockbuild'] }
std = { path = "../libstd" }
panic_unwind = { path = "../libpanic_unwind" }
compiler_builtins = { path = "../libcompiler_builtins" }
registry-dep-using-std = { version = "*", features = ['mockbuild'] }

[features]
panic-unwind = []
Expand Down
3 changes: 2 additions & 1 deletion tests/testsuite/mock-std/src/libtest/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#![feature(staged_api)]
#![feature(test)]
#![unstable(feature = "test", issue = "0")]

extern crate test;

pub use test::*;

pub fn custom_api() {
registry_dep_using_std::custom_api();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ authors = ["Alex Crichton <alex@alexcrichton.com>"]
edition = "2018"

[lib]
name = "alloc"
path = "lib.rs"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ authors = ["Alex Crichton <alex@alexcrichton.com>"]
edition = "2018"

[lib]
name = "core"
path = "lib.rs"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ authors = ["Alex Crichton <alex@alexcrichton.com>"]
edition = "2018"

[lib]
name = "std"
path = "lib.rs"

[dependencies]
Expand Down
Loading

0 comments on commit dead4d0

Please sign in to comment.