Skip to content

Commit 362c0f2

Browse files
authored
Rollup merge of rust-lang#139609 - jieyouxu:compiletest-path-misc, r=Kobzol
compiletest: don't use stringly paths for `compose_and_run` Eventually I'd like to fully migrate to `camino`'s `{Utf8Path,Utf8PathBuf}` because compiletest assumes UTF-8 paths all over the place, so this is an precursor change to make the migration diff cleaner. r? `@Kobzol` (or bootstrap/compiler)
2 parents af3b892 + 4f7c02d commit 362c0f2

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
}
@@ -1020,8 +1020,8 @@ impl<'test> TestCx<'test> {
10201020

10211021
self.compose_and_run(
10221022
test_client,
1023-
self.config.run_lib_path.to_str().unwrap(),
1024-
Some(aux_dir.to_str().unwrap()),
1023+
self.config.run_lib_path.as_path(),
1024+
Some(aux_dir.as_path()),
10251025
None,
10261026
)
10271027
}
@@ -1035,8 +1035,8 @@ impl<'test> TestCx<'test> {
10351035

10361036
self.compose_and_run(
10371037
wr_run,
1038-
self.config.run_lib_path.to_str().unwrap(),
1039-
Some(aux_dir.to_str().unwrap()),
1038+
self.config.run_lib_path.as_path(),
1039+
Some(aux_dir.as_path()),
10401040
None,
10411041
)
10421042
}
@@ -1050,8 +1050,8 @@ impl<'test> TestCx<'test> {
10501050

10511051
self.compose_and_run(
10521052
program,
1053-
self.config.run_lib_path.to_str().unwrap(),
1054-
Some(aux_dir.to_str().unwrap()),
1053+
self.config.run_lib_path.as_path(),
1054+
Some(aux_dir.as_path()),
10551055
None,
10561056
)
10571057
}
@@ -1197,8 +1197,8 @@ impl<'test> TestCx<'test> {
11971197
self.props.unset_rustc_env.iter().fold(&mut rustc, Command::env_remove);
11981198
self.compose_and_run(
11991199
rustc,
1200-
self.config.compile_lib_path.to_str().unwrap(),
1201-
Some(aux_dir.to_str().unwrap()),
1200+
self.config.compile_lib_path.as_path(),
1201+
Some(aux_dir.as_path()),
12021202
input,
12031203
)
12041204
}
@@ -1219,8 +1219,7 @@ impl<'test> TestCx<'test> {
12191219
rustc.args(&["--crate-type", "rlib"]);
12201220
rustc.arg("-Cpanic=abort");
12211221

1222-
let res =
1223-
self.compose_and_run(rustc, self.config.compile_lib_path.to_str().unwrap(), None, None);
1222+
let res = self.compose_and_run(rustc, self.config.compile_lib_path.as_path(), None, None);
12241223
if !res.status.success() {
12251224
self.fatal_proc_rec(
12261225
&format!(
@@ -1332,8 +1331,8 @@ impl<'test> TestCx<'test> {
13321331

13331332
let auxres = aux_cx.compose_and_run(
13341333
aux_rustc,
1335-
aux_cx.config.compile_lib_path.to_str().unwrap(),
1336-
Some(aux_dir.to_str().unwrap()),
1334+
aux_cx.config.compile_lib_path.as_path(),
1335+
Some(aux_dir.as_path()),
13371336
None,
13381337
);
13391338
if !auxres.status.success() {
@@ -1373,8 +1372,8 @@ impl<'test> TestCx<'test> {
13731372
fn compose_and_run(
13741373
&self,
13751374
mut command: Command,
1376-
lib_path: &str,
1377-
aux_path: Option<&str>,
1375+
lib_path: &Path,
1376+
aux_path: Option<&Path>,
13781377
input: Option<String>,
13791378
) -> ProcRes {
13801379
let cmdline = {
@@ -1806,7 +1805,7 @@ impl<'test> TestCx<'test> {
18061805
}
18071806
}
18081807

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

18121811
// Linux and mac don't require adjusting the library search path
@@ -1819,7 +1818,7 @@ impl<'test> TestCx<'test> {
18191818
format!("{}=\"{}\"", util::lib_path_env_var(), util::make_new_path(path))
18201819
}
18211820

1822-
format!("{} {:?}", lib_path_cmd_prefix(libpath), command)
1821+
format!("{} {:?}", lib_path_cmd_prefix(libpath.to_str().unwrap()), command)
18231822
}
18241823
}
18251824

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

1983-
self.compose_and_run(filecheck, "", None, None)
1982+
// FIXME(jieyouxu): don't pass an empty Path
1983+
self.compose_and_run(filecheck, Path::new(""), None, None)
19841984
}
19851985

19861986
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)