Skip to content

Commit 20e86c9

Browse files
authored
Rollup merge of #128100 - GuillaumeGomez:run-make-path, r=Kobzol,jieyouxu
Allow to pass a full path for `run-make` tests It's common (at least for me) to pass a full path to a `run-make` test (including the `rmake.rs` file) and to see that it isn't found, which is a bit frustrating. With these changes, we can now optionally pass the `rmake.rs` (or even `Makefile`) at the end of the path. cc ```@jieyouxu``` r? ```@Kobzol```
2 parents ee77dda + 0728c15 commit 20e86c9

File tree

1 file changed

+25
-2
lines changed
  • src/tools/compiletest/src

1 file changed

+25
-2
lines changed

Diff for: src/tools/compiletest/src/lib.rs

+25-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use build_helper::git::{get_git_modified_files, get_git_untracked_files};
2525
use core::panic;
2626
use getopts::Options;
2727
use std::collections::HashSet;
28-
use std::ffi::OsString;
28+
use std::ffi::{OsStr, OsString};
2929
use std::fs;
3030
use std::io::{self, ErrorKind};
3131
use std::path::{Path, PathBuf};
@@ -225,6 +225,29 @@ pub fn parse_config(args: Vec<String>) -> Config {
225225
// Avoid spawning an external command when we know tidy won't be used.
226226
false
227227
};
228+
let filters = if mode == Mode::RunMake {
229+
matches
230+
.free
231+
.iter()
232+
.map(|f| {
233+
let path = Path::new(f);
234+
let mut iter = path.iter().skip(1);
235+
236+
// We skip the test folder and check if the user passed `rmake.rs` or `Makefile`.
237+
if iter
238+
.next()
239+
.is_some_and(|s| s == OsStr::new("rmake.rs") || s == OsStr::new("Makefile"))
240+
&& iter.next().is_none()
241+
{
242+
path.parent().unwrap().to_str().unwrap().to_string()
243+
} else {
244+
f.to_string()
245+
}
246+
})
247+
.collect::<Vec<_>>()
248+
} else {
249+
matches.free.clone()
250+
};
228251
Config {
229252
bless: matches.opt_present("bless"),
230253
compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")),
@@ -249,7 +272,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
249272
debugger: None,
250273
run_ignored,
251274
with_debug_assertions,
252-
filters: matches.free.clone(),
275+
filters,
253276
skip: matches.opt_strs("skip"),
254277
filter_exact: matches.opt_present("exact"),
255278
force_pass_mode: matches.opt_str("pass").map(|mode| {

0 commit comments

Comments
 (0)