Migrate run-make/crate-data-smoke to rmake.rs

This commit is contained in:
Guillaume Gomez 2024-05-29 15:52:29 +02:00
parent c0d600385b
commit de1d0e0da9
4 changed files with 44 additions and 12 deletions

View File

@ -205,7 +205,7 @@ pub fn crate_name<S: AsRef<OsStr>>(&mut self, name: S) -> &mut Self {
/// Get the [`Output`][::std::process::Output] of the finished process.
#[track_caller]
pub fn command_output(&mut self) -> ::std::process::Output {
pub fn command_output(&mut self) -> Output {
// let's make sure we piped all the input and outputs
self.cmd.stdin(Stdio::piped());
self.cmd.stdout(Stdio::piped());

View File

@ -24,7 +24,6 @@ run-make/compiler-rt-works-on-mingw/Makefile
run-make/compressed-debuginfo/Makefile
run-make/const-prop-lint/Makefile
run-make/const_fn_mir/Makefile
run-make/crate-data-smoke/Makefile
run-make/crate-hash-rustc-version/Makefile
run-make/crate-name-priority/Makefile
run-make/cross-lang-lto-clang/Makefile

View File

@ -1,10 +0,0 @@
include ../tools.mk
all:
[ `$(RUSTC) --print crate-name crate.rs` = "foo" ]
[ `$(RUSTC) --print file-names crate.rs` = "$(call BIN,foo)" ]
[ `$(RUSTC) --print file-names --crate-type=lib \
--test crate.rs` = "$(call BIN,foo)" ]
[ `$(RUSTC) --print file-names --test lib.rs` = "$(call BIN,mylib)" ]
$(RUSTC) --print file-names lib.rs
$(RUSTC) --print file-names rlib.rs

View File

@ -0,0 +1,43 @@
use std::process::Output;
use run_make_support::{bin_name, rust_lib, rustc};
fn compare_stdout<S: AsRef<str>>(output: Output, expected: S) {
assert_eq!(
String::from_utf8(output.stdout).unwrap().trim(),
expected.as_ref()
);
}
fn main() {
compare_stdout(rustc().print("crate-name").input("crate.rs").run(), "foo");
compare_stdout(
rustc().print("file-names").input("crate.rs").run(),
bin_name("foo"),
);
compare_stdout(
rustc()
.print("file-names")
.crate_type("lib")
.arg("--test")
.input("crate.rs")
.run(),
bin_name("foo"),
);
compare_stdout(
rustc()
.print("file-names")
.arg("--test")
.input("lib.rs")
.run(),
bin_name("mylib"),
);
compare_stdout(
rustc().print("file-names").input("lib.rs").run(),
rust_lib("mylib").file_name().unwrap().to_string_lossy(),
);
compare_stdout(
rustc().print("file-names").input("rlib.rs").run(),
rust_lib("mylib").file_name().unwrap().to_string_lossy(),
);
}