Skip to content

Commit cfca5b0

Browse files
Add/improve tests for debugger_visualizer change detection.
1 parent d623668 commit cfca5b0

File tree

6 files changed

+63
-5
lines changed

6 files changed

+63
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# ignore-windows-gnu
2-
31
include ../tools.mk
42

3+
# This test makes sure that files referenced via #[debugger_visualizer] are
4+
# included in `--emit dep-info` output.
5+
56
all:
67
$(RUSTC) --emit dep-info main.rs
78
$(CGREP) "foo.py" < $(TMPDIR)/main.d
8-
$(CGREP) "my_visualizers/bar.py" < $(TMPDIR)/main.d
9+
$(CGREP) "my_visualizers/bar.natvis" < $(TMPDIR)/main.d

tests/run-make/debugger-visualizer-dep-info/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
fn main() {
44
const _UNUSED: u32 = {
55
mod inner {
6-
#![debugger_visualizer(gdb_script_file = "my_visualizers/bar.py")]
6+
#![debugger_visualizer(natvis_file = "my_visualizers/bar.natvis")]
77
pub const XYZ: u32 = 123;
88
}
99

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!-- empty -->

tests/run-make/debugger-visualizer-dep-info/my_visualizers/bar.py

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
include ../tools.mk
2+
3+
# This test makes sure that changes to files referenced via #[debugger_visualizer]
4+
# are picked up when compiling incrementally.
5+
6+
# We have to copy the source to $(TMPDIR) because Github CI mounts the source
7+
# directory as readonly. We need to apply modifications to some of the source
8+
# file.
9+
SRC_DIR := $(TMPDIR)/src
10+
11+
INCR_CACHE_DIR := $(TMPDIR)/incremental
12+
13+
14+
all:
15+
rm -rf $(TMPDIR)/*
16+
mkdir $(SRC_DIR)
17+
cp -t $(SRC_DIR) ./foo.rs
18+
echo "GDB script v1" > $(SRC_DIR)/foo.py
19+
echo "Natvis v1" > $(SRC_DIR)/foo.natvis
20+
$(RUSTC) $(SRC_DIR)/foo.rs \
21+
--crate-type=rlib \
22+
--emit metadata \
23+
-C incremental=$(INCR_CACHE_DIR) \
24+
-Z incremental-verify-ich
25+
$(CGREP) "GDB script v1" < $(TMPDIR)/libfoo.rmeta
26+
$(CGREP) "Natvis v1" < $(TMPDIR)/libfoo.rmeta
27+
28+
# Change only the GDB script and check that the change has been picked up
29+
echo "GDB script v2" > $(SRC_DIR)/foo.py
30+
$(RUSTC) $(SRC_DIR)/foo.rs \
31+
--crate-type=rlib \
32+
--emit metadata \
33+
-C incremental=$(INCR_CACHE_DIR) \
34+
-Z incremental-verify-ich
35+
36+
$(CGREP) "GDB script v2" < $(TMPDIR)/libfoo.rmeta
37+
$(CGREP) -v "GDB script v1" < $(TMPDIR)/libfoo.rmeta
38+
$(CGREP) "Natvis v1" < $(TMPDIR)/libfoo.rmeta
39+
40+
# Now change the Natvis version and check that the change has been picked up
41+
echo "Natvis v2" > $(SRC_DIR)/foo.natvis
42+
$(RUSTC) $(SRC_DIR)/foo.rs \
43+
--crate-type=rlib \
44+
--emit metadata \
45+
-C incremental=$(INCR_CACHE_DIR) \
46+
-Z incremental-verify-ich
47+
48+
$(CGREP) "GDB script v2" < $(TMPDIR)/libfoo.rmeta
49+
$(CGREP) -v "GDB script v1" < $(TMPDIR)/libfoo.rmeta
50+
$(CGREP) "Natvis v2" < $(TMPDIR)/libfoo.rmeta
51+
$(CGREP) -v "Natvis v1" < $(TMPDIR)/libfoo.rmeta
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![debugger_visualizer(natvis_file = "./foo.natvis")]
2+
#![debugger_visualizer(gdb_script_file = "./foo.py")]
3+
4+
pub struct Foo {
5+
pub x: u32,
6+
}

0 commit comments

Comments
 (0)