Skip to content

Commit 67ec627

Browse files
committed
Auto merge of rust-lang#135937 - bjorn3:separate_coretests_crate, r=jieyouxu,tgross35
Put the core unit tests in a separate coretests package Having standard library tests in the same package as a standard library crate has bad side effects. It causes the test to have a dependency on a locally built standard library crate, while also indirectly depending on it through libtest. Currently this works out fine in the context of rust's build system as both copies are identical, but for example in cg_clif's tests I've found it basically impossible to compile both copies with the exact same compiler flags and thus the two copies would cause lang item conflicts. This PR moves the tests of libcore to a separate package which doesn't depend on libcore, thus preventing the duplicate crates even when compiler flags don't exactly match between building the sysroot (for libtest) and building the test itself. The rest of the standard library crates do still have this issue however.
2 parents 68f6b01 + 2178568 commit 67ec627

File tree

161 files changed

+37
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+37
-17
lines changed

Cargo.lock

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ resolver = "1"
33
members = [
44
"std",
55
"sysroot",
6+
"coretests",
67
]
78

89
exclude = [

core/Cargo.toml

-13
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,6 @@ edition = "2021"
1515
test = false
1616
bench = false
1717

18-
[[test]]
19-
name = "coretests"
20-
path = "tests/lib.rs"
21-
22-
[[bench]]
23-
name = "corebenches"
24-
path = "benches/lib.rs"
25-
test = true
26-
27-
[dev-dependencies]
28-
rand = { version = "0.8.5", default-features = false }
29-
rand_xorshift = { version = "0.3.0", default-features = false }
30-
3118
[features]
3219
# Make panics and failed asserts immediately abort without formatting any message
3320
panic_immediate_abort = []

core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
//! called. The `lang` attribute is called `eh_personality`.
4545
4646
// Since core defines many fundamental lang items, all tests live in a
47-
// separate crate, libcoretest (library/core/tests), to avoid bizarre issues.
47+
// separate crate, coretests (library/coretests), to avoid bizarre issues.
4848
//
4949
// Here we explicitly #[cfg]-out this whole crate when testing. If we don't do
5050
// this, both the generated test artifact and the linked libtest (which

coretests/Cargo.toml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[package]
2+
name = "coretests"
3+
version = "0.0.0"
4+
license = "MIT OR Apache-2.0"
5+
repository = "https://github.com/rust-lang/rust.git"
6+
description = "Tests for the Rust Core Library"
7+
autotests = false
8+
autobenches = false
9+
edition = "2021"
10+
11+
[lib]
12+
path = "lib.rs"
13+
test = false
14+
bench = false
15+
16+
[[test]]
17+
name = "coretests"
18+
path = "tests/lib.rs"
19+
20+
[[bench]]
21+
name = "corebenches"
22+
path = "benches/lib.rs"
23+
test = true
24+
25+
[dev-dependencies]
26+
rand = { version = "0.8.5", default-features = false }
27+
rand_xorshift = { version = "0.3.0", default-features = false }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

coretests/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Intentionally left empty.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

core/tests/bstr.rs renamed to coretests/tests/bstr.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#![feature(bstr)]
2-
3-
use core::ByteStr;
1+
use core::bstr::ByteStr;
42

53
#[test]
64
fn test_debug() {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

core/tests/lib.rs renamed to coretests/tests/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![feature(async_iter_from_iter)]
1212
#![feature(async_iterator)]
1313
#![feature(bigint_helper_methods)]
14+
#![feature(bstr)]
1415
#![feature(cell_update)]
1516
#![feature(clone_to_uninit)]
1617
#![feature(const_black_box)]
@@ -139,6 +140,7 @@ mod asserting;
139140
mod async_iter;
140141
mod atomic;
141142
mod bool;
143+
mod bstr;
142144
mod cell;
143145
mod char;
144146
mod clone;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)