-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #124612 - Urgau:run-make-stdin, r=jieyouxu
Add support for inputing via stdin with run-make-support This PR adds the facility to set a input bytes that will be passed via the standard input. This is useful for testing `rustc -` (and soon `rustdoc -`). In #124611 took the approach of having a dedicated `run` method but it is not very convenient to use and would necessitate many functions, one for success, one for fail, ... Instead this PR takes a different approach and allows setting the input bytes as if it were a parameter and when calling the (now custom) `output` function, we write the input bytes into stdin. I think this gives us maximum flexibility in the implementation and a simple interface for users. To test this new logic I ported `tests/run-make/stdin-non-utf8/` to an `rmake.rs` one. r? `@jieyouxu`
- Loading branch information
Showing
10 changed files
with
120 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
} |