Skip to content

Commit

Permalink
Auto merge of rust-lang#128361 - Oneirical:testle-deforestation, r=ji…
Browse files Browse the repository at this point in the history
…eyouxu

Migrate `link-cfg` and `rustdoc-default-output` `run-make` tests to rmake

Part of rust-lang#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
  • Loading branch information
bors committed Aug 2, 2024
2 parents f82eb4d + c27fa5c commit fd8d6fb
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 31 deletions.
2 changes: 0 additions & 2 deletions src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions tests/run-make/issue-88756-default-output/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion tests/run-make/issue-88756-default-output/README.md

This file was deleted.

1 change: 0 additions & 1 deletion tests/run-make/issue-88756-default-output/x.rs

This file was deleted.

23 changes: 0 additions & 23 deletions tests/run-make/link-cfg/Makefile

This file was deleted.

43 changes: 43 additions & 0 deletions tests/run-make/link-cfg/rmake.rs
Original file line number Diff line number Diff line change
@@ -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");
}
16 changes: 16 additions & 0 deletions tests/run-make/rustdoc-default-output/rmake.rs
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit fd8d6fb

Please sign in to comment.