|
5 | 5 | // trigger an error too, as they will all be mixed together.
|
6 | 6 | // See https://github.com/rust-lang/rust/pull/111626
|
7 | 7 |
|
| 8 | +use std::io::IsTerminal; |
| 9 | + |
8 | 10 | use run_make_support::{diff, rfs, rustc};
|
9 | 11 |
|
10 | 12 | fn main() {
|
11 | 13 | rfs::create_dir("out");
|
| 14 | + |
| 15 | + #[cfg(not(windows))] |
| 16 | + let stdout = std::fs::File::options().write(true).open("/dev/ptmx").unwrap(); |
| 17 | + // FIXME: If this test fails and the compiler does print to the console, then this will produce a lot of output. |
| 18 | + // We should spawn a new console instead to print stdout. |
| 19 | + #[cfg(windows)] |
| 20 | + let stdout = std::fs::File::options().read(true).write(true).open(r"\\.\CONOUT$").unwrap(); |
| 21 | + |
| 22 | + assert!(stdout.is_terminal()); |
12 | 23 | test_asm();
|
13 | 24 | test_llvm_ir();
|
14 | 25 | test_dep_info();
|
15 | 26 | test_mir();
|
16 |
| - test_llvm_bc(); |
17 |
| - test_obj(); |
18 |
| - test_metadata(); |
19 |
| - test_link(); |
| 27 | + test_llvm_bc(&stdout); |
| 28 | + test_obj(&stdout); |
| 29 | + test_metadata(&stdout); |
| 30 | + test_link(&stdout); |
20 | 31 | test_multiple_types();
|
21 | 32 | test_multiple_types_option_o();
|
22 | 33 | }
|
@@ -50,26 +61,46 @@ fn test_mir() {
|
50 | 61 | }
|
51 | 62 |
|
52 | 63 | // FIXME: ptmx
|
53 |
| -fn test_llvm_bc() { |
54 |
| - let emit = rustc().emit("llvm-bc=-").input("test.rs").run().stderr_utf8(); |
| 64 | +fn test_llvm_bc(stdout: &std::fs::File) { |
| 65 | + let emit = rustc() |
| 66 | + .emit("llvm-bc=-") |
| 67 | + .stdout(stdout.try_clone().unwrap()) |
| 68 | + .input("test.rs") |
| 69 | + .run_fail() |
| 70 | + .stderr_utf8(); |
55 | 71 | diff().expected_file("emit-llvm-bc.stderr").actual_text("actual", &emit).run();
|
56 | 72 | }
|
57 | 73 |
|
58 | 74 | // FIXME: ptmx
|
59 |
| -fn test_obj() { |
60 |
| - let emit = rustc().emit("obj=-").input("test.rs").run().stderr_utf8(); |
| 75 | +fn test_obj(stdout: &std::fs::File) { |
| 76 | + let emit = rustc() |
| 77 | + .emit("obj=-") |
| 78 | + .stdout(stdout.try_clone().unwrap()) |
| 79 | + .input("test.rs") |
| 80 | + .run_fail() |
| 81 | + .stderr_utf8(); |
61 | 82 | diff().expected_file("emit-obj.stderr").actual_text("actual", &emit).run();
|
62 | 83 | }
|
63 | 84 |
|
64 | 85 | // FIXME: ptmx
|
65 |
| -fn test_metadata() { |
66 |
| - let emit = rustc().emit("metadata=-").input("test.rs").run().stderr_utf8(); |
| 86 | +fn test_metadata(stdout: &std::fs::File) { |
| 87 | + let emit = rustc() |
| 88 | + .emit("metadata=-") |
| 89 | + .input("test.rs") |
| 90 | + .stdout(stdout.try_clone().unwrap()) |
| 91 | + .run_fail() |
| 92 | + .stderr_utf8(); |
67 | 93 | diff().expected_file("emit-metadata.stderr").actual_text("actual", &emit).run();
|
68 | 94 | }
|
69 | 95 |
|
70 | 96 | // FIXME: ptmx
|
71 |
| -fn test_link() { |
72 |
| - let emit = rustc().emit("link=-").input("test.rs").run().stderr_utf8(); |
| 97 | +fn test_link(stdout: &std::fs::File) { |
| 98 | + let emit = rustc() |
| 99 | + .emit("link=-") |
| 100 | + .input("test.rs") |
| 101 | + .stdout(stdout.try_clone().unwrap()) |
| 102 | + .run_fail() |
| 103 | + .stderr_utf8(); |
73 | 104 | diff().expected_file("emit-link.stderr").actual_text("actual", &emit).run();
|
74 | 105 | }
|
75 | 106 |
|
|
0 commit comments