about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-08-02 18:24:21 +0000
committerbors <bors@rust-lang.org>2024-08-02 18:24:21 +0000
commitfd8d6fbe505ecf913f5e2ca590c69a7da2789879 (patch)
treec8e9f182e541c3fb63d99ae4b111c795b30ea73a
parentf82eb4d0a01e2dc782e582f7081439e172b858f9 (diff)
parentc27fa5c3329d4f7fce200043c3117bc1a548f025 (diff)
downloadrust-fd8d6fbe505ecf913f5e2ca590c69a7da2789879.tar.gz
rust-fd8d6fbe505ecf913f5e2ca590c69a7da2789879.zip
Auto merge of #128361 - Oneirical:testle-deforestation, r=jieyouxu
Migrate `link-cfg` and `rustdoc-default-output` `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).

try-job: aarch64-apple
try-job: x86_64-msvc
try-job: x86_64-mingw
try-job: x86_64-gnu-llvm-18
try-job: i686-msvc
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt2
-rw-r--r--tests/run-make/issue-88756-default-output/Makefile4
-rw-r--r--tests/run-make/issue-88756-default-output/README.md1
-rw-r--r--tests/run-make/issue-88756-default-output/x.rs1
-rw-r--r--tests/run-make/link-cfg/Makefile23
-rw-r--r--tests/run-make/link-cfg/rmake.rs43
-rw-r--r--tests/run-make/rustdoc-default-output/output-default.stdout (renamed from tests/run-make/issue-88756-default-output/output-default.stdout)0
-rw-r--r--tests/run-make/rustdoc-default-output/rmake.rs16
8 files changed, 59 insertions, 31 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index bd4f54d22da..2561df2e477 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -11,13 +11,11 @@ run-make/emit-to-stdout/Makefile
 run-make/extern-fn-reachable/Makefile
 run-make/incr-add-rust-src-component/Makefile
 run-make/issue-84395-lto-embed-bitcode/Makefile
-run-make/issue-88756-default-output/Makefile
 run-make/jobserver-error/Makefile
 run-make/libs-through-symlinks/Makefile
 run-make/libtest-json/Makefile
 run-make/libtest-junit/Makefile
 run-make/libtest-thread-limit/Makefile
-run-make/link-cfg/Makefile
 run-make/long-linker-command-lines-cmd-exe/Makefile
 run-make/long-linker-command-lines/Makefile
 run-make/macos-deployment-target/Makefile
diff --git a/tests/run-make/issue-88756-default-output/Makefile b/tests/run-make/issue-88756-default-output/Makefile
deleted file mode 100644
index d1c3d0fe082..00000000000
--- a/tests/run-make/issue-88756-default-output/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-include ../tools.mk
-
-all:
-	$(BARE_RUSTDOC) 2>&1 | sed -E 's@/nightly/|/beta/|/stable/|/1\.[0-9]+\.[0-9]+/@/$$CHANNEL/@g' | diff - output-default.stdout
diff --git a/tests/run-make/issue-88756-default-output/README.md b/tests/run-make/issue-88756-default-output/README.md
deleted file mode 100644
index 8cbfac4f7d2..00000000000
--- a/tests/run-make/issue-88756-default-output/README.md
+++ /dev/null
@@ -1 +0,0 @@
-This is a test to verify that the default behavior of `rustdoc` is printing out help output instead of erroring out (#88756).
diff --git a/tests/run-make/issue-88756-default-output/x.rs b/tests/run-make/issue-88756-default-output/x.rs
deleted file mode 100644
index 5df7576133a..00000000000
--- a/tests/run-make/issue-88756-default-output/x.rs
+++ /dev/null
@@ -1 +0,0 @@
-// nothing to see here
diff --git a/tests/run-make/link-cfg/Makefile b/tests/run-make/link-cfg/Makefile
deleted file mode 100644
index a4099701144..00000000000
--- a/tests/run-make/link-cfg/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# ignore-cross-compile
-include ../tools.mk
-
-all: $(call DYLIB,return1) $(call DYLIB,return2) $(call NATIVE_STATICLIB,return3)
-	ls $(TMPDIR)
-	$(BARE_RUSTC) --print cfg --target x86_64-unknown-linux-musl | $(CGREP) crt-static
-
-	$(RUSTC) no-deps.rs --cfg foo
-	$(call RUN,no-deps)
-	$(RUSTC) no-deps.rs --cfg bar
-	$(call RUN,no-deps)
-
-	$(RUSTC) dep.rs
-	$(RUSTC) with-deps.rs --cfg foo
-	$(call RUN,with-deps)
-	$(RUSTC) with-deps.rs --cfg bar
-	$(call RUN,with-deps)
-
-	$(RUSTC) dep-with-staticlib.rs
-	$(RUSTC) with-staticlib-deps.rs --cfg foo
-	$(call RUN,with-staticlib-deps)
-	$(RUSTC) with-staticlib-deps.rs --cfg bar
-	$(call RUN,with-staticlib-deps)
diff --git a/tests/run-make/link-cfg/rmake.rs b/tests/run-make/link-cfg/rmake.rs
new file mode 100644
index 00000000000..732de5dbd0b
--- /dev/null
+++ b/tests/run-make/link-cfg/rmake.rs
@@ -0,0 +1,43 @@
+// The `#[link(cfg(..))]` annotation means that the `#[link]`
+// directive is only active in a compilation unit if that `cfg` value is satisfied.
+// For example, when compiling an rlib, these directives are just encoded and
+// ignored for dylibs, and all staticlibs are continued to be put into the rlib as
+// usual. When placing that rlib into a staticlib, executable, or dylib, however,
+// the `cfg` is evaluated *as if it were defined in the final artifact* and the
+// library is decided to be linked or not.
+// This test exercises this new feature by testing it with no dependencies, then
+// with only dynamic libraries, then with both a staticlib and dylibs. Compilation
+// and execution should be successful.
+// See https://github.com/rust-lang/rust/pull/37545
+
+//@ ignore-cross-compile
+// Reason: the compiled binary is executed
+
+use run_make_support::{bare_rustc, build_native_dynamic_lib, build_native_static_lib, run, rustc};
+
+fn main() {
+    build_native_dynamic_lib("return1");
+    build_native_dynamic_lib("return2");
+    build_native_static_lib("return3");
+    bare_rustc()
+        .print("cfg")
+        .target("x86_64-unknown-linux-musl")
+        .run()
+        .assert_stdout_contains("crt-static");
+    rustc().input("no-deps.rs").cfg("foo").run();
+    run("no-deps");
+    rustc().input("no-deps.rs").cfg("bar").run();
+    run("no-deps");
+
+    rustc().input("dep.rs").run();
+    rustc().input("with-deps.rs").cfg("foo").run();
+    run("with-deps");
+    rustc().input("with-deps.rs").cfg("bar").run();
+    run("with-deps");
+
+    rustc().input("dep-with-staticlib.rs").run();
+    rustc().input("with-staticlib-deps.rs").cfg("foo").run();
+    run("with-staticlib-deps");
+    rustc().input("with-staticlib-deps.rs").cfg("bar").run();
+    run("with-staticlib-deps");
+}
diff --git a/tests/run-make/issue-88756-default-output/output-default.stdout b/tests/run-make/rustdoc-default-output/output-default.stdout
index bc38d9e9dc6..bc38d9e9dc6 100644
--- a/tests/run-make/issue-88756-default-output/output-default.stdout
+++ b/tests/run-make/rustdoc-default-output/output-default.stdout
diff --git a/tests/run-make/rustdoc-default-output/rmake.rs b/tests/run-make/rustdoc-default-output/rmake.rs
new file mode 100644
index 00000000000..06720445a35
--- /dev/null
+++ b/tests/run-make/rustdoc-default-output/rmake.rs
@@ -0,0 +1,16 @@
+// Calling rustdoc with no arguments, which should bring up a help menu, used to
+// cause an error as rustdoc expects an input file. Fixed in #98331, this test
+// ensures the output of rustdoc's help menu is as expected.
+// See https://github.com/rust-lang/rust/issues/88756
+
+use run_make_support::{bare_rustdoc, diff};
+
+fn main() {
+    let out = bare_rustdoc().run().stdout_utf8();
+    diff()
+        .expected_file("output-default.stdout")
+        .actual_text("actual", out)
+        // replace the channel type in the URL with $CHANNEL
+        .normalize(r"nightly/|beta/|stable/|1\.[0-9]+\.[0-9]+/", "$$CHANNEL/")
+        .run();
+}