diff options
| author | Oneirical <manchot@videotron.ca> | 2024-06-14 16:21:55 -0400 |
|---|---|---|
| committer | Oneirical <manchot@videotron.ca> | 2024-06-14 16:21:55 -0400 |
| commit | 8ece5ce31958bd1acadfc2ac7fccc7ce25176b8d (patch) | |
| tree | e5b8d9d699b566a31033c6621366058566a922e8 /tests/run-make | |
| parent | e088edd149475f3e11267dd7061db3f3e6962772 (diff) | |
| download | rust-8ece5ce31958bd1acadfc2ac7fccc7ce25176b8d.tar.gz rust-8ece5ce31958bd1acadfc2ac7fccc7ce25176b8d.zip | |
rewrite output-filename-overwrites-input to rmake
Diffstat (limited to 'tests/run-make')
| -rw-r--r-- | tests/run-make/output-filename-overwrites-input/Makefile | 14 | ||||
| -rw-r--r-- | tests/run-make/output-filename-overwrites-input/rmake.rs | 21 |
2 files changed, 21 insertions, 14 deletions
diff --git a/tests/run-make/output-filename-overwrites-input/Makefile b/tests/run-make/output-filename-overwrites-input/Makefile deleted file mode 100644 index fe5d231382d..00000000000 --- a/tests/run-make/output-filename-overwrites-input/Makefile +++ /dev/null @@ -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" diff --git a/tests/run-make/output-filename-overwrites-input/rmake.rs b/tests/run-make/output-filename-overwrites-input/rmake.rs new file mode 100644 index 00000000000..c6055e818a1 --- /dev/null +++ b/tests/run-make/output-filename-overwrites-input/rmake.rs @@ -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"#, + ); +} |
