Skip to content

Commit

Permalink
Auto merge of rust-lang#127381 - Oneirical:testalt-consciousness, r=<…
Browse files Browse the repository at this point in the history
…try>

Migrate `issue-83045`, `rustc-macro-dep-files` and `env-dep-info` `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).

Please try on musl.

try-job: dist-x86_64-musl
  • Loading branch information
bors committed Jul 6, 2024
2 parents 51917e2 + 13115ce commit 90002cd
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 69 deletions.
2 changes: 1 addition & 1 deletion src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub use llvm::{
LlvmProfdata, LlvmReadobj,
};
pub use run::{cmd, run, run_fail, run_with_args};
pub use rustc::{aux_build, rustc, Rustc};
pub use rustc::{aux_build, bare_rustc, rustc, Rustc};
pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};

#[track_caller]
Expand Down
17 changes: 15 additions & 2 deletions src/tools/run-make-support/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ pub fn rustc() -> Rustc {
Rustc::new()
}

/// Construct a new `rustc` aux-build invocation.
/// Construct a plain `rustc` invocation with no flags set.
#[track_caller]
pub fn bare_rustc() -> Rustc {
Rustc::bare()
}

// Construct a new `rustc` aux-build invocation.
#[track_caller]
pub fn aux_build() -> Rustc {
Rustc::new_aux_build()
Expand All @@ -30,7 +36,6 @@ fn setup_common() -> Command {
let rustc = env_var("RUSTC");
let mut cmd = Command::new(rustc);
set_host_rpath(&mut cmd);
cmd.arg("-L").arg(cwd());
cmd
}

Expand All @@ -40,6 +45,14 @@ impl Rustc {
/// Construct a new `rustc` invocation.
#[track_caller]
pub fn new() -> Self {
let mut cmd = setup_common();
cmd.arg("-L").arg(cwd());
Self { cmd }
}

/// Construct a bare `rustc` invocation with no flags set.
#[track_caller]
pub fn bare() -> Self {
let cmd = setup_common();
Self { cmd }
}
Expand Down
3 changes: 0 additions & 3 deletions src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ run-make/dump-mono-stats/Makefile
run-make/emit-path-unhashed/Makefile
run-make/emit-shared-files/Makefile
run-make/emit-to-stdout/Makefile
run-make/env-dep-info/Makefile
run-make/export-executable-symbols/Makefile
run-make/extern-diff-internal-name/Makefile
run-make/extern-flag-disambiguates/Makefile
Expand Down Expand Up @@ -65,7 +64,6 @@ run-make/issue-36710/Makefile
run-make/issue-37839/Makefile
run-make/issue-47551/Makefile
run-make/issue-69368/Makefile
run-make/issue-83045/Makefile
run-make/issue-83112-incr-test-moved-file/Makefile
run-make/issue-84395-lto-embed-bitcode/Makefile
run-make/issue-85019-moved-src-dir/Makefile
Expand Down Expand Up @@ -129,7 +127,6 @@ run-make/return-non-c-like-enum-from-c/Makefile
run-make/rlib-format-packed-bundled-libs-2/Makefile
run-make/rlib-format-packed-bundled-libs-3/Makefile
run-make/rlib-format-packed-bundled-libs/Makefile
run-make/rustc-macro-dep-files/Makefile
run-make/sanitizer-cdylib-link/Makefile
run-make/sanitizer-dylib-link/Makefile
run-make/sanitizer-staticlib-link/Makefile
Expand Down
19 changes: 0 additions & 19 deletions tests/run-make/env-dep-info/Makefile

This file was deleted.

29 changes: 29 additions & 0 deletions tests/run-make/env-dep-info/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Inside dep-info emit files, #71858 made it so all accessed environment
// variables are usefully printed. This test checks that this feature works
// as intended by checking if the environment variables used in compilation
// appear in the output dep-info files.
// See https://github.com/rust-lang/rust/issues/40364

use run_make_support::{fs_wrapper, rustc};

// FIXME(Oneirical): try on musl

fn main() {
rustc()
.env("EXISTING_ENV", "1")
.env("EXISTING_OPT_ENV", "1")
.emit("dep-info")
.input("main.rs")
.run();
let dep_info = fs_wrapper::read_to_string("main.d");
assert!(&dep_info.contains("# env-dep:EXISTING_ENV=1"));
assert!(&dep_info.contains("# env-dep:EXISTING_OPT_ENV=1"));
assert!(&dep_info.contains("# env-dep:NONEXISTENT_OPT_ENV"));
assert!(dep_info.contains(r#"# env-dep:ESCAPE\nESCAPE\\"#));
// Procedural macro
rustc().input("macro_def.rs").run();
rustc().env("EXISTING_PROC_MACRO_ENV", "1").emit("dep-info").input("macro_use.rs").run();
let dep_info = fs_wrapper::read_to_string("macro_use.d");
assert!(&dep_info.contains("# env-dep:EXISTING_PROC_MACRO_ENV=1"));
assert!(dep_info.contains("# env-dep:NONEXISTENT_PROC_MACEO_ENV"));
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions tests/run-make/ice-dep-cannot-find-dep/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// This test case creates a situation where the crate loader would run
// into an ICE (internal compiler error) when confronted with an invalid setup where it cannot
// find the dependency of a direct dependency.
//
// The test case makes sure that the compiler produces the expected
// error message but does not ICE immediately after.
//
// See https://github.com/rust-lang/rust/issues/83045

//@ only-x86_64
//@ only-linux
// Reason: This is a platform-independent issue, no need to waste time testing
// everywhere.

// NOTE: We use `bare_rustc` below so that the compiler can't find liba.rlib
// If we used `rustc` the additional '-L rmake_out' option would allow rustc to
// actually find the crate.

use run_make_support::{bare_rustc, fs_wrapper, rust_lib_name, rustc};

fn main() {
rustc().crate_name("a").crate_type("rlib").input("a.rs").arg("--verbose").run();
rustc()
.crate_name("b")
.crate_type("rlib")
.extern_("a", rust_lib_name("a"))
.input("b.rs")
.arg("--verbose")
.run();
bare_rustc()
.extern_("b", rust_lib_name("b"))
.crate_type("rlib")
.edition("2018")
.input("c.rs")
.run_fail()
.assert_stderr_contains("E0463")
.assert_stderr_not_contains("internal compiler error");
}
33 changes: 0 additions & 33 deletions tests/run-make/issue-83045/Makefile

This file was deleted.

11 changes: 0 additions & 11 deletions tests/run-make/rustc-macro-dep-files/Makefile

This file was deleted.

13 changes: 13 additions & 0 deletions tests/run-make/rustc-macro-dep-files/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// --emit dep-info used to print all macro-generated code it could
// find as if it was part of a nonexistent file named "proc-macro source",
// which is not a valid path. After this was fixed in #36776, this test checks
// that macro code is not falsely seen as coming from a different file in dep-info.
// See https://github.com/rust-lang/rust/issues/36625

use run_make_support::{fs_wrapper, rustc, target};

fn main() {
rustc().input("foo.rs").run();
rustc().input("bar.rs").target(target()).emit("dep-info").run();
assert!(!fs_wrapper::read_to_string("bar.d").contains("proc-macro source"));
}

0 comments on commit 90002cd

Please sign in to comment.