Skip to content

Commit e7df5b0

Browse files
committed
Auto merge of #139443 - Zalathar:rollup-c54pncs, r=Zalathar
Rollup of 3 pull requests Successful merges: - #139123 (tidy: Fix paths to `coretests` and `alloctests`) - #139347 (Only build `rust_test_helpers` for `{incremental,ui}` test suites) - #139438 (Prevent a test from seeing forbidden numbers in the rustc version) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1de9312 + f4aa209 commit e7df5b0

File tree

5 files changed

+46
-32
lines changed

5 files changed

+46
-32
lines changed

library/core/src/fmt/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3017,6 +3017,6 @@ impl<T: ?Sized> Debug for SyncUnsafeCell<T> {
30173017
}
30183018
}
30193019

3020-
// If you expected tests to be here, look instead at the core/tests/fmt.rs file,
3020+
// If you expected tests to be here, look instead at coretests/tests/fmt/;
30213021
// it's a lot easier than creating all of the rt::Piece structures here.
3022-
// There are also tests in the alloc crate, for those that need allocations.
3022+
// There are also tests in alloctests/tests/fmt.rs, for those that need allocations.

library/coretests/tests/str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
// All `str` tests live in library/alloc/tests/str.rs
1+
// All `str` tests live in library/alloctests/tests/str.rs

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

+9-10
Original file line numberDiff line numberDiff line change
@@ -1624,21 +1624,13 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
16241624
builder.tool_exe(Tool::RunMakeSupport);
16251625
}
16261626

1627-
// Also provide `rust_test_helpers` for the host.
1628-
builder.ensure(TestHelpers { target: compiler.host });
1629-
16301627
// ensure that `libproc_macro` is available on the host.
16311628
if suite == "mir-opt" {
16321629
builder.ensure(compile::Std::new(compiler, compiler.host).is_for_mir_opt_tests(true));
16331630
} else {
16341631
builder.ensure(compile::Std::new(compiler, compiler.host));
16351632
}
16361633

1637-
// As well as the target
1638-
if suite != "mir-opt" {
1639-
builder.ensure(TestHelpers { target });
1640-
}
1641-
16421634
let mut cmd = builder.tool_cmd(Tool::Compiletest);
16431635

16441636
if suite == "mir-opt" {
@@ -1804,11 +1796,18 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
18041796
}
18051797

18061798
let mut hostflags = flags.clone();
1807-
hostflags.push(format!("-Lnative={}", builder.test_helpers_out(compiler.host).display()));
18081799
hostflags.extend(linker_flags(builder, compiler.host, LldThreads::No, compiler.stage));
18091800

18101801
let mut targetflags = flags;
1811-
targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display()));
1802+
1803+
// Provide `rust_test_helpers` for both host and target.
1804+
if suite == "ui" || suite == "incremental" {
1805+
builder.ensure(TestHelpers { target: compiler.host });
1806+
builder.ensure(TestHelpers { target });
1807+
hostflags
1808+
.push(format!("-Lnative={}", builder.test_helpers_out(compiler.host).display()));
1809+
targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display()));
1810+
}
18121811

18131812
for flag in hostflags {
18141813
cmd.arg("--host-rustcflags").arg(flag);

src/tools/tidy/src/unit_tests.rs

+32-19
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
//! Tidy check to ensure `#[test]` and `#[bench]` are not used directly inside `core`.
1+
//! Tidy check to ensure `#[test]` and `#[bench]` are not used directly inside
2+
//! `core` or `alloc`.
23
//!
3-
//! `#![no_core]` libraries cannot be tested directly due to duplicating lang
4-
//! items. All tests and benchmarks must be written externally in `core/{tests,benches}`.
4+
//! `core` and `alloc` cannot be tested directly due to duplicating lang items.
5+
//! All tests and benchmarks must be written externally in
6+
//! `{coretests,alloctests}/{tests,benches}`.
57
//!
6-
//! Outside of core tests and benchmarks should be outlined into separate files
7-
//! named `tests.rs` or `benches.rs`, or directories named `tests` or `benches` unconfigured
8-
//! during normal build.
8+
//! Outside of `core` and `alloc`, tests and benchmarks should be outlined into
9+
//! separate files named `tests.rs` or `benches.rs`, or directories named
10+
//! `tests` or `benches` unconfigured during normal build.
911
1012
use std::path::Path;
1113

@@ -14,40 +16,51 @@ use crate::walk::{filter_dirs, walk};
1416
pub fn check(root_path: &Path, bad: &mut bool) {
1517
let core = root_path.join("core");
1618
let core_copy = core.clone();
17-
let core_tests = core.join("tests");
18-
let core_benches = core.join("benches");
19-
let is_core = move |path: &Path| {
20-
path.starts_with(&core)
21-
&& !(path.starts_with(&core_tests) || path.starts_with(&core_benches))
22-
};
19+
let is_core = move |path: &Path| path.starts_with(&core);
20+
let alloc = root_path.join("alloc");
21+
let alloc_copy = alloc.clone();
22+
let is_alloc = move |path: &Path| path.starts_with(&alloc);
2323

2424
let skip = move |path: &Path, is_dir| {
2525
let file_name = path.file_name().unwrap_or_default();
2626
if is_dir {
2727
filter_dirs(path)
2828
|| path.ends_with("src/doc")
29-
|| (file_name == "tests" || file_name == "benches") && !is_core(path)
29+
|| (file_name == "tests" || file_name == "benches")
30+
&& !is_core(path)
31+
&& !is_alloc(path)
3032
} else {
3133
let extension = path.extension().unwrap_or_default();
3234
extension != "rs"
33-
|| (file_name == "tests.rs" || file_name == "benches.rs") && !is_core(path)
34-
// UI tests with different names
35-
|| path.ends_with("src/thread/local/dynamic_tests.rs")
36-
|| path.ends_with("src/sync/mpsc/sync_tests.rs")
35+
|| (file_name == "tests.rs" || file_name == "benches.rs")
36+
&& !is_core(path)
37+
&& !is_alloc(path)
38+
// Tests which use non-public internals and, as such, need to
39+
// have the types in the same crate as the tests themselves. See
40+
// the comment in alloctests/lib.rs.
41+
|| path.ends_with("library/alloc/src/collections/btree/borrow/tests.rs")
42+
|| path.ends_with("library/alloc/src/collections/btree/map/tests.rs")
43+
|| path.ends_with("library/alloc/src/collections/btree/node/tests.rs")
44+
|| path.ends_with("library/alloc/src/collections/btree/set/tests.rs")
45+
|| path.ends_with("library/alloc/src/collections/linked_list/tests.rs")
46+
|| path.ends_with("library/alloc/src/collections/vec_deque/tests.rs")
47+
|| path.ends_with("library/alloc/src/raw_vec/tests.rs")
3748
}
3849
};
3950

4051
walk(root_path, skip, &mut |entry, contents| {
4152
let path = entry.path();
4253
let is_core = path.starts_with(&core_copy);
54+
let is_alloc = path.starts_with(&alloc_copy);
4355
for (i, line) in contents.lines().enumerate() {
4456
let line = line.trim();
4557
let is_test = || line.contains("#[test]") && !line.contains("`#[test]");
4658
let is_bench = || line.contains("#[bench]") && !line.contains("`#[bench]");
4759
if !line.starts_with("//") && (is_test() || is_bench()) {
4860
let explanation = if is_core {
49-
"core unit tests and benchmarks must be placed into \
50-
`core/tests` or `core/benches`"
61+
"`core` unit tests and benchmarks must be placed into `coretests`"
62+
} else if is_alloc {
63+
"`alloc` unit tests and benchmarks must be placed into `alloctests`"
5164
} else {
5265
"unit tests and benchmarks must be placed into \
5366
separate files or directories named \

tests/codegen/issues/issue-122600-ptr-discriminant-update.rs

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ pub unsafe fn update(s: *mut State) {
3636
// CHECK-NOT: store
3737
// CHECK-NOT: memcpy
3838
// CHECK-NOT: 75{{3|4}}
39+
40+
// CHECK: ret
3941
let State::A(v) = s.read() else { std::hint::unreachable_unchecked() };
4042
s.write(State::B(v));
4143
}

0 commit comments

Comments
 (0)