Skip to content

Commit 04b2f91

Browse files
committed
Migrate emit-to-stdout to new run-make
1 parent bcf95fc commit 04b2f91

File tree

3 files changed

+60
-52
lines changed

3 files changed

+60
-52
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
run-make/branch-protection-check-IBT/Makefile
22
run-make/cat-and-grep-sanity-check/Makefile
3-
run-make/emit-to-stdout/Makefile
43
run-make/extern-fn-reachable/Makefile
54
run-make/incr-add-rust-src-component/Makefile
65
run-make/issue-84395-lto-embed-bitcode/Makefile

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

-51
This file was deleted.
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Test that emitting to stdout works
2+
3+
use std::fs::{self, File};
4+
5+
use run_make_support::{diff, run_in_tmpdir, rustc};
6+
7+
// Test emitting text outputs to stdout works correctly
8+
fn run_diff(name: &str, file_args: &[&str]) {
9+
rustc().emit(format!("{name}={name}")).input("test.rs").args(file_args).run();
10+
let out = rustc().emit(format!("{name}=-")).input("test.rs").run().stdout_utf8();
11+
diff().expected_file(name).actual_text("stdout", &out).run();
12+
}
13+
14+
// Test that emitting binary formats to a terminal gives the correct error
15+
fn run_terminal_err_diff(name: &str) {
16+
let pty = File::create("/dev/ptmx").unwrap();
17+
let err = File::create(name).unwrap();
18+
rustc().emit(format!("{name}=-")).input("test.rs").stdout(pty).stderr(err).run_fail();
19+
diff().expected_file(format!("emit-{name}.stderr")).actual_file(name).run();
20+
}
21+
22+
fn main() {
23+
run_in_tmpdir(|| {
24+
run_diff("asm", &[]);
25+
run_diff("llvm-ir", &[]);
26+
run_diff("dep-info", &["-Zdep-info-omit-d-target=yes"]);
27+
run_diff("mir", &[]);
28+
29+
run_terminal_err_diff("llvm-bc");
30+
run_terminal_err_diff("obj");
31+
run_terminal_err_diff("metadata");
32+
run_terminal_err_diff("link");
33+
34+
// Test error for emitting multiple types to stdout
35+
rustc()
36+
.input("test.rs")
37+
.emit("asm=-")
38+
.emit("llvm-ir=-")
39+
.emit("dep-info=-")
40+
.emit("mir=-")
41+
.stderr(File::create("multiple-types").unwrap())
42+
.run_fail();
43+
diff().expected_file("emit-multiple-types.stderr").actual_file("multiple-types").run();
44+
45+
// Same as above, but using `-o`
46+
rustc()
47+
.input("test.rs")
48+
.output("-")
49+
.emit("asm,llvm-ir,dep-info,mir")
50+
.stderr(File::create("multiple-types-option-o").unwrap())
51+
.run_fail();
52+
diff()
53+
.expected_file("emit-multiple-types.stderr")
54+
.actual_file("multiple-types-option-o")
55+
.run();
56+
57+
// Test that `-o -` redirected to a file works correctly (#26719)
58+
rustc().input("test.rs").output("-").stdout(File::create("out-stdout").unwrap()).run();
59+
});
60+
}

0 commit comments

Comments
 (0)