Skip to content

Commit 10577ea

Browse files
committed
Handle edge case of non-existant paths
1 parent 81d711d commit 10577ea

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/bootstrap/src/core/builder.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -442,17 +442,23 @@ impl StepDescription {
442442
let paths: Vec<_> = paths
443443
.iter()
444444
.map(|p| {
445+
// If the path does not exist, it may represent the name of a Step, like `test tidy`
446+
if !p.exists() {
447+
return p.clone();
448+
}
445449
// Get the canonical path, strip the prefix, and convert to a PathBuf.
446450
match p.canonicalize() {
447451
Ok(p) => p.strip_prefix(&builder.src).unwrap_or(&p).to_owned(),
448-
Err(_) => {
449-
panic!("failed to canonicalize path: {:?}", p);
452+
Err(e) => {
453+
eprintln!("ERROR: {:?}", e);
454+
panic!("Due to the above error, failed to canonicalize path: {:?}", p);
450455
}
451456
}
452-
}).collect();
457+
})
458+
.collect();
453459

454460
// Convert Vec<PathBuf> to `Vec<&Path>`
455-
let mut paths:Vec<&Path> = paths.iter().map(|p| p.as_ref()).collect();
461+
let mut paths: Vec<&Path> = paths.iter().map(|p| p.as_ref()).collect();
456462

457463
remap_paths(&mut paths);
458464

0 commit comments

Comments
 (0)