Skip to content

compiletest: don't use stringly paths for compose_and_run #139609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ impl<'test> TestCx<'test> {

self.compose_and_run(
rustc,
self.config.compile_lib_path.to_str().unwrap(),
Some(aux_dir.to_str().unwrap()),
self.config.compile_lib_path.as_path(),
Some(aux_dir.as_path()),
src,
)
}
Expand Down Expand Up @@ -1022,8 +1022,8 @@ impl<'test> TestCx<'test> {

self.compose_and_run(
test_client,
self.config.run_lib_path.to_str().unwrap(),
Some(aux_dir.to_str().unwrap()),
self.config.run_lib_path.as_path(),
Some(aux_dir.as_path()),
None,
)
}
Expand All @@ -1037,8 +1037,8 @@ impl<'test> TestCx<'test> {

self.compose_and_run(
wr_run,
self.config.run_lib_path.to_str().unwrap(),
Some(aux_dir.to_str().unwrap()),
self.config.run_lib_path.as_path(),
Some(aux_dir.as_path()),
None,
)
}
Expand All @@ -1052,8 +1052,8 @@ impl<'test> TestCx<'test> {

self.compose_and_run(
program,
self.config.run_lib_path.to_str().unwrap(),
Some(aux_dir.to_str().unwrap()),
self.config.run_lib_path.as_path(),
Some(aux_dir.as_path()),
None,
)
}
Expand Down Expand Up @@ -1199,8 +1199,8 @@ impl<'test> TestCx<'test> {
self.props.unset_rustc_env.iter().fold(&mut rustc, Command::env_remove);
self.compose_and_run(
rustc,
self.config.compile_lib_path.to_str().unwrap(),
Some(aux_dir.to_str().unwrap()),
self.config.compile_lib_path.as_path(),
Some(aux_dir.as_path()),
input,
)
}
Expand All @@ -1221,8 +1221,7 @@ impl<'test> TestCx<'test> {
rustc.args(&["--crate-type", "rlib"]);
rustc.arg("-Cpanic=abort");

let res =
self.compose_and_run(rustc, self.config.compile_lib_path.to_str().unwrap(), None, None);
let res = self.compose_and_run(rustc, self.config.compile_lib_path.as_path(), None, None);
if !res.status.success() {
self.fatal_proc_rec(
&format!(
Expand Down Expand Up @@ -1334,8 +1333,8 @@ impl<'test> TestCx<'test> {

let auxres = aux_cx.compose_and_run(
aux_rustc,
aux_cx.config.compile_lib_path.to_str().unwrap(),
Some(aux_dir.to_str().unwrap()),
aux_cx.config.compile_lib_path.as_path(),
Some(aux_dir.as_path()),
None,
);
if !auxres.status.success() {
Expand Down Expand Up @@ -1375,8 +1374,8 @@ impl<'test> TestCx<'test> {
fn compose_and_run(
&self,
mut command: Command,
lib_path: &str,
aux_path: Option<&str>,
lib_path: &Path,
aux_path: Option<&Path>,
input: Option<String>,
) -> ProcRes {
let cmdline = {
Expand Down Expand Up @@ -1808,7 +1807,7 @@ impl<'test> TestCx<'test> {
}
}

fn make_cmdline(&self, command: &Command, libpath: &str) -> String {
fn make_cmdline(&self, command: &Command, libpath: &Path) -> String {
use crate::util;

// Linux and mac don't require adjusting the library search path
Expand All @@ -1821,7 +1820,7 @@ impl<'test> TestCx<'test> {
format!("{}=\"{}\"", util::lib_path_env_var(), util::make_new_path(path))
}

format!("{} {:?}", lib_path_cmd_prefix(libpath), command)
format!("{} {:?}", lib_path_cmd_prefix(libpath.to_str().unwrap()), command)
}
}

Expand Down Expand Up @@ -1982,7 +1981,8 @@ impl<'test> TestCx<'test> {
// Add custom flags supplied by the `filecheck-flags:` test header.
filecheck.args(&self.props.filecheck_flags);

self.compose_and_run(filecheck, "", None, None)
// FIXME(jieyouxu): don't pass an empty Path
self.compose_and_run(filecheck, Path::new(""), None, None)
}

fn charset() -> &'static str {
Expand Down
7 changes: 4 additions & 3 deletions src/tools/compiletest/src/runtest/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl TestCx<'_> {

let debugger_run_result = self.compose_and_run(
cdb,
self.config.run_lib_path.to_str().unwrap(),
self.config.run_lib_path.as_path(),
None, // aux_path
None, // input
);
Expand Down Expand Up @@ -241,7 +241,8 @@ impl TestCx<'_> {
let cmdline = {
let mut gdb = Command::new(&format!("{}-gdb", self.config.target));
gdb.args(debugger_opts);
let cmdline = self.make_cmdline(&gdb, "");
// FIXME(jieyouxu): don't pass an empty Path
let cmdline = self.make_cmdline(&gdb, Path::new(""));
logv(self.config, format!("executing {}", cmdline));
cmdline
};
Expand Down Expand Up @@ -340,7 +341,7 @@ impl TestCx<'_> {
gdb.args(debugger_opts).env("PYTHONPATH", pythonpath);

debugger_run_result =
self.compose_and_run(gdb, self.config.run_lib_path.to_str().unwrap(), None, None);
self.compose_and_run(gdb, self.config.run_lib_path.as_path(), None, None);
}

if !debugger_run_result.status.success() {
Expand Down
Loading