Skip to content

Commit 9bfc167

Browse files
committed
rewrite incremental-session-fail to rmake
1 parent ab71510 commit 9bfc167

File tree

6 files changed

+52
-49
lines changed

6 files changed

+52
-49
lines changed

src/tools/run-make-support/src/lib.rs

+18-12
Original file line numberDiff line numberDiff line change
@@ -274,23 +274,29 @@ pub fn set_host_rpath(cmd: &mut Command) {
274274
/// Read the contents of a file that cannot simply be read by
275275
/// read_to_string, due to invalid utf8 data, then assert that it contains `expected`.
276276
#[track_caller]
277-
pub fn invalid_utf8_contains_str<P: AsRef<Path>>(path: P, expected: &str) {
278-
use std::io::Read;
279-
let mut file = std::fs::File::open(path).unwrap();
280-
let mut buffer = Vec::new();
281-
file.read_to_end(&mut buffer).unwrap();
282-
assert!(String::from_utf8_lossy(&buffer).contains(expected));
277+
pub fn invalid_utf8_contains<P: AsRef<Path>>(path: P, expected: &str) {
278+
let buffer = fs_wrapper::read(path.as_ref());
279+
if !String::from_utf8_lossy(&buffer).contains(expected) {
280+
eprintln!("=== FILE CONTENTS ===");
281+
eprintln!("{}", String::from_utf8_lossy(&buffer));
282+
eprintln!("=== SPECIFIED TEXT ===");
283+
eprintln!("{}", expected);
284+
panic!("specified text was not found in file");
285+
}
283286
}
284287

285288
/// Read the contents of a file that cannot simply be read by
286289
/// read_to_string, due to invalid utf8 data, then assert that it does not contain `expected`.
287290
#[track_caller]
288-
pub fn invalid_utf8_not_contains_str<P: AsRef<Path>>(path: P, expected: &str) {
289-
use std::io::Read;
290-
let mut file = std::fs::File::open(path).unwrap();
291-
let mut buffer = Vec::new();
292-
file.read_to_end(&mut buffer).unwrap();
293-
assert!(!String::from_utf8_lossy(&buffer).contains(expected));
291+
pub fn invalid_utf8_not_contains<P: AsRef<Path>>(path: P, expected: &str) {
292+
let buffer = fs_wrapper::read(path.as_ref());
293+
if String::from_utf8_lossy(&buffer).contains(expected) {
294+
eprintln!("=== FILE CONTENTS ===");
295+
eprintln!("{}", String::from_utf8_lossy(&buffer));
296+
eprintln!("=== SPECIFIED TEXT ===");
297+
eprintln!("{}", expected);
298+
panic!("specified text was unexpectedly found in file");
299+
}
294300
}
295301

296302
/// Copy a directory into another.

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ run-make/inaccessible-temp-dir/Makefile
6767
run-make/include_bytes_deps/Makefile
6868
run-make/incr-add-rust-src-component/Makefile
6969
run-make/incr-foreign-head-span/Makefile
70-
run-make/incremental-session-fail/Makefile
7170
run-make/inline-always-many-cgu/Makefile
7271
run-make/interdependent-c-libraries/Makefile
7372
run-make/intrinsic-unreachable/Makefile

tests/run-make/extern-flag-fun/rmake.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@
55
// as non-private. This test checks that these rules are enforced.
66
// See https://github.com/rust-lang/rust/pull/15319
77

8-
//@ ignore-cross-compile
9-
108
use run_make_support::{rust_lib_name, rustc};
119

1210
fn main() {
1311
rustc().input("bar.rs").crate_type("rlib").run();
12+
// Exactly the same rlib as the first line, only the filename changes.
1413
rustc().input("bar.rs").crate_type("rlib").extra_filename("-a").run();
1514
rustc().input("bar-alt.rs").crate_type("rlib").run();
15+
// The crate must be valid.
1616
rustc().input("foo.rs").extern_("bar", "no-exist").run_fail();
1717
rustc().input("foo.rs").extern_("bar", "foo.rs").run_fail();
18+
// Compilation fails with two different rlibs.
1819
rustc()
1920
.input("foo.rs")
2021
.extern_("bar", rust_lib_name("bar"))
2122
.extern_("bar", rust_lib_name("bar-alt"))
2223
.run_fail();
24+
// Even though this one has seemingly two rlibs, they are one and the same.
2325
rustc()
2426
.input("foo.rs")
2527
.extern_("bar", rust_lib_name("bar"))
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
// This test makes sure that changes to files referenced via //[debugger_visualizer]
2-
// are picked up when compiling incrementally.
1+
// This test ensures that changes to files referenced via #[debugger_visualizer]
2+
// (in this case, foo.py and foo.natvis) are picked up when compiling incrementally.
3+
// See https://github.com/rust-lang/rust/pull/111641
34

4-
// We have to copy the source to $(TMPDIR) because Github CI mounts the source
5-
// directory as readonly. We need to apply modifications to some of the source
6-
// file.
7-
8-
use run_make_support::{
9-
fs_wrapper, invalid_utf8_contains_str, invalid_utf8_not_contains_str, rustc,
10-
};
5+
use run_make_support::{fs_wrapper, invalid_utf8_contains, invalid_utf8_not_contains, rustc};
116
use std::io::Read;
127

138
fn main() {
149
fs_wrapper::create_file("foo.py");
1510
fs_wrapper::write("foo.py", "GDB script v1");
1611
fs_wrapper::create_file("foo.natvis");
17-
fs_wrapper::write("foo.py", "Natvis v1");
12+
fs_wrapper::write("foo.natvis", "Natvis v1");
1813
rustc()
1914
.input("foo.rs")
2015
.crate_type("rlib")
@@ -23,8 +18,8 @@ fn main() {
2318
.arg("-Zincremental-verify-ich")
2419
.run();
2520

26-
invalid_utf8_contains_str("libfoo.rmeta", "GDB script v1");
27-
invalid_utf8_contains_str("libfoo.rmeta", "Natvis v1");
21+
invalid_utf8_contains("libfoo.rmeta", "GDB script v1");
22+
invalid_utf8_contains("libfoo.rmeta", "Natvis v1");
2823

2924
// Change only the GDB script and check that the change has been picked up
3025
fs_wrapper::remove_file("foo.py");
@@ -38,14 +33,14 @@ fn main() {
3833
.arg("-Zincremental-verify-ich")
3934
.run();
4035

41-
invalid_utf8_contains_str("libfoo.rmeta", "GDB script v2");
42-
invalid_utf8_not_contains_str("libfoo.rmeta", "GDB script v1");
43-
invalid_utf8_contains_str("libfoo.rmeta", "Natvis v1");
36+
invalid_utf8_contains("libfoo.rmeta", "GDB script v2");
37+
invalid_utf8_not_contains("libfoo.rmeta", "GDB script v1");
38+
invalid_utf8_contains("libfoo.rmeta", "Natvis v1");
4439

4540
// Now change the Natvis version and check that the change has been picked up
4641
fs_wrapper::remove_file("foo.natvis");
4742
fs_wrapper::create_file("foo.natvis");
48-
fs_wrapper::write("foo.py", "Natvis v2");
43+
fs_wrapper::write("foo.natvis", "Natvis v2");
4944
rustc()
5045
.input("foo.rs")
5146
.crate_type("rlib")
@@ -54,8 +49,8 @@ fn main() {
5449
.arg("-Zincremental-verify-ich")
5550
.run();
5651

57-
invalid_utf8_contains_str("libfoo.rmeta", "GDB script v2");
58-
invalid_utf8_not_contains_str("libfoo.rmeta", "GDB script v1");
59-
invalid_utf8_not_contains_str("libfoo.rmeta", "Natvis v1");
60-
invalid_utf8_contains_str("libfoo.rmeta", "Natvis v2");
52+
invalid_utf8_contains("libfoo.rmeta", "GDB script v2");
53+
invalid_utf8_not_contains("libfoo.rmeta", "GDB script v1");
54+
invalid_utf8_not_contains("libfoo.rmeta", "Natvis v1");
55+
invalid_utf8_contains("libfoo.rmeta", "Natvis v2");
6156
}

tests/run-make/incremental-session-fail/Makefile

-14
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Failing to create the directory where output incremental
2+
// files would be stored used to cause an ICE (Internal Compiler
3+
// Error). This was patched in #85698, and this test checks that
4+
// the ensuing compilation failure is not an ICE.
5+
// See https://github.com/rust-lang/rust/pull/85698
6+
7+
use run_make_support::{fs_wrapper, rustc};
8+
9+
fn main() {
10+
fs_wrapper::create_file("session");
11+
// rustc should fail to create the session directory here.
12+
let out = rustc().input("foo.rs").crate_type("rlib").incremental("session").run_fail();
13+
out.assert_stderr_contains("could not create incremental compilation crate directory");
14+
out.assert_stderr_not_contains("internal compiler error");
15+
}

0 commit comments

Comments
 (0)