Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 99c5a83

Browse files
committedJun 8, 2024·
Auto merge of rust-lang#126097 - Kobzol:runmake-change-cwd, r=jieyouxu
Change how runmake v2 tests are executed This PR makes execution of v2 runmake tests more sane, by executing each test in a temporary directory by default, rather than running it inside `tests/run-make`. This will have.. a lot of conflicts. Fixes: rust-lang#126080 Closes rust-lang#125726, because it removes `tmp_dir`, lol. r? `@jieyouxu`
2 parents 16e8803 + ca583cb commit 99c5a83

File tree

74 files changed

+274
-302
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+274
-302
lines changed
 

‎src/tools/compiletest/src/runtest.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::errors::{self, Error, ErrorKind};
1515
use crate::header::TestProps;
1616
use crate::json;
1717
use crate::read2::{read2_abbreviated, Truncated};
18-
use crate::util::{add_dylib_path, dylib_env_var, logv, PathBufExt};
18+
use crate::util::{add_dylib_path, copy_dir_all, dylib_env_var, logv, PathBufExt};
1919
use crate::ColorConfig;
2020
use colored::Colorize;
2121
use miropt_test_tools::{files_for_miropt_test, MiroptTest, MiroptTestFile};
@@ -3458,6 +3458,21 @@ impl<'test> TestCx<'test> {
34583458
let rmake_out_dir = base_dir.join("rmake_out");
34593459
create_dir_all(&rmake_out_dir).unwrap();
34603460

3461+
// Copy all input files (apart from rmake.rs) to the temporary directory,
3462+
// so that the input directory structure from `tests/run-make/<test>` is mirrored
3463+
// to the `rmake_out` directory.
3464+
for path in walkdir::WalkDir::new(&self.testpaths.file).min_depth(1) {
3465+
let path = path.unwrap().path().to_path_buf();
3466+
if path.file_name().is_some_and(|s| s != "rmake.rs") {
3467+
let target = rmake_out_dir.join(path.strip_prefix(&self.testpaths.file).unwrap());
3468+
if path.is_dir() {
3469+
copy_dir_all(&path, target).unwrap();
3470+
} else {
3471+
fs::copy(&path, target).unwrap();
3472+
}
3473+
}
3474+
}
3475+
34613476
// HACK: assume stageN-target, we only want stageN.
34623477
let stage = self.config.stage_id.split('-').next().unwrap();
34633478

@@ -3517,18 +3532,11 @@ impl<'test> TestCx<'test> {
35173532
.env("PYTHON", &self.config.python)
35183533
.env("RUST_BUILD_STAGE", &self.config.stage_id)
35193534
.env("RUSTC", cwd.join(&self.config.rustc_path))
3520-
.env("TMPDIR", &rmake_out_dir)
35213535
.env("LD_LIB_PATH_ENVVAR", dylib_env_var())
35223536
.env(dylib_env_var(), &host_dylib_env_paths)
35233537
.env("HOST_RPATH_DIR", cwd.join(&self.config.compile_lib_path))
35243538
.env("TARGET_RPATH_DIR", cwd.join(&self.config.run_lib_path))
3525-
.env("LLVM_COMPONENTS", &self.config.llvm_components)
3526-
// We for sure don't want these tests to run in parallel, so make
3527-
// sure they don't have access to these vars if we run via `make`
3528-
// at the top level
3529-
.env_remove("MAKEFLAGS")
3530-
.env_remove("MFLAGS")
3531-
.env_remove("CARGO_MAKEFLAGS");
3539+
.env("LLVM_COMPONENTS", &self.config.llvm_components);
35323540

35333541
if std::env::var_os("COMPILETEST_FORCE_STAGE0").is_some() {
35343542
let mut stage0_sysroot = build_root.clone();
@@ -3558,7 +3566,7 @@ impl<'test> TestCx<'test> {
35583566
let target_rpath_env_path = env::join_paths(target_rpath_env_path).unwrap();
35593567

35603568
let mut cmd = Command::new(&recipe_bin);
3561-
cmd.current_dir(&self.testpaths.file)
3569+
cmd.current_dir(&rmake_out_dir)
35623570
.stdout(Stdio::piped())
35633571
.stderr(Stdio::piped())
35643572
.env("LD_LIB_PATH_ENVVAR", dylib_env_var())
@@ -3569,16 +3577,9 @@ impl<'test> TestCx<'test> {
35693577
.env("SOURCE_ROOT", &src_root)
35703578
.env("RUST_BUILD_STAGE", &self.config.stage_id)
35713579
.env("RUSTC", cwd.join(&self.config.rustc_path))
3572-
.env("TMPDIR", &rmake_out_dir)
35733580
.env("HOST_RPATH_DIR", cwd.join(&self.config.compile_lib_path))
35743581
.env("TARGET_RPATH_DIR", cwd.join(&self.config.run_lib_path))
3575-
.env("LLVM_COMPONENTS", &self.config.llvm_components)
3576-
// We for sure don't want these tests to run in parallel, so make
3577-
// sure they don't have access to these vars if we run via `make`
3578-
// at the top level
3579-
.env_remove("MAKEFLAGS")
3580-
.env_remove("MFLAGS")
3581-
.env_remove("CARGO_MAKEFLAGS");
3582+
.env("LLVM_COMPONENTS", &self.config.llvm_components);
35823583

35833584
if let Some(ref rustdoc) = self.config.rustdoc_path {
35843585
cmd.env("RUSTDOC", cwd.join(rustdoc));

‎src/tools/compiletest/src/util.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::common::Config;
22
use std::env;
33
use std::ffi::OsStr;
4-
use std::path::PathBuf;
4+
use std::path::{Path, PathBuf};
55
use std::process::Command;
66

77
use tracing::*;
@@ -76,3 +76,17 @@ pub fn add_dylib_path(cmd: &mut Command, paths: impl Iterator<Item = impl Into<P
7676
let new_paths = paths.map(Into::into).chain(old_paths.into_iter().flatten());
7777
cmd.env(dylib_env_var(), env::join_paths(new_paths).unwrap());
7878
}
79+
80+
pub fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io::Result<()> {
81+
std::fs::create_dir_all(&dst)?;
82+
for entry in std::fs::read_dir(src)? {
83+
let entry = entry?;
84+
let ty = entry.file_type()?;
85+
if ty.is_dir() {
86+
copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?;
87+
} else {
88+
std::fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
89+
}
90+
}
91+
Ok(())
92+
}

0 commit comments

Comments
 (0)
This repository has been archived.