diff options
| author | bors <bors@rust-lang.org> | 2020-05-31 19:12:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-05-31 19:12:00 +0000 |
| commit | 9f9877c47f5ce0529b8ebe3ed363a3b06ef9e86f (patch) | |
| tree | 25c7dd3a57324ae14017eedaf124f977fbecb6c0 | |
| parent | 9fdcb13edb4026d1058c793a553f1798c044870c (diff) | |
| parent | 14e9100543166e48acd0ea00233249d2cddf09c2 (diff) | |
| download | rust-9f9877c47f5ce0529b8ebe3ed363a3b06ef9e86f.tar.gz rust-9f9877c47f5ce0529b8ebe3ed363a3b06ef9e86f.zip | |
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
| -rw-r--r-- | tests/compile-test.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/compile-test.rs b/tests/compile-test.rs index 7bd5f09f333..194354b291f 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -181,8 +181,15 @@ fn run_ui_cargo(config: &mut compiletest::Config) { } let src_path = case.path().join("src"); - env::set_current_dir(&src_path)?; + // When switching between branches, if the previous branch had a test + // that the current branch does not have, the directory is not removed + // because an ignored Cargo.lock file exists. + if !src_path.exists() { + continue; + } + + env::set_current_dir(&src_path)?; for file in fs::read_dir(&src_path)? { let file = file?; if file.file_type()?.is_dir() { |
