Skip to content

Commit

Permalink
Unrolled build for rust-lang#125723
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#125723 - GuillaumeGomez:migrate-run-make-crate-data-smoke, r=jieyouxu

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

Part of rust-lang#121876.

r? ``@jieyouxu``
  • Loading branch information
rust-timer authored May 30, 2024
2 parents 23ea77b + 301d722 commit 1c8f516
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 13 deletions.
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 @@ -211,7 +211,7 @@ impl Rustc {

/// Get the [`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 @@ -23,7 +23,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"),
);
compare_stdout(
rustc().print("file-names").input("rlib.rs").run(),
rust_lib_name("mylib"),
);
}

0 comments on commit 1c8f516

Please sign in to comment.