compiletest: don't use stringly paths for compose_and_run

This commit is contained in:
Jieyou Xu 2025-04-10 09:38:21 +08:00
parent 934880f586
commit 4f7c02dda1
No known key found for this signature in database
GPG key ID: 045B995028EA6AFC
2 changed files with 23 additions and 22 deletions

View file

@ -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,
)
}
@ -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,
)
}
@ -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,
)
}
@ -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,
)
}
@ -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,
)
}
@ -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!(
@ -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() {
@ -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 = {
@ -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
@ -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)
}
}
@ -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 {

View file

@ -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
);
@ -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
};
@ -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() {