forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#126500 - Oneirical:test-for-the-holy-grail, r=jieyouxu Migrate `error-found-staticlib-instead-crate`, `output-filename-conflicts-with-directory`, `output-filename-overwrites-input`, `native-link-modifier-verbatim-rustc` and `native-link-verbatim-linker` `run-make` tests to `rmake.rs` format 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).
- Loading branch information
Showing
11 changed files
with
134 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
tests/run-make/error-found-staticlib-instead-crate/rmake.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// When rustc is looking for a crate but is given a staticlib instead, | ||
// the error message should be helpful and indicate precisely the cause | ||
// of the compilation failure. | ||
// See https://github.com/rust-lang/rust/pull/21978 | ||
|
||
use run_make_support::rustc; | ||
|
||
fn main() { | ||
rustc().input("foo.rs").crate_type("staticlib").run(); | ||
rustc().input("bar.rs").run_fail().assert_stderr_contains("found staticlib"); | ||
} |
15 changes: 0 additions & 15 deletions
15
tests/run-make/native-link-modifier-verbatim-linker/Makefile
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
tests/run-make/native-link-modifier-verbatim-linker/rmake.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// `verbatim` is a native link modifier that forces rustc to only accept libraries with | ||
// a specified name. This test checks that this modifier works as intended. | ||
// This test is the same as native-link-modifier-rustc, but without rlibs. | ||
// See https://github.com/rust-lang/rust/issues/99425 | ||
|
||
//@ ignore-apple | ||
// Reason: linking fails due to the unusual ".ext" staticlib name. | ||
|
||
use run_make_support::rustc; | ||
|
||
fn main() { | ||
// Verbatim allows for the specification of a precise name | ||
// - in this case, the unconventional ".ext" extension. | ||
rustc() | ||
.input("local_native_dep.rs") | ||
.crate_type("staticlib") | ||
.output("local_some_strange_name.ext") | ||
.run(); | ||
rustc().input("main.rs").arg("-lstatic:+verbatim=local_some_strange_name.ext").run(); | ||
|
||
// This section voluntarily avoids using static_lib_name helpers to be verbatim. | ||
// With verbatim, even these common library names are refused | ||
// - it wants local_native_dep without | ||
// any file extensions. | ||
rustc() | ||
.input("local_native_dep.rs") | ||
.crate_type("staticlib") | ||
.output("liblocal_native_dep.a") | ||
.run(); | ||
rustc().input("local_native_dep.rs").crate_type("staticlib").output("local_native_dep.a").run(); | ||
rustc() | ||
.input("local_native_dep.rs") | ||
.crate_type("staticlib") | ||
.output("local_native_dep.lib") | ||
.run(); | ||
rustc() | ||
.input("main.rs") | ||
.arg("-lstatic:+verbatim=local_native_dep") | ||
.run_fail() | ||
.assert_stderr_contains("local_native_dep"); | ||
} |
12 changes: 0 additions & 12 deletions
12
tests/run-make/native-link-modifier-verbatim-rustc/Makefile
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
tests/run-make/native-link-modifier-verbatim-rustc/rmake.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// `verbatim` is a native link modifier that forces rustc to only accept libraries with | ||
// a specified name. This test checks that this modifier works as intended. | ||
// This test is the same as native-link-modifier-linker, but with rlibs. | ||
// See https://github.com/rust-lang/rust/issues/99425 | ||
|
||
use run_make_support::rustc; | ||
|
||
fn main() { | ||
// Verbatim allows for the specification of a precise name | ||
// - in this case, the unconventional ".ext" extension. | ||
rustc() | ||
.input("upstream_native_dep.rs") | ||
.crate_type("staticlib") | ||
.output("upstream_some_strange_name.ext") | ||
.run(); | ||
rustc() | ||
.input("rust_dep.rs") | ||
.crate_type("rlib") | ||
.arg("-lstatic:+verbatim=upstream_some_strange_name.ext") | ||
.run(); | ||
|
||
// This section voluntarily avoids using static_lib_name helpers to be verbatim. | ||
// With verbatim, even these common library names are refused | ||
// - it wants upstream_native_dep without | ||
// any file extensions. | ||
rustc() | ||
.input("upstream_native_dep.rs") | ||
.crate_type("staticlib") | ||
.output("libupstream_native_dep.a") | ||
.run(); | ||
rustc() | ||
.input("upstream_native_dep.rs") | ||
.crate_type("staticlib") | ||
.output("upstream_native_dep.a") | ||
.run(); | ||
rustc() | ||
.input("upstream_native_dep.rs") | ||
.crate_type("staticlib") | ||
.output("upstream_native_dep.lib") | ||
.run(); | ||
rustc() | ||
.input("rust_dep.rs") | ||
.crate_type("rlib") | ||
.arg("-lstatic:+verbatim=upstream_native_dep") | ||
.run_fail() | ||
.assert_stderr_contains("upstream_native_dep"); | ||
} |
7 changes: 0 additions & 7 deletions
7
tests/run-make/output-filename-conflicts-with-directory/Makefile
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
tests/run-make/output-filename-conflicts-with-directory/rmake.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// ignore-tidy-linelength | ||
// When the compiled executable would conflict with a directory, a | ||
// rustc error should be displayed instead of a verbose and | ||
// potentially-confusing linker error. | ||
// See https://github.com/rust-lang/rust/pull/47203 | ||
|
||
use run_make_support::{fs_wrapper, rustc}; | ||
|
||
fn main() { | ||
fs_wrapper::create_dir("foo"); | ||
rustc().input("foo.rs").output("foo").run_fail().assert_stderr_contains( | ||
r#"the generated executable for the input file "foo.rs" conflicts with the existing directory "foo""#, | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// If rustc is invoked on a file that would be overwritten by the | ||
// compilation, the compilation should fail, to avoid accidental loss. | ||
// See https://github.com/rust-lang/rust/pull/46814 | ||
|
||
//@ ignore-cross-compile | ||
|
||
use run_make_support::{fs_wrapper, rustc}; | ||
|
||
fn main() { | ||
fs_wrapper::copy("foo.rs", "foo"); | ||
rustc().input("foo").output("foo").run_fail().assert_stderr_contains( | ||
r#"the input file "foo" would be overwritten by the generated executable"#, | ||
); | ||
fs_wrapper::copy("bar.rs", "bar.rlib"); | ||
rustc().input("bar.rlib").output("bar.rlib").run_fail().assert_stderr_contains( | ||
r#"the input file "bar.rlib" would be overwritten by the generated executable"#, | ||
); | ||
rustc().input("foo.rs").output("foo.rs").run_fail().assert_stderr_contains( | ||
r#"the input file "foo.rs" would be overwritten by the generated executable"#, | ||
); | ||
} |