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 b0a563a

Browse files
committedJun 3, 2024·
Auto merge of rust-lang#125383 - Oneirical:bundle-them-up, r=<try>
Rewrite `emit`, `mixing-formats` and `bare-outfile` `run-make` tests in `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). try-job: x86_64-msvc
2 parents 1d52972 + 6e120cf commit b0a563a

File tree

8 files changed

+130
-111
lines changed

8 files changed

+130
-111
lines changed
 

‎src/tools/run-make-support/src/run.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use std::process::{Command, Output};
44

55
use crate::is_windows;
66

7-
use super::{bin_name, handle_failed_output};
7+
use super::handle_failed_output;
88

99
fn run_common(name: &str) -> (Command, Output) {
1010
let mut bin_path = PathBuf::new();
1111
bin_path.push(env::var("TMPDIR").unwrap());
12-
bin_path.push(&bin_name(name));
12+
bin_path.push(name);
1313
let ld_lib_path_envvar = env::var("LD_LIB_PATH_ENVVAR").unwrap();
1414
let mut cmd = Command::new(bin_path);
1515
cmd.env(&ld_lib_path_envvar, {

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

-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ run-make/allocator-shim-circular-deps/Makefile
22
run-make/allow-non-lint-warnings-cmdline/Makefile
33
run-make/archive-duplicate-names/Makefile
44
run-make/atomic-lock-free/Makefile
5-
run-make/bare-outfile/Makefile
65
run-make/branch-protection-check-IBT/Makefile
76
run-make/c-dynamic-dylib/Makefile
87
run-make/c-dynamic-rlib/Makefile
@@ -40,7 +39,6 @@ run-make/emit-path-unhashed/Makefile
4039
run-make/emit-shared-files/Makefile
4140
run-make/emit-stack-sizes/Makefile
4241
run-make/emit-to-stdout/Makefile
43-
run-make/emit/Makefile
4442
run-make/env-dep-info/Makefile
4543
run-make/error-found-staticlib-instead-crate/Makefile
4644
run-make/error-writing-dependencies/Makefile
@@ -147,7 +145,6 @@ run-make/min-global-align/Makefile
147145
run-make/mingw-export-call-convention/Makefile
148146
run-make/mismatching-target-triples/Makefile
149147
run-make/missing-crate-dependency/Makefile
150-
run-make/mixing-formats/Makefile
151148
run-make/mixing-libs/Makefile
152149
run-make/msvc-opt-minsize/Makefile
153150
run-make/multiple-emits/Makefile

‎tests/run-make/bare-outfile/Makefile

-9
This file was deleted.

‎tests/run-make/bare-outfile/rmake.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This test checks that manually setting the output file as a bare file with no file extension
2+
// still results in successful compilation.
3+
4+
//@ ignore-cross-compile
5+
6+
use run_make_support::{run, rustc, tmp_dir};
7+
use std::env;
8+
use std::fs;
9+
10+
fn main() {
11+
fs::copy("foo.rs", tmp_dir().join("foo.rs")).unwrap();
12+
env::set_current_dir(tmp_dir());
13+
rustc().output("foo").input("foo.rs").run();
14+
run("foo");
15+
}

‎tests/run-make/emit/Makefile

-22
This file was deleted.

‎tests/run-make/emit/rmake.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// A bug from 2015 would cause errors when emitting multiple types of files
2+
// in the same rustc call. A fix was created in #30452. This test checks that rustc still compiles
3+
// a source file successfully when emission of multiple output artifacts are requested.
4+
// See https://github.com/rust-lang/rust/pull/30452
5+
6+
//@ ignore-cross-compile
7+
8+
use run_make_support::{run, rustc};
9+
10+
fn main() {
11+
let opt_levels = ["0", "1", "2", "3", "s", "z"];
12+
for level in opt_levels {
13+
rustc().opt_level(level).emit("llvm-bc,llvm-ir,asm,obj,link").input("test-24876.rs").run();
14+
}
15+
for level in opt_levels {
16+
rustc().opt_level(level).emit("llvm-bc,llvm-ir,asm,obj,link").input("test-26235.rs").run();
17+
run("test-26235");
18+
}
19+
}

‎tests/run-make/mixing-formats/Makefile

-75
This file was deleted.
+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Testing various mixings of rlibs and dylibs. Makes sure that it's possible to
2+
// link an rlib to a dylib. The dependency tree among the file looks like:
3+
//
4+
// foo
5+
// / \
6+
// bar1 bar2
7+
// / \ /
8+
// baz baz2
9+
//
10+
// This is generally testing the permutations of the foo/bar1/bar2 layer against
11+
// the baz/baz2 layer
12+
13+
//@ ignore-cross-compile
14+
15+
use run_make_support::{rustc, tmp_dir};
16+
use std::fs;
17+
18+
fn test_with_teardown(rustc_calls: impl Fn()) {
19+
rustc_calls();
20+
//FIXME(Oneirical): This should be replaced with the run-make-support fs wrappers.
21+
fs::remove_dir_all(tmp_dir()).unwrap();
22+
fs::create_dir(tmp_dir()).unwrap();
23+
}
24+
25+
fn main() {
26+
test_with_teardown(|| {
27+
// Building just baz
28+
rustc().crate_type("rlib").input("foo.rs").run();
29+
rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run();
30+
rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run();
31+
rustc().crate_type("bin").input("baz.rs").run();
32+
});
33+
test_with_teardown(|| {
34+
rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run();
35+
rustc().crate_type("rlib").input("bar1.rs").run();
36+
rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run();
37+
rustc().crate_type("bin").input("baz.rs").run();
38+
});
39+
test_with_teardown(|| {
40+
// Building baz2
41+
rustc().crate_type("rlib").input("foo.rs").run();
42+
rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run();
43+
rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run();
44+
rustc().crate_type("dylib").input("baz2.rs").run_fail_assert_exit_code(1);
45+
rustc().crate_type("bin").input("baz2.rs").run_fail_assert_exit_code(1);
46+
});
47+
test_with_teardown(|| {
48+
rustc().crate_type("rlib").input("foo.rs").run();
49+
rustc().crate_type("rlib").input("bar1.rs").run();
50+
rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run();
51+
rustc().crate_type("dylib,rlib").input("baz2.rs").run();
52+
rustc().crate_type("bin").input("baz2.rs").run();
53+
});
54+
test_with_teardown(|| {
55+
rustc().crate_type("rlib").input("foo.rs").run();
56+
rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run();
57+
rustc().crate_type("rlib").input("bar2.rs").run();
58+
rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run();
59+
rustc().crate_type("bin").input("baz2.rs").run();
60+
});
61+
test_with_teardown(|| {
62+
rustc().crate_type("rlib").input("foo.rs").run();
63+
rustc().crate_type("rlib").input("bar1.rs").run();
64+
rustc().crate_type("rlib").input("bar2.rs").run();
65+
rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run();
66+
rustc().crate_type("bin").input("baz2.rs").run();
67+
});
68+
test_with_teardown(|| {
69+
rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run();
70+
rustc().crate_type("rlib").input("bar1.rs").run();
71+
rustc().crate_type("rlib").input("bar2.rs").run();
72+
rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run();
73+
rustc().crate_type("bin").input("baz2.rs").run();
74+
});
75+
test_with_teardown(|| {
76+
rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run();
77+
rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run();
78+
rustc().crate_type("rlib").input("bar2.rs").run();
79+
rustc().crate_type("dylib,rlib").input("baz2.rs").run();
80+
rustc().crate_type("bin").input("baz2.rs").run();
81+
});
82+
test_with_teardown(|| {
83+
rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run();
84+
rustc().crate_type("rlib").input("bar1.rs").run();
85+
rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run();
86+
rustc().crate_type("dylib,rlib").input("baz2.rs").run();
87+
rustc().crate_type("bin").input("baz2.rs").run();
88+
});
89+
rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run();
90+
rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run();
91+
rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run();
92+
rustc().crate_type("dylib,rlib").input("baz2.rs").run();
93+
rustc().crate_type("bin").input("baz2.rs").run();
94+
}

0 commit comments

Comments
 (0)
Please sign in to comment.