Skip to content

Commit

Permalink
Truncate standalone test files instead of removing
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDenton committed Jan 8, 2024
1 parent cefdabd commit 8cc2fae
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/tests/standalone/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,14 @@ fn write_no_inner_attr(output: &str, filter: &[&str]) {
}

fn riddle(output: &str, filter: &[&str], config: &[&str]) {
_ = std::fs::remove_file(output);
// Rust-analyzer may re-run build scripts whenever a source file is deleted
// which causes an endless loop if the file is deleted from a build script.
// To workaroud this, we truncate the file instead of deleting it.
// See #2777.
_ = std::fs::File::options()
.truncate(true)
.write(true)
.open(output);

let mut command = std::process::Command::new("cargo");

Expand Down

0 comments on commit 8cc2fae

Please sign in to comment.