Skip to content

Commit 5a9a84d

Browse files
committed
rewrite emit-to-stdout to rmake
1 parent 0b5eb7b commit 5a9a84d

File tree

3 files changed

+71
-52
lines changed

3 files changed

+71
-52
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ run-make/cross-lang-lto/Makefile
88
run-make/dep-info-doesnt-run-much/Makefile
99
run-make/dep-info-spaces/Makefile
1010
run-make/dep-info/Makefile
11-
run-make/emit-to-stdout/Makefile
1211
run-make/extern-fn-reachable/Makefile
1312
run-make/fmt-write-bloat/Makefile
1413
run-make/foreign-double-unwind/Makefile

tests/run-make/emit-to-stdout/Makefile

-51
This file was deleted.
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// If `-o -` or `--emit KIND=-` is provided, output should be written
2+
// to stdout instead. Binary output (`obj`, `llvm-bc`, `link` and
3+
// `metadata`) being written this way will result in an error unless
4+
// stdout is not a tty. Multiple output types going to stdout will
5+
// trigger an error too, as they will all be mixed together.
6+
// See https://github.com/rust-lang/rust/pull/111626
7+
8+
use run_make_support::{diff, rfs, rustc};
9+
10+
fn main() {
11+
rfs::create_dir("out");
12+
let tests = ["asm", "llvm-ir", "dep-info", "mir", "llvm-bc", "obj", "metadata", "link"];
13+
for test in tests {
14+
test_emit(test);
15+
}
16+
diff()
17+
.expected_file("emit-multiple-types.stderr")
18+
.actual_text(
19+
"actual",
20+
rustc()
21+
.output("-")
22+
.emit("asm=-")
23+
.emit("llvm-ir=-")
24+
.emit("dep-info=-")
25+
.emit("mir=-")
26+
.input("test.rs")
27+
.run_fail()
28+
.stderr_utf8(),
29+
)
30+
.run();
31+
diff()
32+
.expected_file("emit-multiple-types.stderr")
33+
.actual_text(
34+
"actual",
35+
rustc()
36+
.output("-")
37+
.emit("asm,llvm-ir,dep-info,mir")
38+
.input("test.rs")
39+
.run_fail()
40+
.stderr_utf8(),
41+
)
42+
.run();
43+
}
44+
45+
fn test_emit(emit_type: &str) {
46+
let stderr_types = ["llvm-bc", "obj", "metadata", "link"];
47+
if !stderr_types.contains(&emit_type) {
48+
let mut initial_compile = rustc();
49+
initial_compile.emit(&format!("{emit_type}=out/{emit_type}")).input("test.rs");
50+
if emit_type == "dep-info" {
51+
initial_compile.arg("-Zdep-info-omit-d-target=yes");
52+
}
53+
initial_compile.run();
54+
}
55+
let mut compile = rustc();
56+
compile.emit(&format!("{emit_type}=-")).input("test.rs");
57+
let compile =
58+
if stderr_types.contains(&emit_type) { compile.run_fail() } else { compile.run() };
59+
let emit = if stderr_types.contains(&emit_type) {
60+
compile.stderr_utf8()
61+
} else {
62+
compile.stdout_utf8()
63+
};
64+
let mut diff = diff();
65+
if stderr_types.contains(&emit_type) {
66+
diff.expected_file(&format!("emit-{emit_type}.stderr"));
67+
} else {
68+
diff.expected_file(&format!("out/{emit_type}"));
69+
}
70+
diff.actual_text("actual", &emit).run();
71+
}

0 commit comments

Comments
 (0)