Skip to content

Commit 2c4214e

Browse files
committed
run-make: port stdin-rustc to Rust-based rmake.rs
1 parent 0a03b09 commit 2c4214e

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ run-make/static-unwinding/Makefile
288288
run-make/staticlib-blank-lib/Makefile
289289
run-make/staticlib-dylib-linkage/Makefile
290290
run-make/std-core-cycle/Makefile
291-
run-make/stdin-non-utf8/Makefile
292291
run-make/suspicious-library/Makefile
293292
run-make/symbol-mangling-hashed/Makefile
294293
run-make/symbol-visibility/Makefile

tests/run-make/stdin-non-utf8/Makefile

-6
This file was deleted.

tests/run-make/stdin-non-utf8/non-utf8

-1
This file was deleted.

tests/run-make/stdin-rustc/rmake.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//! This test checks rustc `-` (stdin) support
2+
3+
use run_make_support::{is_windows, rustc, tmp_dir};
4+
5+
const HELLO_WORLD: &str = r#"
6+
fn main() {
7+
println!("Hello world!");
8+
}
9+
"#;
10+
11+
const NOT_UTF8: &[u8] = &[0xff, 0xff, 0xff];
12+
13+
fn main() {
14+
let out_dir = tmp_dir();
15+
16+
// echo $HELLO_WORLD | rustc -
17+
rustc().arg("-").stdin(HELLO_WORLD).run();
18+
assert!(
19+
out_dir.join(if !is_windows() { "rust_out" } else { "rust_out.exe" }).try_exists().unwrap()
20+
);
21+
22+
// echo $NOT_UTF8 | rustc -
23+
let output = rustc().arg("-").stdin(NOT_UTF8).run_fail();
24+
let stderr = String::from_utf8(output.stderr).unwrap();
25+
assert!(stderr.contains("error: couldn't read from stdin, as it did not contain valid UTF-8"));
26+
}

0 commit comments

Comments
 (0)