Skip to content

Commit 9f9877c

Browse files
committed
Auto merge of #5662 - ebroto:cargo_tests_invalid_crate, r=flip1995
cargo-ui tests: check that <dir>/src exists before processing test I forgot that I had fixed this in a PR I closed some days ago (#5643). Before this change, cargo UI tests could fail when switching between branches if the previous branch had a test that the current branch does not have. The directory is not removed when switching because an ignored `Cargo.lock` file exists, and the code was trying to reach `$DIR/src` unconditionally. This change will just skip a directory that has no `src` subdirectory. changelog: none
2 parents 9fdcb13 + 14e9100 commit 9f9877c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tests/compile-test.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,15 @@ fn run_ui_cargo(config: &mut compiletest::Config) {
181181
}
182182

183183
let src_path = case.path().join("src");
184-
env::set_current_dir(&src_path)?;
185184

185+
// When switching between branches, if the previous branch had a test
186+
// that the current branch does not have, the directory is not removed
187+
// because an ignored Cargo.lock file exists.
188+
if !src_path.exists() {
189+
continue;
190+
}
191+
192+
env::set_current_dir(&src_path)?;
186193
for file in fs::read_dir(&src_path)? {
187194
let file = file?;
188195
if file.file_type()?.is_dir() {

0 commit comments

Comments
 (0)