rewrite incremental-session-fail to rmake
This commit is contained in:
parent
ab71510704
commit
cdfcc9442e
@ -274,23 +274,29 @@ pub fn set_host_rpath(cmd: &mut Command) {
|
|||||||
/// Read the contents of a file that cannot simply be read by
|
/// Read the contents of a file that cannot simply be read by
|
||||||
/// read_to_string, due to invalid utf8 data, then assert that it contains `expected`.
|
/// read_to_string, due to invalid utf8 data, then assert that it contains `expected`.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn invalid_utf8_contains_str<P: AsRef<Path>>(path: P, expected: &str) {
|
pub fn invalid_utf8_contains<P: AsRef<Path>>(path: P, expected: &str) {
|
||||||
use std::io::Read;
|
let buffer = fs_wrapper::read(path.as_ref());
|
||||||
let mut file = std::fs::File::open(path).unwrap();
|
if !String::from_utf8_lossy(&buffer).contains(expected) {
|
||||||
let mut buffer = Vec::new();
|
eprintln!("=== FILE CONTENTS (LOSSY) ===");
|
||||||
file.read_to_end(&mut buffer).unwrap();
|
eprintln!("{}", String::from_utf8_lossy(&buffer));
|
||||||
assert!(String::from_utf8_lossy(&buffer).contains(expected));
|
eprintln!("=== SPECIFIED TEXT ===");
|
||||||
|
eprintln!("{}", expected);
|
||||||
|
panic!("specified text was not found in file");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read the contents of a file that cannot simply be read by
|
/// Read the contents of a file that cannot simply be read by
|
||||||
/// read_to_string, due to invalid utf8 data, then assert that it does not contain `expected`.
|
/// read_to_string, due to invalid utf8 data, then assert that it does not contain `expected`.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn invalid_utf8_not_contains_str<P: AsRef<Path>>(path: P, expected: &str) {
|
pub fn invalid_utf8_not_contains<P: AsRef<Path>>(path: P, expected: &str) {
|
||||||
use std::io::Read;
|
let buffer = fs_wrapper::read(path.as_ref());
|
||||||
let mut file = std::fs::File::open(path).unwrap();
|
if String::from_utf8_lossy(&buffer).contains(expected) {
|
||||||
let mut buffer = Vec::new();
|
eprintln!("=== FILE CONTENTS (LOSSY) ===");
|
||||||
file.read_to_end(&mut buffer).unwrap();
|
eprintln!("{}", String::from_utf8_lossy(&buffer));
|
||||||
assert!(!String::from_utf8_lossy(&buffer).contains(expected));
|
eprintln!("=== SPECIFIED TEXT ===");
|
||||||
|
eprintln!("{}", expected);
|
||||||
|
panic!("specified text was unexpectedly found in file");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Copy a directory into another.
|
/// Copy a directory into another.
|
||||||
|
@ -67,7 +67,6 @@ run-make/inaccessible-temp-dir/Makefile
|
|||||||
run-make/include_bytes_deps/Makefile
|
run-make/include_bytes_deps/Makefile
|
||||||
run-make/incr-add-rust-src-component/Makefile
|
run-make/incr-add-rust-src-component/Makefile
|
||||||
run-make/incr-foreign-head-span/Makefile
|
run-make/incr-foreign-head-span/Makefile
|
||||||
run-make/incremental-session-fail/Makefile
|
|
||||||
run-make/inline-always-many-cgu/Makefile
|
run-make/inline-always-many-cgu/Makefile
|
||||||
run-make/interdependent-c-libraries/Makefile
|
run-make/interdependent-c-libraries/Makefile
|
||||||
run-make/intrinsic-unreachable/Makefile
|
run-make/intrinsic-unreachable/Makefile
|
||||||
|
@ -5,21 +5,23 @@
|
|||||||
// as non-private. This test checks that these rules are enforced.
|
// as non-private. This test checks that these rules are enforced.
|
||||||
// See https://github.com/rust-lang/rust/pull/15319
|
// See https://github.com/rust-lang/rust/pull/15319
|
||||||
|
|
||||||
//@ ignore-cross-compile
|
|
||||||
|
|
||||||
use run_make_support::{rust_lib_name, rustc};
|
use run_make_support::{rust_lib_name, rustc};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
rustc().input("bar.rs").crate_type("rlib").run();
|
rustc().input("bar.rs").crate_type("rlib").run();
|
||||||
|
// Exactly the same rlib as the first line, only the filename changes.
|
||||||
rustc().input("bar.rs").crate_type("rlib").extra_filename("-a").run();
|
rustc().input("bar.rs").crate_type("rlib").extra_filename("-a").run();
|
||||||
rustc().input("bar-alt.rs").crate_type("rlib").run();
|
rustc().input("bar-alt.rs").crate_type("rlib").run();
|
||||||
|
// The crate must be valid.
|
||||||
rustc().input("foo.rs").extern_("bar", "no-exist").run_fail();
|
rustc().input("foo.rs").extern_("bar", "no-exist").run_fail();
|
||||||
rustc().input("foo.rs").extern_("bar", "foo.rs").run_fail();
|
rustc().input("foo.rs").extern_("bar", "foo.rs").run_fail();
|
||||||
|
// Compilation fails with two different rlibs.
|
||||||
rustc()
|
rustc()
|
||||||
.input("foo.rs")
|
.input("foo.rs")
|
||||||
.extern_("bar", rust_lib_name("bar"))
|
.extern_("bar", rust_lib_name("bar"))
|
||||||
.extern_("bar", rust_lib_name("bar-alt"))
|
.extern_("bar", rust_lib_name("bar-alt"))
|
||||||
.run_fail();
|
.run_fail();
|
||||||
|
// Even though this one has seemingly two rlibs, they are one and the same.
|
||||||
rustc()
|
rustc()
|
||||||
.input("foo.rs")
|
.input("foo.rs")
|
||||||
.extern_("bar", rust_lib_name("bar"))
|
.extern_("bar", rust_lib_name("bar"))
|
||||||
|
@ -1,20 +1,15 @@
|
|||||||
// This test makes sure that changes to files referenced via //[debugger_visualizer]
|
// This test ensures that changes to files referenced via #[debugger_visualizer]
|
||||||
// are picked up when compiling incrementally.
|
// (in this case, foo.py and foo.natvis) are picked up when compiling incrementally.
|
||||||
|
// See https://github.com/rust-lang/rust/pull/111641
|
||||||
|
|
||||||
// We have to copy the source to $(TMPDIR) because Github CI mounts the source
|
use run_make_support::{fs_wrapper, invalid_utf8_contains, invalid_utf8_not_contains, rustc};
|
||||||
// directory as readonly. We need to apply modifications to some of the source
|
|
||||||
// file.
|
|
||||||
|
|
||||||
use run_make_support::{
|
|
||||||
fs_wrapper, invalid_utf8_contains_str, invalid_utf8_not_contains_str, rustc,
|
|
||||||
};
|
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
fs_wrapper::create_file("foo.py");
|
fs_wrapper::create_file("foo.py");
|
||||||
fs_wrapper::write("foo.py", "GDB script v1");
|
fs_wrapper::write("foo.py", "GDB script v1");
|
||||||
fs_wrapper::create_file("foo.natvis");
|
fs_wrapper::create_file("foo.natvis");
|
||||||
fs_wrapper::write("foo.py", "Natvis v1");
|
fs_wrapper::write("foo.natvis", "Natvis v1");
|
||||||
rustc()
|
rustc()
|
||||||
.input("foo.rs")
|
.input("foo.rs")
|
||||||
.crate_type("rlib")
|
.crate_type("rlib")
|
||||||
@ -23,8 +18,8 @@ fn main() {
|
|||||||
.arg("-Zincremental-verify-ich")
|
.arg("-Zincremental-verify-ich")
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
invalid_utf8_contains_str("libfoo.rmeta", "GDB script v1");
|
invalid_utf8_contains("libfoo.rmeta", "GDB script v1");
|
||||||
invalid_utf8_contains_str("libfoo.rmeta", "Natvis v1");
|
invalid_utf8_contains("libfoo.rmeta", "Natvis v1");
|
||||||
|
|
||||||
// Change only the GDB script and check that the change has been picked up
|
// Change only the GDB script and check that the change has been picked up
|
||||||
fs_wrapper::remove_file("foo.py");
|
fs_wrapper::remove_file("foo.py");
|
||||||
@ -38,14 +33,14 @@ fn main() {
|
|||||||
.arg("-Zincremental-verify-ich")
|
.arg("-Zincremental-verify-ich")
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
invalid_utf8_contains_str("libfoo.rmeta", "GDB script v2");
|
invalid_utf8_contains("libfoo.rmeta", "GDB script v2");
|
||||||
invalid_utf8_not_contains_str("libfoo.rmeta", "GDB script v1");
|
invalid_utf8_not_contains("libfoo.rmeta", "GDB script v1");
|
||||||
invalid_utf8_contains_str("libfoo.rmeta", "Natvis v1");
|
invalid_utf8_contains("libfoo.rmeta", "Natvis v1");
|
||||||
|
|
||||||
// Now change the Natvis version and check that the change has been picked up
|
// Now change the Natvis version and check that the change has been picked up
|
||||||
fs_wrapper::remove_file("foo.natvis");
|
fs_wrapper::remove_file("foo.natvis");
|
||||||
fs_wrapper::create_file("foo.natvis");
|
fs_wrapper::create_file("foo.natvis");
|
||||||
fs_wrapper::write("foo.py", "Natvis v2");
|
fs_wrapper::write("foo.natvis", "Natvis v2");
|
||||||
rustc()
|
rustc()
|
||||||
.input("foo.rs")
|
.input("foo.rs")
|
||||||
.crate_type("rlib")
|
.crate_type("rlib")
|
||||||
@ -54,8 +49,8 @@ fn main() {
|
|||||||
.arg("-Zincremental-verify-ich")
|
.arg("-Zincremental-verify-ich")
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
invalid_utf8_contains_str("libfoo.rmeta", "GDB script v2");
|
invalid_utf8_contains("libfoo.rmeta", "GDB script v2");
|
||||||
invalid_utf8_not_contains_str("libfoo.rmeta", "GDB script v1");
|
invalid_utf8_not_contains("libfoo.rmeta", "GDB script v1");
|
||||||
invalid_utf8_not_contains_str("libfoo.rmeta", "Natvis v1");
|
invalid_utf8_not_contains("libfoo.rmeta", "Natvis v1");
|
||||||
invalid_utf8_contains_str("libfoo.rmeta", "Natvis v2");
|
invalid_utf8_contains("libfoo.rmeta", "Natvis v2");
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
include ../tools.mk
|
|
||||||
|
|
||||||
SESSION_DIR := $(TMPDIR)/session
|
|
||||||
OUTPUT_FILE := $(TMPDIR)/build-output
|
|
||||||
|
|
||||||
all:
|
|
||||||
echo $(TMPDIR)
|
|
||||||
# Make it so that rustc will fail to create a session directory.
|
|
||||||
touch $(SESSION_DIR)
|
|
||||||
# Check exit code is 1 for an error, and not 101 for ICE.
|
|
||||||
$(RUSTC) foo.rs --crate-type=rlib -C incremental=$(SESSION_DIR) > $(OUTPUT_FILE) 2>&1; [ $$? -eq 1 ]
|
|
||||||
$(CGREP) "could not create incremental compilation crate directory" < $(OUTPUT_FILE)
|
|
||||||
# -v tests are fragile, hopefully this text won't change
|
|
||||||
$(CGREP) -v "internal compiler error" < $(OUTPUT_FILE)
|
|
15
tests/run-make/incremental-session-fail/rmake.rs
Normal file
15
tests/run-make/incremental-session-fail/rmake.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Failing to create the directory where output incremental
|
||||||
|
// files would be stored used to cause an ICE (Internal Compiler
|
||||||
|
// Error). This was patched in #85698, and this test checks that
|
||||||
|
// the ensuing compilation failure is not an ICE.
|
||||||
|
// See https://github.com/rust-lang/rust/pull/85698
|
||||||
|
|
||||||
|
use run_make_support::{fs_wrapper, rustc};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
fs_wrapper::create_file("session");
|
||||||
|
// rustc should fail to create the session directory here.
|
||||||
|
let out = rustc().input("foo.rs").crate_type("rlib").incremental("session").run_fail();
|
||||||
|
out.assert_stderr_contains("could not create incremental compilation crate directory");
|
||||||
|
out.assert_stderr_not_contains("internal compiler error");
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user