Skip to content

Commit bf631b3

Browse files
committed
compiletest: Use PYTHONPATH for lldb too, not only gdb
That allows you to e.g. run debuginfo tests with lldb-15 on Ubuntu 24.04 like this: sudo apt install lldb-15 python3-six PYTHONPATH=/usr/lib/python3/dist-packages ./x --set build.lldb=lldb-15 test tests/debuginfo/basic-stepping.rs
1 parent 2d76d9b commit bf631b3

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/tools/compiletest/src/runtest/debuginfo.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,7 @@ impl TestCx<'_> {
310310

311311
let mut gdb = Command::new(self.config.gdb.as_ref().unwrap());
312312

313-
// FIXME: we are propagating `PYTHONPATH` from the environment, not a compiletest flag!
314-
let pythonpath = if let Ok(pp) = std::env::var("PYTHONPATH") {
315-
format!("{pp}:{rust_pp_module_abs_path}")
316-
} else {
317-
rust_pp_module_abs_path.to_string()
318-
};
313+
let pythonpath = with_pythonpath_prepended(&rust_pp_module_abs_path);
319314
gdb.args(debugger_opts).env("PYTHONPATH", pythonpath);
320315

321316
debugger_run_result =
@@ -458,7 +453,8 @@ impl TestCx<'_> {
458453
debugger_script: &Utf8Path,
459454
) -> ProcRes {
460455
// Path containing `lldb_batchmode.py`, so that the `script` command can import it.
461-
let pythonpath = self.config.src_root.join("src/etc");
456+
let rust_pp_module_abs_path = self.config.src_root.join("src/etc");
457+
let pythonpath = with_pythonpath_prepended(&rust_pp_module_abs_path);
462458

463459
let mut cmd = Command::new(lldb);
464460
cmd.arg("--one-line")
@@ -471,3 +467,12 @@ impl TestCx<'_> {
471467
self.run_command_to_procres(&mut cmd)
472468
}
473469
}
470+
471+
fn with_pythonpath_prepended(some_path: &Utf8Path) -> String {
472+
// FIXME: we are propagating `PYTHONPATH` from the environment, not a compiletest flag!
473+
if let Ok(pp) = std::env::var("PYTHONPATH") {
474+
format!("{pp}:{some_path}")
475+
} else {
476+
some_path.to_string()
477+
}
478+
}

0 commit comments

Comments
 (0)