Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate issue-83045, rustc-macro-dep-files and env-dep-info run-make tests to rmake #127381

Merged
merged 3 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/tools/run-make-support/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ use std::path::Path;

use crate::{command, cwd, env_var, set_host_rpath};

/// Construct a new `rustc` invocation.
/// Construct a new `rustc` invocation. This will automatically set the library
/// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.
#[track_caller]
pub fn rustc() -> Rustc {
Rustc::new()
}

/// Construct a plain `rustc` invocation with no flags set.
/// Construct a plain `rustc` invocation with no flags set. Note that [`set_host_rpath`]
/// still presets the environment variable `HOST_RPATH_DIR` by default.
#[track_caller]
pub fn bare_rustc() -> Rustc {
Rustc::bare()
Expand Down Expand Up @@ -42,7 +44,8 @@ fn setup_common() -> Command {
impl Rustc {
// `rustc` invocation constructor methods

/// Construct a new `rustc` invocation.
/// Construct a new `rustc` invocation. This will automatically set the library
/// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.
#[track_caller]
pub fn new() -> Self {
let mut cmd = setup_common();
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 @@ -23,7 +23,6 @@ run-make/dep-info/Makefile
run-make/dump-ice-to-disk/Makefile
run-make/dump-mono-stats/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 @@ -58,7 +57,6 @@ run-make/issue-35164/Makefile
run-make/issue-36710/Makefile
run-make/issue-47551/Makefile
run-make/issue-69368/Makefile
run-make/issue-83045/Makefile
run-make/issue-84395-lto-embed-bitcode/Makefile
run-make/issue-85019-moved-src-dir/Makefile
run-make/issue-85401-static-mir/Makefile
Expand Down Expand Up @@ -116,7 +114,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.

6 changes: 6 additions & 0 deletions tests/run-make/env-dep-info/correct_macro.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
macro_use.d: macro_use.rs

macro_use.rs:

# env-dep:EXISTING_PROC_MACRO_ENV=1
# env-dep:NONEXISTENT_PROC_MACEO_ENV
8 changes: 8 additions & 0 deletions tests/run-make/env-dep-info/correct_main.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
main.d: main.rs

main.rs:

# env-dep:ESCAPE\nESCAPE\\
# env-dep:EXISTING_ENV=1
# env-dep:EXISTING_OPT_ENV=1
# env-dep:NONEXISTENT_OPT_ENV
21 changes: 21 additions & 0 deletions tests/run-make/env-dep-info/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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::{diff, rustc};

fn main() {
rustc()
.env("EXISTING_ENV", "1")
.env("EXISTING_OPT_ENV", "1")
.emit("dep-info")
.input("main.rs")
.run();
diff().expected_file("correct_main.d").actual_file("main.d").run();
// Procedural macro
rustc().input("macro_def.rs").run();
rustc().env("EXISTING_PROC_MACRO_ENV", "1").emit("dep-info").input("macro_use.rs").run();
diff().expected_file("correct_macro.d").actual_file("macro_use.d").run();
}
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.

3 changes: 3 additions & 0 deletions tests/run-make/rustc-macro-dep-files/correct.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bar.d: bar.rs

bar.rs:
14 changes: 14 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,14 @@
// --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::{diff, rustc, target};

fn main() {
rustc().input("foo.rs").run();
rustc().input("bar.rs").target(target()).emit("dep-info").run();
// The emitted file should not contain "proc-macro source".
diff().expected_file("correct.d").actual_file("bar.d").run();
}
Loading