rewrite output-filename-overwrites-input to rmake

This commit is contained in:
Oneirical 2024-06-14 16:21:55 -04:00
parent e088edd149
commit 8ece5ce319
3 changed files with 21 additions and 15 deletions

View file

@ -152,7 +152,6 @@ run-make/no-duplicate-libs/Makefile
run-make/obey-crate-type-flag/Makefile
run-make/optimization-remarks-dir-pgo/Makefile
run-make/optimization-remarks-dir/Makefile
run-make/output-filename-overwrites-input/Makefile
run-make/output-type-permutations/Makefile
run-make/output-with-hyphens/Makefile
run-make/override-aliased-flags/Makefile

View file

@ -1,14 +0,0 @@
# ignore-cross-compile
include ../tools.mk
all:
cp foo.rs $(TMPDIR)/foo
$(RUSTC) $(TMPDIR)/foo -o $(TMPDIR)/foo 2>&1 \
| $(CGREP) -e "the input file \".*foo\" would be overwritten by the generated executable"
cp bar.rs $(TMPDIR)/bar.rlib
$(RUSTC) $(TMPDIR)/bar.rlib -o $(TMPDIR)/bar.rlib 2>&1 \
| $(CGREP) -e "the input file \".*bar.rlib\" would be overwritten by the generated executable"
$(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls=root $(TMPDIR)/foo 2>&1
cp foo.rs $(TMPDIR)/foo.rs
$(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo.rs 2>&1 \
| $(CGREP) -e "the input file \".*foo.rs\" would be overwritten by the generated executable"

View file

@ -0,0 +1,21 @@
// If rustc is invoked on a file that would be overwritten by the
// compilation, the compilation should fail, to avoid accidental loss.
// See https://github.com/rust-lang/rust/pull/46814
//@ ignore-cross-compile
use run_make_support::{fs_wrapper, rustc};
fn main() {
fs_wrapper::copy("foo.rs", "foo");
rustc().input("foo").output("foo").run_fail().assert_stderr_contains(
r#"the input file "foo" would be overwritten by the generated executable"#,
);
fs_wrapper::copy("bar.rs", "bar.rlib");
rustc().input("bar.rlib").output("bar.rlib").run_fail().assert_stderr_contains(
r#"the input file "bar.rlib" would be overwritten by the generated executable"#,
);
rustc().input("foo.rs").output("foo.rs").run_fail().assert_stderr_contains(
r#"the input file "foo.rs" would be overwritten by the generated executable"#,
);
}