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 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 #126500

Merged
merged 5 commits into from
Jun 18, 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
5 changes: 0 additions & 5 deletions src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ run-make/emit-shared-files/Makefile
run-make/emit-stack-sizes/Makefile
run-make/emit-to-stdout/Makefile
run-make/env-dep-info/Makefile
run-make/error-found-staticlib-instead-crate/Makefile
run-make/error-writing-dependencies/Makefile
run-make/export-executable-symbols/Makefile
run-make/extern-diff-internal-name/Makefile
Expand Down Expand Up @@ -143,8 +142,6 @@ run-make/missing-crate-dependency/Makefile
run-make/mixing-libs/Makefile
run-make/msvc-opt-minsize/Makefile
run-make/native-link-modifier-bundle/Makefile
run-make/native-link-modifier-verbatim-linker/Makefile
run-make/native-link-modifier-verbatim-rustc/Makefile
run-make/native-link-modifier-whole-archive/Makefile
run-make/no-alloc-shim/Makefile
run-make/no-builtins-attribute/Makefile
Expand All @@ -153,8 +150,6 @@ run-make/no-duplicate-libs/Makefile
run-make/obey-crate-type-flag/Makefile
run-make/optimization-remarks-dir-pgo/Makefile
run-make/optimization-remarks-dir/Makefile
run-make/output-filename-conflicts-with-directory/Makefile
run-make/output-filename-overwrites-input/Makefile
run-make/output-type-permutations/Makefile
run-make/output-with-hyphens/Makefile
run-make/override-aliased-flags/Makefile
Expand Down
5 changes: 0 additions & 5 deletions tests/run-make/error-found-staticlib-instead-crate/Makefile

This file was deleted.

11 changes: 11 additions & 0 deletions tests/run-make/error-found-staticlib-instead-crate/rmake.rs
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 tests/run-make/native-link-modifier-verbatim-linker/Makefile

This file was deleted.

41 changes: 41 additions & 0 deletions tests/run-make/native-link-modifier-verbatim-linker/rmake.rs
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 tests/run-make/native-link-modifier-verbatim-rustc/Makefile

This file was deleted.

47 changes: 47 additions & 0 deletions tests/run-make/native-link-modifier-verbatim-rustc/rmake.rs
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");
}

This file was deleted.

14 changes: 14 additions & 0 deletions tests/run-make/output-filename-conflicts-with-directory/rmake.rs
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""#,
);
}
14 changes: 0 additions & 14 deletions tests/run-make/output-filename-overwrites-input/Makefile

This file was deleted.

21 changes: 21 additions & 0 deletions tests/run-make/output-filename-overwrites-input/rmake.rs
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"#,
);
}
Loading