Skip to content

Commit 4baeeab

Browse files
committed
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
2 parents 5367673 + c9b6648 commit 4baeeab

File tree

8 files changed

+59
-31
lines changed

8 files changed

+59
-31
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ run-make/foreign-exceptions/Makefile
1414
run-make/incr-add-rust-src-component/Makefile
1515
run-make/issue-36710/Makefile
1616
run-make/issue-84395-lto-embed-bitcode/Makefile
17-
run-make/issue-88756-default-output/Makefile
1817
run-make/jobserver-error/Makefile
1918
run-make/libs-through-symlinks/Makefile
2019
run-make/libtest-json/Makefile
2120
run-make/libtest-junit/Makefile
2221
run-make/libtest-thread-limit/Makefile
23-
run-make/link-cfg/Makefile
2422
run-make/long-linker-command-lines-cmd-exe/Makefile
2523
run-make/long-linker-command-lines/Makefile
2624
run-make/macos-deployment-target/Makefile

tests/run-make/issue-88756-default-output/Makefile

-4
This file was deleted.

tests/run-make/issue-88756-default-output/README.md

-1
This file was deleted.

tests/run-make/issue-88756-default-output/x.rs

-1
This file was deleted.

tests/run-make/link-cfg/Makefile

-23
This file was deleted.

tests/run-make/link-cfg/rmake.rs

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// The `#[link(cfg(..))]` annotation means that the `#[link]`
2+
// directive is only active in a compilation unit if that `cfg` value is satisfied.
3+
// For example, when compiling an rlib, these directives are just encoded and
4+
// ignored for dylibs, and all staticlibs are continued to be put into the rlib as
5+
// usual. When placing that rlib into a staticlib, executable, or dylib, however,
6+
// the `cfg` is evaluated *as if it were defined in the final artifact* and the
7+
// library is decided to be linked or not.
8+
// This test exercises this new feature by testing it with no dependencies, then
9+
// with only dynamic libraries, then with both a staticlib and dylibs. Compilation
10+
// and execution should be successful.
11+
// See https://github.com/rust-lang/rust/pull/37545
12+
13+
//@ ignore-cross-compile
14+
// Reason: the compiled binary is executed
15+
16+
use run_make_support::{bare_rustc, build_native_dynamic_lib, build_native_static_lib, run, rustc};
17+
18+
fn main() {
19+
build_native_dynamic_lib("return1");
20+
build_native_dynamic_lib("return2");
21+
build_native_static_lib("return3");
22+
bare_rustc()
23+
.print("cfg")
24+
.target("x86_64-unknown-linux-musl")
25+
.run()
26+
.assert_stdout_contains("crt-static");
27+
rustc().input("no-deps.rs").cfg("foo").run();
28+
run("no-deps");
29+
rustc().input("no-deps.rs").cfg("bar").run();
30+
run("no-deps");
31+
32+
rustc().input("dep.rs").run();
33+
rustc().input("with-deps.rs").cfg("foo").run();
34+
run("with-deps");
35+
rustc().input("with-deps.rs").cfg("bar").run();
36+
run("with-deps");
37+
38+
rustc().input("dep-with-staticlib.rs").run();
39+
rustc().input("with-staticlib-deps.rs").cfg("foo").run();
40+
run("with-staticlib-deps");
41+
rustc().input("with-staticlib-deps.rs").cfg("bar").run();
42+
run("with-staticlib-deps");
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Calling rustdoc with no arguments, which should bring up a help menu, used to
2+
// cause an error as rustdoc expects an input file. Fixed in #98331, this test
3+
// ensures the output of rustdoc's help menu is as expected.
4+
// See https://github.com/rust-lang/rust/issues/88756
5+
6+
use run_make_support::{bare_rustdoc, diff};
7+
8+
fn main() {
9+
let out = bare_rustdoc().run().stdout_utf8();
10+
diff()
11+
.expected_file("output-default.stdout")
12+
.actual_text("actual", out)
13+
// replace the channel type in the URL with $CHANNEL
14+
.normalize(r"/nightly/|beta/|stable/|1\.[0-9]+\.[0-9]+/", "/$$CHANNEL/")
15+
.run();
16+
}

0 commit comments

Comments
 (0)