Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tools/run-make-support/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl Rustc {

/// 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());
Expand Down
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 @@ -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
Expand Down
10 changes: 0 additions & 10 deletions tests/run-make/crate-data-smoke/Makefile

This file was deleted.

43 changes: 43 additions & 0 deletions tests/run-make/crate-data-smoke/rmake.rs
Original file line number Diff line number Diff line change
@@ -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(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: rust_lib is a bit weird because it constructs a path under tmp_dir() and then joins the library name. Then to get the filename we have to do this long .file_name().unwrap().to_string_lossy() dance.

I know we currently have it defined as

/// Construct a path to a rust library (rlib) under `$TMPDIR` given the library name. This will return a
/// path with `$TMPDIR` joined with the library name.
pub fn rust_lib(name: &str) -> PathBuf {
    tmp_dir().join(format!("lib{name}.rlib"))
}

should we introduce a helper that's only responsible for calculating the rlib name itself?

fn rlib_name(name: &str) -> String {
    format!("lib{name}.rlib")
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be much better indeed! Doing it.

);
compare_stdout(
rustc().print("file-names").input("rlib.rs").run(),
rust_lib("mylib").file_name().unwrap().to_string_lossy(),
);
}
Loading