Skip to content

Commit

Permalink
run-make: port stdin-rustc to Rust-based rmake.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed May 3, 2024
1 parent 0a03b09 commit 2c4214e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions tests/run-make/stdin-non-utf8/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion tests/run-make/stdin-non-utf8/non-utf8

This file was deleted.

26 changes: 26 additions & 0 deletions tests/run-make/stdin-rustc/rmake.rs
Original file line number Diff line number Diff line change
@@ -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"));
}

0 comments on commit 2c4214e

Please sign in to comment.