diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 0cf05b32e9681..af2ea8af6567c 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -666,15 +666,24 @@ fn collect_tests_from_dir( } if config.mode == Mode::RunMake { - if dir.join("Makefile").exists() && dir.join("rmake.rs").exists() { + let makefile_path = dir.join("Makefile"); + let rmake_path = dir.join("rmake.rs"); + if makefile_path.exists() && rmake_path.exists() { return Err(io::Error::other( "run-make tests cannot have both `Makefile` and `rmake.rs`", )); } - if dir.join("Makefile").exists() || dir.join("rmake.rs").exists() { + if rmake_path.exists() { let paths = TestPaths { - file: dir.to_path_buf(), + file: rmake_path, + relative_dir: relative_dir_path.parent().unwrap().to_path_buf(), + }; + tests.extend(make_test(config, cache, &paths, inputs, poisoned)); + return Ok(()); + } else if makefile_path.exists() { + let paths = TestPaths { + file: makefile_path, relative_dir: relative_dir_path.parent().unwrap().to_path_buf(), }; tests.extend(make_test(config, cache, &paths, inputs, poisoned)); @@ -750,21 +759,7 @@ fn make_test( inputs: &Stamp, poisoned: &mut bool, ) -> Vec { - let test_path = if config.mode == Mode::RunMake { - if testpaths.file.join("rmake.rs").exists() && testpaths.file.join("Makefile").exists() { - panic!("run-make tests cannot have both `rmake.rs` and `Makefile`"); - } - - if testpaths.file.join("rmake.rs").exists() { - // Parse directives in rmake.rs. - testpaths.file.join("rmake.rs") - } else { - // Parse directives in the Makefile. - testpaths.file.join("Makefile") - } - } else { - PathBuf::from(&testpaths.file) - }; + let test_path = PathBuf::from(&testpaths.file); let early_props = EarlyProps::from_file(&config, &test_path); // Incremental tests are special, they inherently cannot be run in parallel. diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 5398820313648..c1e18c1e00f39 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -125,7 +125,7 @@ pub fn run(config: Arc, testpaths: &TestPaths, revision: Option<&str>) { // We're going to be dumping a lot of info. Start on a new line. print!("\n\n"); } - debug!("running {:?}", testpaths.file.display()); + eprintln!("running {:?}", testpaths.file.display()); let mut props = TestProps::from_file(&testpaths.file, revision, &config); // For non-incremental (i.e. regular UI) tests, the incremental directory @@ -3253,13 +3253,10 @@ impl<'test> TestCx<'test> { } fn run_rmake_test(&self) { - let test_dir = &self.testpaths.file; - if test_dir.join("rmake.rs").exists() { - self.run_rmake_v2_test(); - } else if test_dir.join("Makefile").exists() { - self.run_rmake_legacy_test(); - } else { - self.fatal("failed to find either `rmake.rs` or `Makefile`") + match &self.testpaths.file.iter().last() { + Some(s) if *s == OsStr::new("rmake.rs") => self.run_rmake_v2_test(), + Some(s) if *s == OsStr::new("Makefile") => self.run_rmake_legacy_test(), + _ => self.fatal("failed to find either `rmake.rs` or `Makefile`"), } } @@ -3287,7 +3284,7 @@ impl<'test> TestCx<'test> { }; let mut cmd = Command::new(make); - cmd.current_dir(&self.testpaths.file) + cmd.current_dir(&self.testpaths.file.parent().unwrap()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .env("TARGET", &self.config.target) @@ -3487,10 +3484,11 @@ impl<'test> TestCx<'test> { // Copy all input files (apart from rmake.rs) to the temporary directory, // so that the input directory structure from `tests/run-make/` is mirrored // to the `rmake_out` directory. - for path in walkdir::WalkDir::new(&self.testpaths.file).min_depth(1) { + let parent = self.testpaths.file.parent().unwrap(); + for path in walkdir::WalkDir::new(&parent).min_depth(1) { let path = path.unwrap().path().to_path_buf(); if path.file_name().is_some_and(|s| s != "rmake.rs") { - let target = rmake_out_dir.join(path.strip_prefix(&self.testpaths.file).unwrap()); + let target = rmake_out_dir.join(path.strip_prefix(&parent).unwrap()); if path.is_dir() { copy_dir_all(&path, target).unwrap(); } else { @@ -3588,7 +3586,7 @@ impl<'test> TestCx<'test> { .arg("--extern") .arg(format!("run_make_support={}", &support_lib_path.to_string_lossy())) .arg("--edition=2021") - .arg(&self.testpaths.file.join("rmake.rs")) + .arg(&self.testpaths.file) // Provide necessary library search paths for rustc. .env(dylib_env_var(), &env::join_paths(host_dylib_search_paths).unwrap());