Move all alloc integration tests to a new alloctests crate

This commit is contained in:
bjorn3 2025-02-06 11:38:59 +00:00
parent 03eb454523
commit fb04372dc5
58 changed files with 73 additions and 25 deletions

View file

@ -40,6 +40,14 @@ version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]]
name = "alloctests"
version = "0.0.0"
dependencies = [
"rand",
"rand_xorshift",
]
[[package]]
name = "cc"
version = "1.2.0"

View file

@ -4,6 +4,7 @@ members = [
"std",
"sysroot",
"coretests",
"alloctests",
]
exclude = [

View file

@ -18,24 +18,6 @@ compiler_builtins = { version = "=0.1.151", features = ['rustc-dep-of-std'] }
rand = { version = "0.9.0", default-features = false, features = ["alloc"] }
rand_xorshift = "0.4.0"
[[test]]
name = "alloctests"
path = "tests/lib.rs"
[[test]]
name = "vec_deque_alloc_error"
path = "tests/vec_deque_alloc_error.rs"
[[bench]]
name = "allocbenches"
path = "benches/lib.rs"
test = true
[[bench]]
name = "vec_deque_append_bench"
path = "benches/vec_deque_append.rs"
harness = false
[features]
compiler-builtins-mem = ['compiler_builtins/mem']
compiler-builtins-c = ["compiler_builtins/c"]

View file

@ -0,0 +1,46 @@
[package]
name = "alloctests"
version = "0.0.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/rust.git"
description = "Tests for the Rust Allocation Library"
autotests = false
autobenches = false
edition = "2021"
[lib]
path = "lib.rs"
test = false
bench = false
[dev-dependencies]
rand = { version = "0.9.0", default-features = false, features = ["alloc"] }
rand_xorshift = "0.4.0"
[[test]]
name = "alloctests"
path = "tests/lib.rs"
[[test]]
name = "vec_deque_alloc_error"
path = "tests/vec_deque_alloc_error.rs"
[[bench]]
name = "allocbenches"
path = "benches/lib.rs"
test = true
[[bench]]
name = "vec_deque_append_bench"
path = "benches/vec_deque_append.rs"
harness = false
[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(bootstrap)',
'cfg(no_global_oom_handling)',
'cfg(no_rc)',
'cfg(no_sync)',
'cfg(randomized_layouts)',
]

View file

@ -0,0 +1 @@
// Intentionally left empty.

View file

@ -43,11 +43,12 @@
#![deny(fuzzy_provenance_casts)]
#![deny(unsafe_op_in_unsafe_fn)]
extern crate alloc;
extern crate test;
use std::hash::{DefaultHasher, Hash, Hasher};
mod alloc;
mod alloc_test;
mod arc;
mod autotraits;
mod borrow;

View file

@ -56,6 +56,7 @@ check-aux:
# Run standard library tests in Miri.
$(Q)$(BOOTSTRAP) miri --stage 2 \
library/coretests \
library/alloctests \
library/alloc \
$(BOOTSTRAP_ARGS) \
--no-doc
@ -63,6 +64,7 @@ check-aux:
$(Q)MIRIFLAGS="-Zmiri-disable-isolation" \
$(BOOTSTRAP) miri --stage 2 \
library/coretests \
library/alloctests \
library/alloc \
$(BOOTSTRAP_ARGS) \
--doc

View file

@ -45,7 +45,10 @@ impl Step for Std {
const DEFAULT: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.crate_or_deps("sysroot").crate_or_deps("coretests").path("library")
run.crate_or_deps("sysroot")
.crate_or_deps("coretests")
.crate_or_deps("alloctests")
.path("library")
}
fn make_run(run: RunConfig<'_>) {

View file

@ -2609,7 +2609,7 @@ impl Step for Crate {
const DEFAULT: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.crate_or_deps("sysroot").crate_or_deps("coretests")
run.crate_or_deps("sysroot").crate_or_deps("coretests").crate_or_deps("alloctests")
}
fn make_run(run: RunConfig<'_>) {
@ -2724,12 +2724,16 @@ impl Step for Crate {
};
let mut crates = self.crates.clone();
// The core crate can't directly be tested. We could silently
// ignore it, but adding it's own test crate is less confusing
// for users. We still keep core itself for doctests.
// The core and alloc crates can't directly be tested. We
// could silently ignore them, but adding their own test
// crates is less confusing for users. We still keep core and
// alloc themself for doctests
if crates.iter().any(|crate_| crate_ == "core") {
crates.push("coretests".to_owned());
}
if crates.iter().any(|crate_| crate_ == "alloc") {
crates.push("alloctests".to_owned());
}
run_cargo_test(cargo, &[], &crates, &*crate_description(&self.crates), target, builder);
}

View file

@ -475,7 +475,7 @@ pub fn check(path: &Path, bad: &mut bool) {
&& !trimmed.starts_with("//")
&& !file.ancestors().any(|a| {
(a.ends_with("tests") && a.join("COMPILER_TESTS.md").exists())
|| a.ends_with("library/alloc/tests")
|| a.ends_with("library/alloctests")
})
&& filename != "tests.rs"
{