Skip to content

Commit e9ec381

Browse files
authored
Merge pull request #4248 from RalfJung/edition-2024
bump parts of test-cargo-miri to edition 2024
2 parents 0e359e3 + c4f60ab commit e9ec381

13 files changed

+59
-44
lines changed

test-cargo-miri/Cargo.lock

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

test-cargo-miri/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ exclude = ["no-std-smoke"] # it wants to be panic="abort"
66
name = "cargo-miri-test"
77
version = "0.1.0"
88
authors = ["Miri Team"]
9-
edition = "2018"
9+
edition = "2024"
1010

1111
[dependencies]
1212
byteorder = "1.0"

test-cargo-miri/run-test.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def test_cargo_miri_run():
136136
cargo_miri("run") + ["--target-dir=custom-run", "--", "--target-dir=target/custom-run"],
137137
"run.args.stdout.ref", "run.custom-target-dir.stderr.ref",
138138
)
139-
test("`cargo miri run --package=test-local-crate-detection` (test local crate detection)",
139+
test("`cargo miri run` (test local crate detection)",
140140
cargo_miri("run") + ["--package=test-local-crate-detection"],
141141
"run.local_crate.stdout.ref", "run.local_crate.stderr.ref",
142142
)
@@ -149,43 +149,44 @@ def test_cargo_miri_test():
149149

150150
test("`cargo miri test`",
151151
cargo_miri("test"),
152-
default_ref, "test.stderr-empty.ref",
152+
default_ref, "test.empty.ref",
153153
env={'MIRIFLAGS': "-Zmiri-seed=4242"},
154154
)
155155
test("`cargo miri test` (no isolation, no doctests)",
156156
cargo_miri("test") + ["--bins", "--tests"], # no `--lib`, we disabled that in `Cargo.toml`
157-
"test.cross-target.stdout.ref", "test.stderr-empty.ref",
157+
"test.cross-target.stdout.ref", "test.empty.ref",
158158
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
159159
)
160160
test("`cargo miri test` (with filter)",
161161
cargo_miri("test") + ["--", "--format=pretty", "pl"],
162-
filter_ref, "test.stderr-empty.ref",
162+
filter_ref, "test.empty.ref",
163163
)
164164
test("`cargo miri test` (test target)",
165165
cargo_miri("test") + ["--test", "test", "--", "--format=pretty"],
166-
"test.test-target.stdout.ref", "test.stderr-empty.ref",
166+
"test.test-target.stdout.ref", "test.empty.ref",
167167
)
168168
test("`cargo miri test` (bin target)",
169169
cargo_miri("test") + ["--bin", "cargo-miri-test", "--", "--format=pretty"],
170-
"test.bin-target.stdout.ref", "test.stderr-empty.ref",
170+
"test.bin-target.stdout.ref", "test.empty.ref",
171171
)
172172
test("`cargo miri t` (subcrate, no isolation)",
173173
cargo_miri("t") + ["-p", "subcrate"],
174-
"test.subcrate.stdout.ref", "test.stderr-proc-macro.ref",
174+
"test.subcrate.cross-target.stdout.ref" if is_foreign else "test.subcrate.stdout.ref",
175+
"test.empty.ref",
175176
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
176177
)
177-
test("`cargo miri test` (subcrate, doctests)",
178-
cargo_miri("test") + ["-p", "subcrate", "--doc"],
179-
"test.stdout-empty.ref", "test.stderr-proc-macro-doctest.ref",
178+
test("`cargo miri test` (proc-macro crate)",
179+
cargo_miri("test") + ["-p", "proc_macro_crate"],
180+
"test.empty.ref", "test.proc-macro.stderr.ref",
180181
)
181182
test("`cargo miri test` (custom target dir)",
182183
cargo_miri("test") + ["--target-dir=custom-test"],
183-
default_ref, "test.stderr-empty.ref",
184+
default_ref, "test.empty.ref",
184185
)
185186
del os.environ["CARGO_TARGET_DIR"] # this overrides `build.target-dir` passed by `--config`, so unset it
186187
test("`cargo miri test` (config-cli)",
187188
cargo_miri("test") + ["--config=build.target-dir=\"config-cli\""],
188-
default_ref, "test.stderr-empty.ref",
189+
default_ref, "test.empty.ref",
189190
)
190191
if ARGS.multi_target:
191192
test_cargo_miri_multi_target()
@@ -194,7 +195,7 @@ def test_cargo_miri_test():
194195
def test_cargo_miri_multi_target():
195196
test("`cargo miri test` (multiple targets)",
196197
cargo_miri("test", targets = ["aarch64-unknown-linux-gnu", "s390x-unknown-linux-gnu"]),
197-
"test.multiple_targets.stdout.ref", "test.stderr-empty.ref",
198+
"test.multiple_targets.stdout.ref", "test.empty.ref",
198199
)
199200

200201
args_parser = argparse.ArgumentParser(description='`cargo miri` testing')

test-cargo-miri/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
///
2727
/// let _val = Fail::<i32>::C;
2828
/// ```
29-
#[no_mangle]
29+
// This is imported in `main.rs`.
30+
#[unsafe(no_mangle)]
3031
pub fn make_true() -> bool {
3132
proc_macro_crate::use_the_dependency!();
3233
issue_1567::use_the_dependency();

test-cargo-miri/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn main() {
3030
let mut out = Vec::with_capacity(1024);
3131

3232
unsafe {
33-
extern "Rust" {
33+
unsafe extern "Rust" {
3434
fn miri_host_to_target_path(
3535
path: *const c_char,
3636
out: *mut c_char,
@@ -81,7 +81,7 @@ mod test {
8181
// Test calling exported symbols in (transitive) dependencies.
8282
// Repeat calls to make sure the `Instance` cache is not broken.
8383
for _ in 0..3 {
84-
extern "Rust" {
84+
unsafe extern "Rust" {
8585
fn exported_symbol() -> i32;
8686
fn assoc_fn_as_exported_symbol() -> i32;
8787
fn make_true() -> bool;

test-cargo-miri/subcrate/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
name = "subcrate"
33
version = "0.1.0"
44
authors = ["Miri Team"]
5+
# This is deliberately *not* on the 2024 edition to ensure doctests keep working
6+
# on old editions.
57
edition = "2018"
68

79
[lib]
8-
proc-macro = true
9-
doctest = false
1010

1111
[[bin]]
1212
name = "subcrate"

test-cargo-miri/subcrate/src/lib.rs

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
// This is a proc-macro crate.
2-
3-
extern crate proc_macro; // make sure proc_macro is in the sysroot
4-
5-
#[cfg(doctest)]
6-
compile_error!("rustdoc should not touch me");
7-
8-
#[cfg(miri)]
9-
compile_error!("Miri should not touch me");
10-
11-
use proc_macro::TokenStream;
12-
13-
#[proc_macro]
14-
pub fn make_answer(_item: TokenStream) -> TokenStream {
15-
"fn answer() -> u32 { 42 }".parse().unwrap()
1+
/// Doc-test test
2+
///
3+
/// ```rust
4+
/// assert!(subcrate::make_true());
5+
/// ```
6+
pub fn make_true() -> bool {
7+
true
168
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
Running unit tests of `proc-macro` crates is not currently supported by Miri.
2+
Running doctests of `proc-macro` crates is not currently supported by Miri.

test-cargo-miri/test.stderr-proc-macro-doctest.ref

-1
This file was deleted.

test-cargo-miri/test.stdout-empty.ref

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
running 0 tests
3+
4+
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
5+
6+
7+
running 0 tests
8+
9+
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
10+
11+
subcrate testing
+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11

2+
running 0 tests
3+
4+
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
5+
6+
27
running 0 tests
38

49
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
510

611
subcrate testing
12+
13+
running 1 test
14+
.
15+
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
16+

0 commit comments

Comments
 (0)