Skip to content

Commit

Permalink
tests: use renamed stdin_buf
Browse files Browse the repository at this point in the history
  • Loading branch information
jieyouxu committed Sep 5, 2024
1 parent 2031eac commit afed862
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion tests/run-make/clear-error-blank-output/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
use run_make_support::rustc;

fn main() {
let output = rustc().output("").stdin(b"fn main() {}").run_fail();
let output = rustc().output("").stdin_buf(b"fn main() {}").run_fail();
output.assert_stderr_not_contains("panic");
}
2 changes: 1 addition & 1 deletion tests/run-make/comment-section/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() {

rustc()
.arg("-")
.stdin("fn main() {}")
.stdin_buf("fn main() {}")
.emit("link,obj")
.arg("-Csave-temps")
.target(target)
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/compile-stdin/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
use run_make_support::{run, rustc};

fn main() {
rustc().arg("-").stdin("fn main() {}").run();
rustc().arg("-").stdin_buf("fn main() {}").run();
run("rust_out");
}
2 changes: 1 addition & 1 deletion tests/run-make/libtest-junit/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn run_tests(extra_args: &[&str], expected_file: &str) {
.run_fail();
let test_stdout = &cmd_out.stdout_utf8();

python_command().arg("validate_junit.py").stdin(test_stdout).run();
python_command().arg("validate_junit.py").stdin_buf(test_stdout).run();

diff()
.expected_file(expected_file)
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/llvm-ident/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn main() {
.codegen_units(16)
.opt_level("2")
.target(&env_var("TARGET"))
.stdin("fn main(){}")
.stdin_buf("fn main(){}")
.run();

// `llvm-dis` is used here since `--emit=llvm-ir` does not emit LLVM IR
Expand Down
4 changes: 2 additions & 2 deletions tests/run-make/llvm-outputs/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ fn main() {
let p = cwd();
path_bc = p.join("nonexistant_dir_bc");
path_ir = p.join("nonexistant_dir_ir");
rustc().input("-").stdin("fn main() {}").out_dir(&path_bc).emit("llvm-bc").run();
rustc().input("-").stdin("fn main() {}").out_dir(&path_ir).emit("llvm-ir").run();
rustc().input("-").stdin_buf("fn main() {}").out_dir(&path_bc).emit("llvm-bc").run();
rustc().input("-").stdin_buf("fn main() {}").out_dir(&path_ir).emit("llvm-ir").run();
assert!(path_bc.exists());
assert!(path_ir.exists());
});
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/no-builtins-attribute/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ use run_make_support::{llvm_filecheck, rfs, rustc};
fn main() {
rustc().input("no_builtins.rs").emit("link").run();
rustc().input("main.rs").emit("llvm-ir").run();
llvm_filecheck().patterns("filecheck.main.txt").stdin(rfs::read("main.ll")).run();
llvm_filecheck().patterns("filecheck.main.txt").stdin_buf(rfs::read("main.ll")).run();
}
5 changes: 4 additions & 1 deletion tests/run-make/pgo-branch-weights/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ fn main() {
.codegen_units(1)
.emit("llvm-ir")
.run();
llvm_filecheck().patterns("filecheck-patterns.txt").stdin(rfs::read("interesting.ll")).run();
llvm_filecheck()
.patterns("filecheck-patterns.txt")
.stdin_buf(rfs::read("interesting.ll"))
.run();
}
5 changes: 4 additions & 1 deletion tests/run-make/pgo-indirect-call-promotion/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ fn main() {
.codegen_units(1)
.emit("llvm-ir")
.run();
llvm_filecheck().patterns("filecheck-patterns.txt").stdin(rfs::read("interesting.ll")).run();
llvm_filecheck()
.patterns("filecheck-patterns.txt")
.stdin_buf(rfs::read("interesting.ll"))
.run();
}
2 changes: 1 addition & 1 deletion tests/run-make/pgo-use/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ fn main() {
let lines: Vec<_> = ir.lines().rev().collect();
let mut reversed_ir = lines.join("\n");
reversed_ir.push('\n');
llvm_filecheck().patterns("filecheck-patterns.txt").stdin(reversed_ir.as_bytes()).run();
llvm_filecheck().patterns("filecheck-patterns.txt").stdin_buf(reversed_ir.as_bytes()).run();
}
2 changes: 1 addition & 1 deletion tests/run-make/separate-link/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use run_make_support::{run, rustc};

fn main() {
rustc().stdin(b"fn main(){}").arg("-Zno-link").arg("-").run();
rustc().stdin_buf(b"fn main(){}").arg("-Zno-link").arg("-").run();
rustc().arg("-Zlink-only").input("rust_out.rlink").run();
run("rust_out");
}
2 changes: 1 addition & 1 deletion tests/run-make/static-pie/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn ok_compiler_version(compiler: &str) -> bool {
}

let compiler_output =
cmd(compiler).stdin(trigger).arg("-").arg("-E").arg("-x").arg("c").run().stdout_utf8();
cmd(compiler).stdin_buf(trigger).arg("-").arg("-E").arg("-x").arg("c").run().stdout_utf8();
let re = Regex::new(r"(?m)^(\d+)").unwrap();
let version: u32 =
re.captures(&compiler_output).unwrap().get(1).unwrap().as_str().parse().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions tests/run-make/stdin-rustc/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ const NOT_UTF8: &[u8] = &[0xff, 0xff, 0xff];

fn main() {
// echo $HELLO_WORLD | rustc -
rustc().arg("-").stdin(HELLO_WORLD).run();
rustc().arg("-").stdin_buf(HELLO_WORLD).run();
assert!(
PathBuf::from(if !is_windows() { "rust_out" } else { "rust_out.exe" })
.try_exists()
.unwrap()
);

// echo $NOT_UTF8 | rustc -
rustc().arg("-").stdin(NOT_UTF8).run_fail().assert_stderr_contains(
rustc().arg("-").stdin_buf(NOT_UTF8).run_fail().assert_stderr_contains(
"error: couldn't read from stdin, as it did not contain valid UTF-8",
);
}
4 changes: 2 additions & 2 deletions tests/run-make/stdin-rustdoc/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ fn main() {
let out_dir = PathBuf::from("doc");

// rustdoc -
rustdoc().arg("-").out_dir(&out_dir).stdin(INPUT).run();
rustdoc().arg("-").out_dir(&out_dir).stdin_buf(INPUT).run();
assert!(out_dir.join("rust_out/struct.F.html").try_exists().unwrap());

// rustdoc --test -
rustdoc().arg("--test").arg("-").stdin(INPUT).run();
rustdoc().arg("--test").arg("-").stdin_buf(INPUT).run();

// rustdoc file.rs -
rustdoc().arg("file.rs").arg("-").run_fail();
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/sysroot-crates-are-unstable/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn check_crate_is_unstable(cr: &Crate) {
.target(target())
.extern_(name, path)
.input("-")
.stdin(format!("extern crate {name};"))
.stdin_buf(format!("extern crate {name};"))
.run_fail();

// Make sure it failed for the intended reason, not some other reason.
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/unknown-mod-stdin/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use run_make_support::{diff, rustc};

fn main() {
let out = rustc().crate_type("rlib").stdin(b"mod unknown;").arg("-").run_fail();
let out = rustc().crate_type("rlib").stdin_buf(b"mod unknown;").arg("-").run_fail();
diff()
.actual_text("actual-stdout", out.stdout_utf8())
.expected_file("unknown-mod.stdout")
Expand Down
12 changes: 8 additions & 4 deletions tests/run-make/x86_64-fortanix-unknown-sgx-lvi/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,23 @@ fn check(func_re: &str, mut checks: &str) {
// This is because frame pointers are optional, and them being enabled requires
// an additional `popq` in the pattern checking file.
if func_re == "std::io::stdio::_print::[[:alnum:]]+" {
let output = llvm_filecheck().stdin(&dump).patterns(checks).run_unchecked();
let output = llvm_filecheck().stdin_buf(&dump).patterns(checks).run_unchecked();
if !output.status().success() {
checks = "print.without_frame_pointers.checks";
llvm_filecheck().stdin(&dump).patterns(checks).run();
llvm_filecheck().stdin_buf(&dump).patterns(checks).run();
}
} else {
llvm_filecheck().stdin(&dump).patterns(checks).run();
llvm_filecheck().stdin_buf(&dump).patterns(checks).run();
}
if !["rust_plus_one_global_asm", "cmake_plus_one_c_global_asm", "cmake_plus_one_cxx_global_asm"]
.contains(&func_re)
{
// The assembler cannot avoid explicit `ret` instructions. Sequences
// of `shlq $0x0, (%rsp); lfence; retq` are used instead.
llvm_filecheck().args(&["--implicit-check-not", "ret"]).stdin(dump).patterns(checks).run();
llvm_filecheck()
.args(&["--implicit-check-not", "ret"])
.stdin_buf(dump)
.patterns(checks)
.run();
}
}

0 comments on commit afed862

Please sign in to comment.