rewrite many-crates-but-no-match to rmake

This commit is contained in:
Oneirical 2024-06-26 14:02:05 -04:00
parent c6bb357502
commit b94eae5877
3 changed files with 31 additions and 36 deletions

View file

@ -100,7 +100,6 @@ 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

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.
}