Skip to content

Commit fff9e44

Browse files
committed
Auto merge of #154844 - Walnut356:compiletest_windows, r=jieyouxu
Fix `compiletest` path-related issues on Windows fixes the issues mentioned [here](#147552 (comment)). With these changes I'm able to run `./x test tests/debuginfo` on `x86_64-pc-windows-gnu` without any issues. As mentioned in the link though, there are 3 tests that currently fail when run on windows, but that pass on whatever CI targets actually run `tests/debuginfo`. I'm not sure if `target_run_lib_path` really needs to be prepended on all targets (it absolutely does for Windows though), but i figure it can't hurt. Also made sure the path separators are correct per-platform. The `lldb_batchmode` change prevents the tests from hanging forever. I'm not 100% sure why this hasn't been a problem so far. Maybe just due to the version of LLDB used on the test runner? I haven't done too much testing, but the situation is...weird. I opened [an issue about it in the LLVM repo](llvm/llvm-project#190516).
2 parents 906ca7f + c9e3d31 commit fff9e44

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

src/etc/lldb_batchmode.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ def main():
252252
print("Aborting.", file=sys.stderr)
253253
sys.exit(1)
254254
finally:
255-
debugger.Terminate()
256255
script_file.close()
257256

258257

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,14 +455,17 @@ impl TestCx<'_> {
455455
// Path containing `lldb_batchmode.py`, so that the `script` command can import it.
456456
let rust_pp_module_abs_path = self.config.src_root.join("src/etc");
457457
let pythonpath = with_pythonpath_prepended(&rust_pp_module_abs_path);
458+
// make sure `PATH` points to all the dlls necessary to run the debugee
459+
let path = prepend_to_path(&self.config.target_run_lib_path);
458460

459461
let mut cmd = Command::new(lldb);
460462
cmd.arg("--one-line")
461463
.arg("script --language python -- import lldb_batchmode; lldb_batchmode.main()")
462464
.env("LLDB_BATCHMODE_TARGET_PATH", test_executable)
463465
.env("LLDB_BATCHMODE_SCRIPT_PATH", debugger_script)
464466
.env("PYTHONUNBUFFERED", "1") // Help debugging #78665
465-
.env("PYTHONPATH", pythonpath);
467+
.env("PYTHONPATH", pythonpath)
468+
.env("PATH", path);
466469

467470
self.run_command_to_procres(&mut cmd)
468471
}
@@ -471,7 +474,29 @@ impl TestCx<'_> {
471474
fn with_pythonpath_prepended(some_path: &Utf8Path) -> String {
472475
// FIXME: we are propagating `PYTHONPATH` from the environment, not a compiletest flag!
473476
if let Ok(pp) = std::env::var("PYTHONPATH") {
474-
format!("{pp}:{some_path}")
477+
#[cfg(target_os = "windows")]
478+
{
479+
format!("{pp};{some_path}")
480+
}
481+
#[cfg(not(target_os = "windows"))]
482+
{
483+
format!("{pp}:{some_path}")
484+
}
485+
} else {
486+
some_path.to_string()
487+
}
488+
}
489+
490+
fn prepend_to_path(some_path: &Utf8Path) -> String {
491+
if let Ok(path) = std::env::var("PATH") {
492+
#[cfg(target_os = "windows")]
493+
{
494+
format!("{some_path};{path}")
495+
}
496+
#[cfg(not(target_os = "windows"))]
497+
{
498+
format!("{some_path}:{path}")
499+
}
475500
} else {
476501
some_path.to_string()
477502
}

0 commit comments

Comments
 (0)