run-make: port stdin-rustc to Rust-based rmake.rs

This commit is contained in:
Urgau 2024-05-02 12:04:20 +02:00
parent 0a03b0961a
commit 2c4214e0a0
4 changed files with 26 additions and 8 deletions

View File

@ -288,7 +288,6 @@ run-make/static-unwinding/Makefile
run-make/staticlib-blank-lib/Makefile
run-make/staticlib-dylib-linkage/Makefile
run-make/std-core-cycle/Makefile
run-make/stdin-non-utf8/Makefile
run-make/suspicious-library/Makefile
run-make/symbol-mangling-hashed/Makefile
run-make/symbol-visibility/Makefile

View File

@ -1,6 +0,0 @@
include ../tools.mk
all:
cp non-utf8 $(TMPDIR)/non-utf.rs
cat $(TMPDIR)/non-utf.rs | $(RUSTC) - 2>&1 \
| $(CGREP) "error: couldn't read from stdin, as it did not contain valid UTF-8"

View File

@ -1 +0,0 @@
<EFBFBD>

View File

@ -0,0 +1,26 @@
//! This test checks rustc `-` (stdin) support
use run_make_support::{is_windows, rustc, tmp_dir};
const HELLO_WORLD: &str = r#"
fn main() {
println!("Hello world!");
}
"#;
const NOT_UTF8: &[u8] = &[0xff, 0xff, 0xff];
fn main() {
let out_dir = tmp_dir();
// echo $HELLO_WORLD | rustc -
rustc().arg("-").stdin(HELLO_WORLD).run();
assert!(
out_dir.join(if !is_windows() { "rust_out" } else { "rust_out.exe" }).try_exists().unwrap()
);
// echo $NOT_UTF8 | rustc -
let output = rustc().arg("-").stdin(NOT_UTF8).run_fail();
let stderr = String::from_utf8(output.stderr).unwrap();
assert!(stderr.contains("error: couldn't read from stdin, as it did not contain valid UTF-8"));
}