Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7f5442e

Browse files
authoredJun 17, 2024
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).
2 parents 6dd6ad5 + 6fffe84 commit 7f5442e

File tree

11 files changed

+134
-58
lines changed

11 files changed

+134
-58
lines changed
 

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ run-make/emit-shared-files/Makefile
3535
run-make/emit-stack-sizes/Makefile
3636
run-make/emit-to-stdout/Makefile
3737
run-make/env-dep-info/Makefile
38-
run-make/error-found-staticlib-instead-crate/Makefile
3938
run-make/error-writing-dependencies/Makefile
4039
run-make/export-executable-symbols/Makefile
4140
run-make/extern-diff-internal-name/Makefile
@@ -133,17 +132,13 @@ run-make/missing-crate-dependency/Makefile
133132
run-make/mixing-libs/Makefile
134133
run-make/msvc-opt-minsize/Makefile
135134
run-make/native-link-modifier-bundle/Makefile
136-
run-make/native-link-modifier-verbatim-linker/Makefile
137-
run-make/native-link-modifier-verbatim-rustc/Makefile
138135
run-make/native-link-modifier-whole-archive/Makefile
139136
run-make/no-alloc-shim/Makefile
140137
run-make/no-builtins-attribute/Makefile
141138
run-make/no-duplicate-libs/Makefile
142139
run-make/obey-crate-type-flag/Makefile
143140
run-make/optimization-remarks-dir-pgo/Makefile
144141
run-make/optimization-remarks-dir/Makefile
145-
run-make/output-filename-conflicts-with-directory/Makefile
146-
run-make/output-filename-overwrites-input/Makefile
147142
run-make/output-type-permutations/Makefile
148143
run-make/override-aliased-flags/Makefile
149144
run-make/overwrite-input/Makefile

‎tests/run-make/error-found-staticlib-instead-crate/Makefile

-5
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// When rustc is looking for a crate but is given a staticlib instead,
2+
// the error message should be helpful and indicate precisely the cause
3+
// of the compilation failure.
4+
// See https://github.com/rust-lang/rust/pull/21978
5+
6+
use run_make_support::rustc;
7+
8+
fn main() {
9+
rustc().input("foo.rs").crate_type("staticlib").run();
10+
rustc().input("bar.rs").run_fail().assert_stderr_contains("found staticlib");
11+
}

‎tests/run-make/native-link-modifier-verbatim-linker/Makefile

-15
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// `verbatim` is a native link modifier that forces rustc to only accept libraries with
2+
// a specified name. This test checks that this modifier works as intended.
3+
// This test is the same as native-link-modifier-rustc, but without rlibs.
4+
// See https://github.com/rust-lang/rust/issues/99425
5+
6+
//@ ignore-apple
7+
// Reason: linking fails due to the unusual ".ext" staticlib name.
8+
9+
use run_make_support::rustc;
10+
11+
fn main() {
12+
// Verbatim allows for the specification of a precise name
13+
// - in this case, the unconventional ".ext" extension.
14+
rustc()
15+
.input("local_native_dep.rs")
16+
.crate_type("staticlib")
17+
.output("local_some_strange_name.ext")
18+
.run();
19+
rustc().input("main.rs").arg("-lstatic:+verbatim=local_some_strange_name.ext").run();
20+
21+
// This section voluntarily avoids using static_lib_name helpers to be verbatim.
22+
// With verbatim, even these common library names are refused
23+
// - it wants local_native_dep without
24+
// any file extensions.
25+
rustc()
26+
.input("local_native_dep.rs")
27+
.crate_type("staticlib")
28+
.output("liblocal_native_dep.a")
29+
.run();
30+
rustc().input("local_native_dep.rs").crate_type("staticlib").output("local_native_dep.a").run();
31+
rustc()
32+
.input("local_native_dep.rs")
33+
.crate_type("staticlib")
34+
.output("local_native_dep.lib")
35+
.run();
36+
rustc()
37+
.input("main.rs")
38+
.arg("-lstatic:+verbatim=local_native_dep")
39+
.run_fail()
40+
.assert_stderr_contains("local_native_dep");
41+
}

‎tests/run-make/native-link-modifier-verbatim-rustc/Makefile

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// `verbatim` is a native link modifier that forces rustc to only accept libraries with
2+
// a specified name. This test checks that this modifier works as intended.
3+
// This test is the same as native-link-modifier-linker, but with rlibs.
4+
// See https://github.com/rust-lang/rust/issues/99425
5+
6+
use run_make_support::rustc;
7+
8+
fn main() {
9+
// Verbatim allows for the specification of a precise name
10+
// - in this case, the unconventional ".ext" extension.
11+
rustc()
12+
.input("upstream_native_dep.rs")
13+
.crate_type("staticlib")
14+
.output("upstream_some_strange_name.ext")
15+
.run();
16+
rustc()
17+
.input("rust_dep.rs")
18+
.crate_type("rlib")
19+
.arg("-lstatic:+verbatim=upstream_some_strange_name.ext")
20+
.run();
21+
22+
// This section voluntarily avoids using static_lib_name helpers to be verbatim.
23+
// With verbatim, even these common library names are refused
24+
// - it wants upstream_native_dep without
25+
// any file extensions.
26+
rustc()
27+
.input("upstream_native_dep.rs")
28+
.crate_type("staticlib")
29+
.output("libupstream_native_dep.a")
30+
.run();
31+
rustc()
32+
.input("upstream_native_dep.rs")
33+
.crate_type("staticlib")
34+
.output("upstream_native_dep.a")
35+
.run();
36+
rustc()
37+
.input("upstream_native_dep.rs")
38+
.crate_type("staticlib")
39+
.output("upstream_native_dep.lib")
40+
.run();
41+
rustc()
42+
.input("rust_dep.rs")
43+
.crate_type("rlib")
44+
.arg("-lstatic:+verbatim=upstream_native_dep")
45+
.run_fail()
46+
.assert_stderr_contains("upstream_native_dep");
47+
}

‎tests/run-make/output-filename-conflicts-with-directory/Makefile

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// ignore-tidy-linelength
2+
// When the compiled executable would conflict with a directory, a
3+
// rustc error should be displayed instead of a verbose and
4+
// potentially-confusing linker error.
5+
// See https://github.com/rust-lang/rust/pull/47203
6+
7+
use run_make_support::{fs_wrapper, rustc};
8+
9+
fn main() {
10+
fs_wrapper::create_dir("foo");
11+
rustc().input("foo.rs").output("foo").run_fail().assert_stderr_contains(
12+
r#"the generated executable for the input file "foo.rs" conflicts with the existing directory "foo""#,
13+
);
14+
}

‎tests/run-make/output-filename-overwrites-input/Makefile

-14
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// If rustc is invoked on a file that would be overwritten by the
2+
// compilation, the compilation should fail, to avoid accidental loss.
3+
// See https://github.com/rust-lang/rust/pull/46814
4+
5+
//@ ignore-cross-compile
6+
7+
use run_make_support::{fs_wrapper, rustc};
8+
9+
fn main() {
10+
fs_wrapper::copy("foo.rs", "foo");
11+
rustc().input("foo").output("foo").run_fail().assert_stderr_contains(
12+
r#"the input file "foo" would be overwritten by the generated executable"#,
13+
);
14+
fs_wrapper::copy("bar.rs", "bar.rlib");
15+
rustc().input("bar.rlib").output("bar.rlib").run_fail().assert_stderr_contains(
16+
r#"the input file "bar.rlib" would be overwritten by the generated executable"#,
17+
);
18+
rustc().input("foo.rs").output("foo.rs").run_fail().assert_stderr_contains(
19+
r#"the input file "foo.rs" would be overwritten by the generated executable"#,
20+
);
21+
}

0 commit comments

Comments
 (0)
Failed to load comments.