Skip to content

Commit fb04372

Browse files
committed
Move all alloc integration tests to a new alloctests crate
1 parent 03eb454 commit fb04372

Some content is hidden

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

58 files changed

+73
-25
lines changed

library/Cargo.lock

+8
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ version = "0.2.21"
4040
source = "registry+https://github.com/rust-lang/crates.io-index"
4141
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
4242

43+
[[package]]
44+
name = "alloctests"
45+
version = "0.0.0"
46+
dependencies = [
47+
"rand",
48+
"rand_xorshift",
49+
]
50+
4351
[[package]]
4452
name = "cc"
4553
version = "1.2.0"

library/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ members = [
44
"std",
55
"sysroot",
66
"coretests",
7+
"alloctests",
78
]
89

910
exclude = [

library/alloc/Cargo.toml

-18
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,6 @@ compiler_builtins = { version = "=0.1.151", features = ['rustc-dep-of-std'] }
1818
rand = { version = "0.9.0", default-features = false, features = ["alloc"] }
1919
rand_xorshift = "0.4.0"
2020

21-
[[test]]
22-
name = "alloctests"
23-
path = "tests/lib.rs"
24-
25-
[[test]]
26-
name = "vec_deque_alloc_error"
27-
path = "tests/vec_deque_alloc_error.rs"
28-
29-
[[bench]]
30-
name = "allocbenches"
31-
path = "benches/lib.rs"
32-
test = true
33-
34-
[[bench]]
35-
name = "vec_deque_append_bench"
36-
path = "benches/vec_deque_append.rs"
37-
harness = false
38-
3921
[features]
4022
compiler-builtins-mem = ['compiler_builtins/mem']
4123
compiler-builtins-c = ["compiler_builtins/c"]
File renamed without changes.
File renamed without changes.

library/alloctests/Cargo.toml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[package]
2+
name = "alloctests"
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 Allocation 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+
[dev-dependencies]
17+
rand = { version = "0.9.0", default-features = false, features = ["alloc"] }
18+
rand_xorshift = "0.4.0"
19+
20+
[[test]]
21+
name = "alloctests"
22+
path = "tests/lib.rs"
23+
24+
[[test]]
25+
name = "vec_deque_alloc_error"
26+
path = "tests/vec_deque_alloc_error.rs"
27+
28+
[[bench]]
29+
name = "allocbenches"
30+
path = "benches/lib.rs"
31+
test = true
32+
33+
[[bench]]
34+
name = "vec_deque_append_bench"
35+
path = "benches/vec_deque_append.rs"
36+
harness = false
37+
38+
[lints.rust.unexpected_cfgs]
39+
level = "warn"
40+
check-cfg = [
41+
'cfg(bootstrap)',
42+
'cfg(no_global_oom_handling)',
43+
'cfg(no_rc)',
44+
'cfg(no_sync)',
45+
'cfg(randomized_layouts)',
46+
]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

library/alloctests/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.

library/alloc/tests/lib.rs renamed to library/alloctests/tests/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@
4343
#![deny(fuzzy_provenance_casts)]
4444
#![deny(unsafe_op_in_unsafe_fn)]
4545

46+
extern crate alloc;
4647
extern crate test;
4748

4849
use std::hash::{DefaultHasher, Hash, Hasher};
4950

50-
mod alloc;
51+
mod alloc_test;
5152
mod arc;
5253
mod autotraits;
5354
mod borrow;
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.

src/bootstrap/mk/Makefile.in

+2
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ check-aux:
5656
# Run standard library tests in Miri.
5757
$(Q)$(BOOTSTRAP) miri --stage 2 \
5858
library/coretests \
59+
library/alloctests \
5960
library/alloc \
6061
$(BOOTSTRAP_ARGS) \
6162
--no-doc
6263
# Some doctests use file system operations to demonstrate dealing with `Result`.
6364
$(Q)MIRIFLAGS="-Zmiri-disable-isolation" \
6465
$(BOOTSTRAP) miri --stage 2 \
6566
library/coretests \
67+
library/alloctests \
6668
library/alloc \
6769
$(BOOTSTRAP_ARGS) \
6870
--doc

src/bootstrap/src/core/build_steps/check.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ impl Step for Std {
4545
const DEFAULT: bool = true;
4646

4747
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
48-
run.crate_or_deps("sysroot").crate_or_deps("coretests").path("library")
48+
run.crate_or_deps("sysroot")
49+
.crate_or_deps("coretests")
50+
.crate_or_deps("alloctests")
51+
.path("library")
4952
}
5053

5154
fn make_run(run: RunConfig<'_>) {

src/bootstrap/src/core/build_steps/test.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -2609,7 +2609,7 @@ impl Step for Crate {
26092609
const DEFAULT: bool = true;
26102610

26112611
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2612-
run.crate_or_deps("sysroot").crate_or_deps("coretests")
2612+
run.crate_or_deps("sysroot").crate_or_deps("coretests").crate_or_deps("alloctests")
26132613
}
26142614

26152615
fn make_run(run: RunConfig<'_>) {
@@ -2724,12 +2724,16 @@ impl Step for Crate {
27242724
};
27252725

27262726
let mut crates = self.crates.clone();
2727-
// The core crate can't directly be tested. We could silently
2728-
// ignore it, but adding it's own test crate is less confusing
2729-
// for users. We still keep core itself for doctests.
2727+
// The core and alloc crates can't directly be tested. We
2728+
// could silently ignore them, but adding their own test
2729+
// crates is less confusing for users. We still keep core and
2730+
// alloc themself for doctests
27302731
if crates.iter().any(|crate_| crate_ == "core") {
27312732
crates.push("coretests".to_owned());
27322733
}
2734+
if crates.iter().any(|crate_| crate_ == "alloc") {
2735+
crates.push("alloctests".to_owned());
2736+
}
27332737

27342738
run_cargo_test(cargo, &[], &crates, &*crate_description(&self.crates), target, builder);
27352739
}

src/tools/tidy/src/style.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ pub fn check(path: &Path, bad: &mut bool) {
475475
&& !trimmed.starts_with("//")
476476
&& !file.ancestors().any(|a| {
477477
(a.ends_with("tests") && a.join("COMPILER_TESTS.md").exists())
478-
|| a.ends_with("library/alloc/tests")
478+
|| a.ends_with("library/alloctests")
479479
})
480480
&& filename != "tests.rs"
481481
{

0 commit comments

Comments
 (0)