Skip to content

Commit ef48ae8

Browse files
committed
rewrite output-type-permutations to rmake
1 parent 99f77a2 commit ef48ae8

File tree

3 files changed

+178
-148
lines changed

3 files changed

+178
-148
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ run-make/no-duplicate-libs/Makefile
116116
run-make/obey-crate-type-flag/Makefile
117117
run-make/optimization-remarks-dir-pgo/Makefile
118118
run-make/optimization-remarks-dir/Makefile
119-
run-make/output-type-permutations/Makefile
120119
run-make/override-aliased-flags/Makefile
121120
run-make/overwrite-input/Makefile
122121
run-make/panic-abort-eh_frame/Makefile

tests/run-make/output-type-permutations/Makefile

-147
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
// In 2014, rustc's output flags were reworked to be a lot more modular.
2+
// This test uses these output flags in an expansive variety of combinations
3+
// and syntax styles, checking that compilation is successful and that no unexpected
4+
// files are created.
5+
// The assert_eq! checks that "1 file remains" at the end of each part of the test,
6+
// because foo.rs counts as a file, and should be the only remaining one.
7+
// See https://github.com/rust-lang/rust/pull/12020
8+
9+
use run_make_support::{
10+
bin_name, cwd, dynamic_lib_name, fs_wrapper, rust_lib_name, rustc, static_lib_name,
11+
};
12+
13+
fn remove_artifacts() {
14+
std::fs::remove_file("libbar.ddl.exp").unwrap_or_default();
15+
std::fs::remove_file("libbar.dll.lib").unwrap_or_default();
16+
std::fs::remove_file("libbar.pdb").unwrap_or_default();
17+
std::fs::remove_file("libbar.dll.a").unwrap_or_default();
18+
std::fs::remove_file("libbar.exe.a").unwrap_or_default();
19+
std::fs::remove_file("bar.ddl.exp").unwrap_or_default();
20+
std::fs::remove_file("bar.dll.lib").unwrap_or_default();
21+
std::fs::remove_file("bar.pdb").unwrap_or_default();
22+
std::fs::remove_file("bar.dll.a").unwrap_or_default();
23+
std::fs::remove_file("bar.exe.a").unwrap_or_default();
24+
}
25+
26+
fn main() {
27+
rustc().input("foo.rs").crate_type("rlib,dylib,staticlib").run();
28+
fs_wrapper::remove_file(rust_lib_name("bar"));
29+
fs_wrapper::remove_file(dynamic_lib_name("bar"));
30+
fs_wrapper::remove_file(static_lib_name("bar"));
31+
remove_artifacts();
32+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
33+
34+
rustc().input("foo.rs").crate_type("bin").run();
35+
fs_wrapper::remove_file(bin_name("bar"));
36+
std::fs::remove_file("bar.pdb").unwrap_or_default();
37+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
38+
39+
rustc().input("foo.rs").emit("asm,llvm-ir,llvm-bc,obj,link").run();
40+
fs_wrapper::remove_file("bar.ll");
41+
fs_wrapper::remove_file("bar.bc");
42+
fs_wrapper::remove_file("bar.s");
43+
fs_wrapper::remove_file("bar.o");
44+
fs_wrapper::remove_file(bin_name("bar"));
45+
std::fs::remove_file("bar.pdb").unwrap_or_default();
46+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
47+
48+
rustc().input("foo.rs").emit("asm").output("foo").run();
49+
fs_wrapper::remove_file("foo");
50+
rustc().input("foo.rs").emit("asm=foo").run();
51+
fs_wrapper::remove_file("foo");
52+
rustc().input("foo.rs").arg("--emit=asm=foo").run();
53+
fs_wrapper::remove_file("foo");
54+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
55+
56+
rustc().input("foo.rs").emit("llvm-bc").output("foo").run();
57+
fs_wrapper::remove_file("foo");
58+
rustc().input("foo.rs").emit("llvm-bc=foo").run();
59+
fs_wrapper::remove_file("foo");
60+
rustc().input("foo.rs").arg("--emit=llvm-bc=foo").run();
61+
fs_wrapper::remove_file("foo");
62+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
63+
64+
rustc().input("foo.rs").emit("llvm-ir").output("foo").run();
65+
fs_wrapper::remove_file("foo");
66+
rustc().input("foo.rs").emit("llvm-ir=foo").run();
67+
fs_wrapper::remove_file("foo");
68+
rustc().input("foo.rs").arg("--emit=llvm-ir=foo").run();
69+
fs_wrapper::remove_file("foo");
70+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
71+
72+
rustc().input("foo.rs").emit("obj").output("foo").run();
73+
fs_wrapper::remove_file("foo");
74+
rustc().input("foo.rs").emit("obj=foo").run();
75+
fs_wrapper::remove_file("foo");
76+
rustc().input("foo.rs").arg("--emit=obj=foo").run();
77+
fs_wrapper::remove_file("foo");
78+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
79+
80+
let bin_foo = bin_name("foo");
81+
rustc().input("foo.rs").emit("link").output(&bin_foo).run();
82+
fs_wrapper::remove_file(&bin_foo);
83+
rustc().input("foo.rs").emit(&format!("link={bin_foo}")).run();
84+
fs_wrapper::remove_file(&bin_foo);
85+
rustc().input("foo.rs").arg(&format!("--emit=link={bin_foo}")).run();
86+
fs_wrapper::remove_file(&bin_foo);
87+
std::fs::remove_file("foo.pdb").unwrap_or_default();
88+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
89+
90+
rustc().input("foo.rs").crate_type("rlib").output("foo").run();
91+
fs_wrapper::remove_file("foo");
92+
rustc().input("foo.rs").crate_type("rlib").emit("link=foo").run();
93+
fs_wrapper::remove_file("foo");
94+
rustc().input("foo.rs").crate_type("rlib").arg("--emit=link=foo").run();
95+
fs_wrapper::remove_file("foo");
96+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
97+
98+
rustc().input("foo.rs").crate_type("dylib").output(&bin_foo).run();
99+
fs_wrapper::remove_file(&bin_foo);
100+
rustc().input("foo.rs").crate_type("dylib").emit(&format!("link={bin_foo}")).run();
101+
fs_wrapper::remove_file(&bin_foo);
102+
rustc().input("foo.rs").crate_type("dylib").arg(&format!("--emit=link={bin_foo}")).run();
103+
fs_wrapper::remove_file(&bin_foo);
104+
remove_artifacts();
105+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
106+
107+
rustc().input("foo.rs").crate_type("staticlib").emit("link").output("foo").run();
108+
fs_wrapper::remove_file("foo");
109+
rustc().input("foo.rs").crate_type("staticlib").emit("link=foo").run();
110+
fs_wrapper::remove_file("foo");
111+
rustc().input("foo.rs").crate_type("staticlib").arg("--emit=link=foo").run();
112+
fs_wrapper::remove_file("foo");
113+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
114+
115+
rustc().input("foo.rs").crate_type("bin").output(&bin_foo).run();
116+
fs_wrapper::remove_file(&bin_foo);
117+
rustc().input("foo.rs").crate_type("bin").emit(&format!("link={bin_foo}")).run();
118+
fs_wrapper::remove_file(&bin_foo);
119+
rustc().input("foo.rs").crate_type("bin").arg(&format!("--emit=link={bin_foo}")).run();
120+
fs_wrapper::remove_file(&bin_foo);
121+
std::fs::remove_file("foo.pdb").unwrap_or_default();
122+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
123+
124+
rustc().input("foo.rs").emit("llvm-ir=ir").emit("link").crate_type("rlib").run();
125+
fs_wrapper::remove_file("ir");
126+
fs_wrapper::remove_file(rust_lib_name("bar"));
127+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
128+
129+
rustc()
130+
.input("foo.rs")
131+
.emit("asm=asm")
132+
.emit("llvm-ir=ir")
133+
.emit("llvm-bc=bc")
134+
.emit("obj=obj")
135+
.emit("link=link")
136+
.crate_type("staticlib")
137+
.run();
138+
fs_wrapper::remove_file("asm");
139+
fs_wrapper::remove_file("ir");
140+
fs_wrapper::remove_file("bc");
141+
fs_wrapper::remove_file("obj");
142+
fs_wrapper::remove_file("link");
143+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
144+
145+
rustc()
146+
.input("foo.rs")
147+
.arg("--emit=asm=asm")
148+
.arg("--emit")
149+
.arg("llvm-ir=ir")
150+
.arg("--emit=llvm-bc=bc")
151+
.arg("--emit")
152+
.arg("obj=obj")
153+
.arg("--emit=link=link")
154+
.crate_type("staticlib")
155+
.run();
156+
fs_wrapper::remove_file("asm");
157+
fs_wrapper::remove_file("ir");
158+
fs_wrapper::remove_file("bc");
159+
fs_wrapper::remove_file("obj");
160+
fs_wrapper::remove_file("link");
161+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
162+
163+
rustc().input("foo.rs").emit("asm,llvm-ir,llvm-bc,obj,link").crate_type("staticlib").run();
164+
fs_wrapper::remove_file("bar.ll");
165+
fs_wrapper::remove_file("bar.s");
166+
fs_wrapper::remove_file("bar.o");
167+
fs_wrapper::remove_file(static_lib_name("bar"));
168+
fs_wrapper::rename("bar.bc", "foo.bc");
169+
// Don't check that no files except foo.rs remain - we left `foo.bc` for later
170+
// comparison.
171+
172+
rustc().input("foo.rs").emit("llvm-bc,link").crate_type("rlib").run();
173+
assert_eq!(fs_wrapper::read("foo.bc"), fs_wrapper::read("bar.bc"));
174+
fs_wrapper::remove_file("bar.bc");
175+
fs_wrapper::remove_file("foo.bc");
176+
fs_wrapper::remove_file(rust_lib_name("bar"));
177+
assert_eq!(fs_wrapper::read_dir(cwd()).count(), 1);
178+
}

0 commit comments

Comments
 (0)