about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-06-14 13:42:42 -0400
committerOneirical <manchot@videotron.ca>2024-06-14 13:42:42 -0400
commita3b7c2993ed969e4abb3ad196c7abe3e05d88a93 (patch)
tree4987485bb533f5dd9eb1eccdfb614ea9c1b94d66
parent7ac6c2fc685681824fbfc156b38035df743881dd (diff)
downloadrust-a3b7c2993ed969e4abb3ad196c7abe3e05d88a93.tar.gz
rust-a3b7c2993ed969e4abb3ad196c7abe3e05d88a93.zip
rewrite extern-flag-fun to rmake
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/extern-flag-fun/Makefile20
-rw-r--r--tests/run-make/extern-flag-fun/rmake.rs36
3 files changed, 36 insertions, 21 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index be9df226d64..ec184c2c214 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -43,7 +43,6 @@ run-make/error-writing-dependencies/Makefile
 run-make/export-executable-symbols/Makefile
 run-make/extern-diff-internal-name/Makefile
 run-make/extern-flag-disambiguates/Makefile
-run-make/extern-flag-fun/Makefile
 run-make/extern-flag-pathless/Makefile
 run-make/extern-flag-rename-transitive/Makefile
 run-make/extern-fn-explicit-align/Makefile
diff --git a/tests/run-make/extern-flag-fun/Makefile b/tests/run-make/extern-flag-fun/Makefile
deleted file mode 100644
index 687cdfd7675..00000000000
--- a/tests/run-make/extern-flag-fun/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# ignore-cross-compile
-include ../tools.mk
-
-all:
-	$(RUSTC) bar.rs --crate-type=rlib
-	$(RUSTC) bar.rs --crate-type=rlib -C extra-filename=-a
-	$(RUSTC) bar-alt.rs --crate-type=rlib
-	$(RUSTC) foo.rs --extern bar=no-exist && exit 1 || exit 0
-	$(RUSTC) foo.rs --extern bar=foo.rs && exit 1 || exit 0
-	$(RUSTC) foo.rs \
-		--extern bar=$(TMPDIR)/libbar.rlib \
-		--extern bar=$(TMPDIR)/libbar-alt.rlib \
-		&& exit 1 || exit 0
-	$(RUSTC) foo.rs \
-		--extern bar=$(TMPDIR)/libbar.rlib \
-		--extern bar=$(TMPDIR)/libbar-a.rlib
-	$(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib
-	# Try to be sneaky and load a private crate from with a non-private name.
-	$(RUSTC) rustc.rs -Zforce-unstable-if-unmarked --crate-type=rlib
-	$(RUSTC) gated_unstable.rs --extern alloc=$(TMPDIR)/librustc.rlib 2>&1 | $(CGREP) 'rustc_private'
diff --git a/tests/run-make/extern-flag-fun/rmake.rs b/tests/run-make/extern-flag-fun/rmake.rs
new file mode 100644
index 00000000000..10fec6e30b4
--- /dev/null
+++ b/tests/run-make/extern-flag-fun/rmake.rs
@@ -0,0 +1,36 @@
+// The --extern flag can override the default crate search of
+// the compiler and directly fetch a given path. There are a few rules
+// to follow: for example, there can't be more than one rlib, the crates must
+// be valid ("no-exist" in this test), and private crates can't be loaded
+// as non-private. This test checks that these rules are enforced.
+// See https://github.com/rust-lang/rust/pull/15319
+
+//@ ignore-cross-compile
+
+use run_make_support::{rust_lib_name, rustc};
+
+fn main() {
+    rustc().input("bar.rs").crate_type("rlib").run();
+    rustc().input("bar.rs").crate_type("rlib").extra_filename("-a").run();
+    rustc().input("bar-alt.rs").crate_type("rlib").run();
+    rustc().input("foo.rs").extern_("bar", "no-exist").run_fail();
+    rustc().input("foo.rs").extern_("bar", "foo.rs").run_fail();
+    rustc()
+        .input("foo.rs")
+        .extern_("bar", rust_lib_name("bar"))
+        .extern_("bar", rust_lib_name("bar-alt"))
+        .run_fail();
+    rustc()
+        .input("foo.rs")
+        .extern_("bar", rust_lib_name("bar"))
+        .extern_("bar", rust_lib_name("bar-a"))
+        .run();
+    rustc().input("foo.rs").extern_("bar", rust_lib_name("bar")).run();
+    // Try to be sneaky and load a private crate from with a non-private name.
+    rustc().input("rustc.rs").arg("-Zforce-unstable-if-unmarked").crate_type("rlib").run();
+    rustc()
+        .input("gated_unstable.rs")
+        .extern_("alloc", rust_lib_name("rustc"))
+        .run_fail()
+        .assert_stderr_contains("rustc_private");
+}