From 7232a07f5a44831b794be120b8bfd52b856a13f6 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Thu, 22 Aug 2024 11:51:02 +1000 Subject: [PATCH 1/3] Explain the `run-make/debugger-visualizer-dep-info` Python script --- tests/run-make/debugger-visualizer-dep-info/foo.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/run-make/debugger-visualizer-dep-info/foo.py b/tests/run-make/debugger-visualizer-dep-info/foo.py index 1bb8bf6d7fd4c..d319792657eda 100644 --- a/tests/run-make/debugger-visualizer-dep-info/foo.py +++ b/tests/run-make/debugger-visualizer-dep-info/foo.py @@ -1 +1,6 @@ -# empty +# This is a Python script, but we don't actually run it. +# So if you're trying to remove Python scripts from the test suite, +# be aware that there's no value in trying to get rid of this one. +# +# It just needs to exist so that the compiler can embed it via +# `#![debugger_visualizer(gdb_script_file = "...")]`. From 5fc562c5b1a53fd78ecad2da7481c0559705307b Mon Sep 17 00:00:00 2001 From: Zalathar Date: Thu, 22 Aug 2024 11:52:21 +1000 Subject: [PATCH 2/3] Rename `foo.py` to `my_gdb_script.py` This makes it easier for maintainers to see what the Python script is for. --- tests/run-make/debugger-visualizer-dep-info/main.rs | 2 +- .../debugger-visualizer-dep-info/{foo.py => my_gdb_script.py} | 0 tests/run-make/debugger-visualizer-dep-info/rmake.rs | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename tests/run-make/debugger-visualizer-dep-info/{foo.py => my_gdb_script.py} (100%) diff --git a/tests/run-make/debugger-visualizer-dep-info/main.rs b/tests/run-make/debugger-visualizer-dep-info/main.rs index 3aede2215eac2..3539b305be353 100644 --- a/tests/run-make/debugger-visualizer-dep-info/main.rs +++ b/tests/run-make/debugger-visualizer-dep-info/main.rs @@ -1,4 +1,4 @@ -#![debugger_visualizer(gdb_script_file = "foo.py")] +#![debugger_visualizer(gdb_script_file = "my_gdb_script.py")] fn main() { const _UNUSED: u32 = { diff --git a/tests/run-make/debugger-visualizer-dep-info/foo.py b/tests/run-make/debugger-visualizer-dep-info/my_gdb_script.py similarity index 100% rename from tests/run-make/debugger-visualizer-dep-info/foo.py rename to tests/run-make/debugger-visualizer-dep-info/my_gdb_script.py diff --git a/tests/run-make/debugger-visualizer-dep-info/rmake.rs b/tests/run-make/debugger-visualizer-dep-info/rmake.rs index 65ffb2373e7c4..f5cf39157ac65 100644 --- a/tests/run-make/debugger-visualizer-dep-info/rmake.rs +++ b/tests/run-make/debugger-visualizer-dep-info/rmake.rs @@ -6,6 +6,6 @@ use run_make_support::{invalid_utf8_contains, rustc}; fn main() { rustc().emit("dep-info").input("main.rs").run(); - invalid_utf8_contains("main.d", "foo.py"); + invalid_utf8_contains("main.d", "my_gdb_script.py"); invalid_utf8_contains("main.d", "my_visualizers/bar.natvis"); } From 34cdfc9b490c7d7cc284fcdaf2338976ee6329bf Mon Sep 17 00:00:00 2001 From: Zalathar Date: Thu, 22 Aug 2024 11:58:46 +1000 Subject: [PATCH 3/3] Advise against removing `run-make/libtest-junit/validate_junit.py` Trying to get rid of this Python script looks tempting, because it's currently the only Python script in the whole `run-make` suite that we actually run. But getting rid of it would require pulling in a Rust crate to parse XML instead, and that's probably not worth the extra hassle for a relatively-minor test. --- tests/run-make/libtest-junit/validate_junit.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/run-make/libtest-junit/validate_junit.py b/tests/run-make/libtest-junit/validate_junit.py index 0d9b34a3cf7e0..f92473751b036 100755 --- a/tests/run-make/libtest-junit/validate_junit.py +++ b/tests/run-make/libtest-junit/validate_junit.py @@ -1,5 +1,15 @@ #!/usr/bin/env python +# Trivial Python script that reads lines from stdin, and checks that each line +# is a well-formed XML document. +# +# This takes advantage of the fact that Python has a built-in XML parser, +# whereas doing the same check in Rust would require us to pull in an XML +# crate just for this relatively-minor test. +# +# If you're trying to remove Python scripts from the test suite, think twice +# before removing this one. You could do so, but it's probably not worth it. + import sys import xml.etree.ElementTree as ET