Skip to content

Commit 4f7c02d

Browse files
committed
compiletest: don't use stringly paths for compose_and_run
1 parent 934880f commit 4f7c02d

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

src/tools/compiletest/src/runtest.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,8 @@ impl<'test> TestCx<'test> {
445445

446446
self.compose_and_run(
447447
rustc,
448-
self.config.compile_lib_path.to_str().unwrap(),
449-
Some(aux_dir.to_str().unwrap()),
448+
self.config.compile_lib_path.as_path(),
449+
Some(aux_dir.as_path()),
450450
src,
451451
)
452452
}
@@ -1022,8 +1022,8 @@ impl<'test> TestCx<'test> {
10221022

10231023
self.compose_and_run(
10241024
test_client,
1025-
self.config.run_lib_path.to_str().unwrap(),
1026-
Some(aux_dir.to_str().unwrap()),
1025+
self.config.run_lib_path.as_path(),
1026+
Some(aux_dir.as_path()),
10271027
None,
10281028
)
10291029
}
@@ -1037,8 +1037,8 @@ impl<'test> TestCx<'test> {
10371037

10381038
self.compose_and_run(
10391039
wr_run,
1040-
self.config.run_lib_path.to_str().unwrap(),
1041-
Some(aux_dir.to_str().unwrap()),
1040+
self.config.run_lib_path.as_path(),
1041+
Some(aux_dir.as_path()),
10421042
None,
10431043
)
10441044
}
@@ -1052,8 +1052,8 @@ impl<'test> TestCx<'test> {
10521052

10531053
self.compose_and_run(
10541054
program,
1055-
self.config.run_lib_path.to_str().unwrap(),
1056-
Some(aux_dir.to_str().unwrap()),
1055+
self.config.run_lib_path.as_path(),
1056+
Some(aux_dir.as_path()),
10571057
None,
10581058
)
10591059
}
@@ -1199,8 +1199,8 @@ impl<'test> TestCx<'test> {
11991199
self.props.unset_rustc_env.iter().fold(&mut rustc, Command::env_remove);
12001200
self.compose_and_run(
12011201
rustc,
1202-
self.config.compile_lib_path.to_str().unwrap(),
1203-
Some(aux_dir.to_str().unwrap()),
1202+
self.config.compile_lib_path.as_path(),
1203+
Some(aux_dir.as_path()),
12041204
input,
12051205
)
12061206
}
@@ -1221,8 +1221,7 @@ impl<'test> TestCx<'test> {
12211221
rustc.args(&["--crate-type", "rlib"]);
12221222
rustc.arg("-Cpanic=abort");
12231223

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

13351334
let auxres = aux_cx.compose_and_run(
13361335
aux_rustc,
1337-
aux_cx.config.compile_lib_path.to_str().unwrap(),
1338-
Some(aux_dir.to_str().unwrap()),
1336+
aux_cx.config.compile_lib_path.as_path(),
1337+
Some(aux_dir.as_path()),
13391338
None,
13401339
);
13411340
if !auxres.status.success() {
@@ -1375,8 +1374,8 @@ impl<'test> TestCx<'test> {
13751374
fn compose_and_run(
13761375
&self,
13771376
mut command: Command,
1378-
lib_path: &str,
1379-
aux_path: Option<&str>,
1377+
lib_path: &Path,
1378+
aux_path: Option<&Path>,
13801379
input: Option<String>,
13811380
) -> ProcRes {
13821381
let cmdline = {
@@ -1808,7 +1807,7 @@ impl<'test> TestCx<'test> {
18081807
}
18091808
}
18101809

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

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

1824-
format!("{} {:?}", lib_path_cmd_prefix(libpath), command)
1823+
format!("{} {:?}", lib_path_cmd_prefix(libpath.to_str().unwrap()), command)
18251824
}
18261825
}
18271826

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

1985-
self.compose_and_run(filecheck, "", None, None)
1984+
// FIXME(jieyouxu): don't pass an empty Path
1985+
self.compose_and_run(filecheck, Path::new(""), None, None)
19861986
}
19871987

19881988
fn charset() -> &'static str {

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl TestCx<'_> {
104104

105105
let debugger_run_result = self.compose_and_run(
106106
cdb,
107-
self.config.run_lib_path.to_str().unwrap(),
107+
self.config.run_lib_path.as_path(),
108108
None, // aux_path
109109
None, // input
110110
);
@@ -241,7 +241,8 @@ impl TestCx<'_> {
241241
let cmdline = {
242242
let mut gdb = Command::new(&format!("{}-gdb", self.config.target));
243243
gdb.args(debugger_opts);
244-
let cmdline = self.make_cmdline(&gdb, "");
244+
// FIXME(jieyouxu): don't pass an empty Path
245+
let cmdline = self.make_cmdline(&gdb, Path::new(""));
245246
logv(self.config, format!("executing {}", cmdline));
246247
cmdline
247248
};
@@ -340,7 +341,7 @@ impl TestCx<'_> {
340341
gdb.args(debugger_opts).env("PYTHONPATH", pythonpath);
341342

342343
debugger_run_result =
343-
self.compose_and_run(gdb, self.config.run_lib_path.to_str().unwrap(), None, None);
344+
self.compose_and_run(gdb, self.config.run_lib_path.as_path(), None, None);
344345
}
345346

346347
if !debugger_run_result.status.success() {

0 commit comments

Comments
 (0)