Skip to content

Commit baf948d

Browse files
Allow to pass a full path for run-make tests
1 parent 49649bf commit baf948d

File tree

2 files changed

+23
-30
lines changed

2 files changed

+23
-30
lines changed

src/tools/compiletest/src/lib.rs

+13-18
Original file line numberDiff line numberDiff line change
@@ -666,15 +666,24 @@ fn collect_tests_from_dir(
666666
}
667667

668668
if config.mode == Mode::RunMake {
669-
if dir.join("Makefile").exists() && dir.join("rmake.rs").exists() {
669+
let makefile_path = dir.join("Makefile");
670+
let rmake_path = dir.join("rmake.rs");
671+
if makefile_path.exists() && rmake_path.exists() {
670672
return Err(io::Error::other(
671673
"run-make tests cannot have both `Makefile` and `rmake.rs`",
672674
));
673675
}
674676

675-
if dir.join("Makefile").exists() || dir.join("rmake.rs").exists() {
677+
if rmake_path.exists() {
676678
let paths = TestPaths {
677-
file: dir.to_path_buf(),
679+
file: rmake_path,
680+
relative_dir: relative_dir_path.parent().unwrap().to_path_buf(),
681+
};
682+
tests.extend(make_test(config, cache, &paths, inputs, poisoned));
683+
return Ok(());
684+
} else if makefile_path.exists() {
685+
let paths = TestPaths {
686+
file: makefile_path,
678687
relative_dir: relative_dir_path.parent().unwrap().to_path_buf(),
679688
};
680689
tests.extend(make_test(config, cache, &paths, inputs, poisoned));
@@ -750,21 +759,7 @@ fn make_test(
750759
inputs: &Stamp,
751760
poisoned: &mut bool,
752761
) -> Vec<test::TestDescAndFn> {
753-
let test_path = if config.mode == Mode::RunMake {
754-
if testpaths.file.join("rmake.rs").exists() && testpaths.file.join("Makefile").exists() {
755-
panic!("run-make tests cannot have both `rmake.rs` and `Makefile`");
756-
}
757-
758-
if testpaths.file.join("rmake.rs").exists() {
759-
// Parse directives in rmake.rs.
760-
testpaths.file.join("rmake.rs")
761-
} else {
762-
// Parse directives in the Makefile.
763-
testpaths.file.join("Makefile")
764-
}
765-
} else {
766-
PathBuf::from(&testpaths.file)
767-
};
762+
let test_path = PathBuf::from(&testpaths.file);
768763
let early_props = EarlyProps::from_file(&config, &test_path);
769764

770765
// Incremental tests are special, they inherently cannot be run in parallel.

src/tools/compiletest/src/runtest.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub fn run(config: Arc<Config>, testpaths: &TestPaths, revision: Option<&str>) {
125125
// We're going to be dumping a lot of info. Start on a new line.
126126
print!("\n\n");
127127
}
128-
debug!("running {:?}", testpaths.file.display());
128+
eprintln!("running {:?}", testpaths.file.display());
129129
let mut props = TestProps::from_file(&testpaths.file, revision, &config);
130130

131131
// For non-incremental (i.e. regular UI) tests, the incremental directory
@@ -3253,13 +3253,10 @@ impl<'test> TestCx<'test> {
32533253
}
32543254

32553255
fn run_rmake_test(&self) {
3256-
let test_dir = &self.testpaths.file;
3257-
if test_dir.join("rmake.rs").exists() {
3258-
self.run_rmake_v2_test();
3259-
} else if test_dir.join("Makefile").exists() {
3260-
self.run_rmake_legacy_test();
3261-
} else {
3262-
self.fatal("failed to find either `rmake.rs` or `Makefile`")
3256+
match &self.testpaths.file.iter().last() {
3257+
Some(s) if *s == OsStr::new("rmake.rs") => self.run_rmake_v2_test(),
3258+
Some(s) if *s == OsStr::new("Makefile") => self.run_rmake_legacy_test(),
3259+
_ => self.fatal("failed to find either `rmake.rs` or `Makefile`"),
32633260
}
32643261
}
32653262

@@ -3287,7 +3284,7 @@ impl<'test> TestCx<'test> {
32873284
};
32883285

32893286
let mut cmd = Command::new(make);
3290-
cmd.current_dir(&self.testpaths.file)
3287+
cmd.current_dir(&self.testpaths.file.parent().unwrap())
32913288
.stdout(Stdio::piped())
32923289
.stderr(Stdio::piped())
32933290
.env("TARGET", &self.config.target)
@@ -3487,10 +3484,11 @@ impl<'test> TestCx<'test> {
34873484
// Copy all input files (apart from rmake.rs) to the temporary directory,
34883485
// so that the input directory structure from `tests/run-make/<test>` is mirrored
34893486
// to the `rmake_out` directory.
3490-
for path in walkdir::WalkDir::new(&self.testpaths.file).min_depth(1) {
3487+
let parent = self.testpaths.file.parent().unwrap();
3488+
for path in walkdir::WalkDir::new(&parent).min_depth(1) {
34913489
let path = path.unwrap().path().to_path_buf();
34923490
if path.file_name().is_some_and(|s| s != "rmake.rs") {
3493-
let target = rmake_out_dir.join(path.strip_prefix(&self.testpaths.file).unwrap());
3491+
let target = rmake_out_dir.join(path.strip_prefix(&parent).unwrap());
34943492
if path.is_dir() {
34953493
copy_dir_all(&path, target).unwrap();
34963494
} else {
@@ -3588,7 +3586,7 @@ impl<'test> TestCx<'test> {
35883586
.arg("--extern")
35893587
.arg(format!("run_make_support={}", &support_lib_path.to_string_lossy()))
35903588
.arg("--edition=2021")
3591-
.arg(&self.testpaths.file.join("rmake.rs"))
3589+
.arg(&self.testpaths.file)
35923590
// Provide necessary library search paths for rustc.
35933591
.env(dylib_env_var(), &env::join_paths(host_dylib_search_paths).unwrap());
35943592

0 commit comments

Comments
 (0)