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 all commits
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
8 changes: 7 additions & 1 deletion src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,13 @@ pub fn dynamic_lib_name(name: &str) -> String {
/// 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"))
tmp_dir().join(rust_lib_name(name))
}

/// Generate the name a rust library (rlib) would have. If you want the complete path, use
/// [`rust_lib`] instead.
pub fn rust_lib_name(name: &str) -> String {
format!("lib{name}.rlib")
}

/// Construct the binary name based on platform.
Expand Down
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_name, 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_name("mylib"),
Copy link
Member

Choose a reason for hiding this comment

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

Yes, I like how this reads much better :3

);
compare_stdout(
rustc().print("file-names").input("rlib.rs").run(),
rust_lib_name("mylib"),
);
}
Loading