rewrite incremental-debugger-visualiser to rmake

This commit is contained in:
Oneirical 2024-06-14 15:10:34 -04:00
parent a3b7c2993e
commit ab71510704
4 changed files with 83 additions and 50 deletions

View File

@ -271,6 +271,28 @@ pub fn set_host_rpath(cmd: &mut Command) {
});
}
/// 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`.
#[track_caller]
pub fn invalid_utf8_contains_str<P: AsRef<Path>>(path: P, expected: &str) {
use std::io::Read;
let mut file = std::fs::File::open(path).unwrap();
let mut buffer = Vec::new();
file.read_to_end(&mut buffer).unwrap();
assert!(String::from_utf8_lossy(&buffer).contains(expected));
}
/// 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`.
#[track_caller]
pub fn invalid_utf8_not_contains_str<P: AsRef<Path>>(path: P, expected: &str) {
use std::io::Read;
let mut file = std::fs::File::open(path).unwrap();
let mut buffer = Vec::new();
file.read_to_end(&mut buffer).unwrap();
assert!(!String::from_utf8_lossy(&buffer).contains(expected));
}
/// Copy a directory into another.
pub fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) {
fn copy_dir_all_inner(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> {

View File

@ -67,7 +67,6 @@ run-make/inaccessible-temp-dir/Makefile
run-make/include_bytes_deps/Makefile
run-make/incr-add-rust-src-component/Makefile
run-make/incr-foreign-head-span/Makefile
run-make/incremental-debugger-visualizer/Makefile
run-make/incremental-session-fail/Makefile
run-make/inline-always-many-cgu/Makefile
run-make/interdependent-c-libraries/Makefile

View File

@ -1,49 +0,0 @@
include ../tools.mk
# This test makes sure that changes to files referenced via #[debugger_visualizer]
# are picked up when compiling incrementally.
# We have to copy the source to $(TMPDIR) because Github CI mounts the source
# directory as readonly. We need to apply modifications to some of the source
# file.
SRC_DIR := $(TMPDIR)/src
INCR_CACHE_DIR := $(TMPDIR)/incremental
all:
rm -rf $(TMPDIR)/*
mkdir $(SRC_DIR)
cp ./foo.rs $(SRC_DIR)
echo "GDB script v1" > $(SRC_DIR)/foo.py
echo "Natvis v1" > $(SRC_DIR)/foo.natvis
$(RUSTC) $(SRC_DIR)/foo.rs \
--crate-type=rlib \
--emit metadata \
-C incremental=$(INCR_CACHE_DIR) \
-Z incremental-verify-ich
$(CGREP) "GDB script v1" < $(TMPDIR)/libfoo.rmeta
$(CGREP) "Natvis v1" < $(TMPDIR)/libfoo.rmeta
# Change only the GDB script and check that the change has been picked up
echo "GDB script v2" > $(SRC_DIR)/foo.py
$(RUSTC) $(SRC_DIR)/foo.rs \
--crate-type=rlib \
--emit metadata \
-C incremental=$(INCR_CACHE_DIR) \
-Z incremental-verify-ich
$(CGREP) "GDB script v2" < $(TMPDIR)/libfoo.rmeta
$(CGREP) -v "GDB script v1" < $(TMPDIR)/libfoo.rmeta
$(CGREP) "Natvis v1" < $(TMPDIR)/libfoo.rmeta
# Now change the Natvis version and check that the change has been picked up
echo "Natvis v2" > $(SRC_DIR)/foo.natvis
$(RUSTC) $(SRC_DIR)/foo.rs \
--crate-type=rlib \
--emit metadata \
-C incremental=$(INCR_CACHE_DIR) \
-Z incremental-verify-ich
$(CGREP) "GDB script v2" < $(TMPDIR)/libfoo.rmeta
$(CGREP) -v "GDB script v1" < $(TMPDIR)/libfoo.rmeta
$(CGREP) "Natvis v2" < $(TMPDIR)/libfoo.rmeta
$(CGREP) -v "Natvis v1" < $(TMPDIR)/libfoo.rmeta

View File

@ -0,0 +1,61 @@
// This test makes sure that changes to files referenced via //[debugger_visualizer]
// are picked up when compiling incrementally.
// We have to copy the source to $(TMPDIR) because Github CI mounts the source
// 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;
fn main() {
fs_wrapper::create_file("foo.py");
fs_wrapper::write("foo.py", "GDB script v1");
fs_wrapper::create_file("foo.natvis");
fs_wrapper::write("foo.py", "Natvis v1");
rustc()
.input("foo.rs")
.crate_type("rlib")
.emit("metadata")
.incremental("incremental")
.arg("-Zincremental-verify-ich")
.run();
invalid_utf8_contains_str("libfoo.rmeta", "GDB script v1");
invalid_utf8_contains_str("libfoo.rmeta", "Natvis v1");
// Change only the GDB script and check that the change has been picked up
fs_wrapper::remove_file("foo.py");
fs_wrapper::create_file("foo.py");
fs_wrapper::write("foo.py", "GDB script v2");
rustc()
.input("foo.rs")
.crate_type("rlib")
.emit("metadata")
.incremental("incremental")
.arg("-Zincremental-verify-ich")
.run();
invalid_utf8_contains_str("libfoo.rmeta", "GDB script v2");
invalid_utf8_not_contains_str("libfoo.rmeta", "GDB script v1");
invalid_utf8_contains_str("libfoo.rmeta", "Natvis v1");
// Now change the Natvis version and check that the change has been picked up
fs_wrapper::remove_file("foo.natvis");
fs_wrapper::create_file("foo.natvis");
fs_wrapper::write("foo.py", "Natvis v2");
rustc()
.input("foo.rs")
.crate_type("rlib")
.emit("metadata")
.incremental("incremental")
.arg("-Zincremental-verify-ich")
.run();
invalid_utf8_contains_str("libfoo.rmeta", "GDB script v2");
invalid_utf8_not_contains_str("libfoo.rmeta", "GDB script v1");
invalid_utf8_not_contains_str("libfoo.rmeta", "Natvis v1");
invalid_utf8_contains_str("libfoo.rmeta", "Natvis v2");
}