Auto merge of #127000 - Oneirical:no-test-for-the-wicked, r=Kobzol

Migrate `use-suggestions-rust-2018`, `overwrite-input`, `lto-dylib-dep` and `many-crates-but-no-match` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
This commit is contained in:
bors 2024-06-28 17:42:05 +00:00
commit c4c0897a26
12 changed files with 79 additions and 76 deletions

View File

@ -93,14 +93,12 @@ run-make/llvm-ident/Makefile
run-make/long-linker-command-lines-cmd-exe/Makefile
run-make/long-linker-command-lines/Makefile
run-make/longjmp-across-rust/Makefile
run-make/lto-dylib-dep/Makefile
run-make/lto-linkage-used-attr/Makefile
run-make/lto-no-link-whole-rlib/Makefile
run-make/lto-smoke-c/Makefile
run-make/macos-deployment-target/Makefile
run-make/macos-fat-archive/Makefile
run-make/manual-link/Makefile
run-make/many-crates-but-no-match/Makefile
run-make/metadata-dep-info/Makefile
run-make/min-global-align/Makefile
run-make/mingw-export-call-convention/Makefile
@ -118,7 +116,6 @@ run-make/optimization-remarks-dir-pgo/Makefile
run-make/optimization-remarks-dir/Makefile
run-make/output-type-permutations/Makefile
run-make/override-aliased-flags/Makefile
run-make/overwrite-input/Makefile
run-make/panic-abort-eh_frame/Makefile
run-make/pass-linker-flags-flavor/Makefile
run-make/pass-linker-flags-from-dep/Makefile
@ -192,7 +189,6 @@ run-make/translation/Makefile
run-make/type-mismatch-same-crate-name/Makefile
run-make/unknown-mod-stdin/Makefile
run-make/unstable-flag-required/Makefile
run-make/use-suggestions-rust-2018/Makefile
run-make/used-cdylib-macos/Makefile
run-make/volatile-intrinsics/Makefile
run-make/wasm-exceptions-nostd/Makefile

View File

@ -1,11 +0,0 @@
# ignore-cross-compile
include ../tools.mk
# Test that we don't run into an assertion when using a Rust dylib dependency
# while compiling with full LTO.
# See https://github.com/rust-lang/rust/issues/59137
all:
$(RUSTC) a_dylib.rs --crate-type=dylib -C prefer-dynamic
$(RUSTC) main.rs -C lto
$(call RUN,main)

View File

@ -0,0 +1,15 @@
// Compiling with link-time-optimizations (LTO) would previously run into an internal
// compiler error (ICE) if a dylib was passed as a required library. This was due to a
// misplaced assert! call in the compiler, which is now removed. This test checks that
// this bug does not make a resurgence and that dylib+lto compilation succeeds.
// See https://github.com/rust-lang/rust/issues/59137
//@ ignore-cross-compile
use run_make_support::{run, rustc};
fn main() {
rustc().input("a_dylib.rs").crate_type("dylib").arg("-Cprefer-dynamic").run();
rustc().input("main.rs").arg("-Clto").run();
run("main");
}

View File

@ -1,35 +0,0 @@
include ../tools.mk
# Modelled after ui/changing-crates.rs test, but this one puts
# more than one (mismatching) candidate crate into the search path,
# which did not appear directly expressible in UI testing infrastructure.
#
# Note that we move the built libraries into target direcrtories rather than
# use the `--out-dir` option because the `../tools.mk` file already bakes a
# use of `--out-dir` into the definition of $(RUSTC).
A1=$(TMPDIR)/a1
A2=$(TMPDIR)/a2
A3=$(TMPDIR)/a3
# A hack to match distinct lines of output from a single run.
LOG=$(TMPDIR)/log.txt
all:
mkdir -p $(A1) $(A2) $(A3)
$(RUSTC) --crate-type=rlib crateA1.rs
mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A1)
$(RUSTC) --crate-type=rlib -L $(A1) crateB.rs
$(RUSTC) --crate-type=rlib crateA2.rs
mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A2)
$(RUSTC) --crate-type=rlib crateA3.rs
mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A3)
# Ensure crateC fails to compile since A1 is "missing" and A2/A3 hashes do not match
$(RUSTC) -L $(A2) -L $(A3) crateC.rs >$(LOG) 2>&1 || true
$(CGREP) \
'found possibly newer version of crate `crateA` which `crateB` depends on' \
'note: perhaps that crate needs to be recompiled?' \
'crate `crateA`:' \
'crate `crateB`:' \
< $(LOG)
# the 'crate `crateA`' will match two entries.

View File

@ -0,0 +1,31 @@
// An extended version of the ui/changing-crates.rs test, this test puts
// multiple mismatching crates into the search path of crateC (A2 and A3)
// and checks that the standard error contains helpful messages to indicate
// what should be done to fix the issue.
// See https://github.com/rust-lang/rust/issues/13266
use run_make_support::{fs_wrapper, rustc};
fn main() {
fs_wrapper::create_dir("a1");
fs_wrapper::create_dir("a2");
fs_wrapper::create_dir("a3");
rustc().crate_type("rlib").out_dir("a1").input("crateA1.rs").run();
rustc().crate_type("rlib").library_search_path("a1").input("crateB.rs").run();
rustc().crate_type("rlib").out_dir("a2").input("crateA2.rs").run();
rustc().crate_type("rlib").out_dir("a3").input("crateA3.rs").run();
// Ensure crateC fails to compile since A1 is "missing" and A2/A3 hashes do not match
rustc()
.crate_type("rlib")
.library_search_path("a2")
.library_search_path("a3")
.input("crateC.rs")
.run_fail()
.assert_stderr_contains(
"found possibly newer version of crate `crateA` which `crateB` depends on",
)
.assert_stderr_contains("note: perhaps that crate needs to be recompiled?")
.assert_stderr_contains("crate `crateA`:")
.assert_stderr_contains("crate `crateB`:");
// the 'crate `crateA`' will match two entries.
}

View File

@ -1,7 +0,0 @@
include ../tools.mk
all:
$(RUSTC) main.rs -o main.rs 2> $(TMPDIR)/file.stderr || echo "failed successfully"
$(RUSTC) main.rs -o . 2> $(TMPDIR)/folder.stderr || echo "failed successfully"
$(RUSTC_TEST_OP) "$(TMPDIR)"/file.stderr file.stderr
$(RUSTC_TEST_OP) "$(TMPDIR)"/folder.stderr folder.stderr

View File

@ -1,6 +1,4 @@
warning: ignoring --out-dir flag due to -o flag
error: the input file "main.rs" would be overwritten by the generated executable
error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 1 previous error

View File

@ -1,6 +1,4 @@
warning: ignoring --out-dir flag due to -o flag
error: the generated executable for the input file "main.rs" conflicts with the existing directory "."
error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 1 previous error

View File

@ -1,6 +0,0 @@
warning: ignoring --out-dir flag due to -o flag
error: the input file "main.rs" would be overwritten by the generated executable
error: aborting due to 1 previous error; 1 warning emitted

View File

@ -0,0 +1,13 @@
// An attempt to set the output `-o` into a directory or a file we cannot write into should indeed
// be an error; but not an ICE (Internal Compiler Error). This test attempts both and checks
// that the standard error matches what is expected.
// See https://github.com/rust-lang/rust/issues/66530
use run_make_support::{diff, rustc};
fn main() {
let file_out = rustc().input("main.rs").output("main.rs").run_fail().stderr_utf8();
let folder_out = rustc().input("main.rs").output(".").run_fail().stderr_utf8();
diff().expected_file("file.stderr").actual_text("actual-file-stderr", file_out).run();
diff().expected_file("folder.stderr").actual_text("actual-folder-stderr", folder_out).run();
}

View File

@ -1,7 +0,0 @@
include ../tools.mk
all:
$(RUSTC) ep-nested-lib.rs
$(RUSTC) use-suggestions.rs --edition=2018 --extern ep_nested_lib=$(TMPDIR)/libep_nested_lib.rlib 2>&1 | $(CGREP) "use ep_nested_lib::foo::bar::Baz"

View File

@ -0,0 +1,18 @@
// The compilation error caused by calling on an unimported crate
// should have a suggestion to write, say, crate::bar::Foo instead
// of just bar::Foo. However, this suggestion used to only appear for
// extern crate statements, not crate struct. After this was fixed in #51456,
// this test checks that the correct suggestion is printed no matter what.
// See https://github.com/rust-lang/rust/issues/51212
use run_make_support::{rust_lib_name, rustc};
fn main() {
rustc().input("ep-nested-lib.rs").run();
rustc()
.input("use-suggestions.rs")
.edition("2018")
.extern_("ep_nested_lib", rust_lib_name("ep_nested_lib"))
.run_fail()
.assert_stderr_contains("use ep_nested_lib::foo::bar::Baz");
}