Skip to content

Commit cef8a04

Browse files
committed
rewrite extra-filename-with-temp-outputs to rmake
1 parent b286722 commit cef8a04

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

src/tools/run-make-support/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ pub fn filename_not_in_denylist<P: AsRef<Path>, V: AsRef<[String]>>(path: P, exp
303303
.is_some_and(|name| !expected.contains(&name.to_str().unwrap().to_owned()))
304304
}
305305

306+
/// Returns true if the filename at `path` ends with `suffix`.
307+
pub fn has_suffix<P: AsRef<Path>>(path: P, suffix: &str) -> bool {
308+
path.as_ref().file_name().is_some_and(|name| name.to_str().unwrap().ends_with(suffix))
309+
}
310+
306311
/// Gathers all files in the current working directory that have the extension `ext`, and counts
307312
/// the number of lines within that contain a match with the regex pattern `re`.
308313
pub fn count_regex_matches_in_files_with_extension(re: &regex::Regex, ext: &str) -> usize {

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ run-make/extern-fn-with-packed-struct/Makefile
3737
run-make/extern-fn-with-union/Makefile
3838
run-make/extern-multiple-copies/Makefile
3939
run-make/extern-multiple-copies2/Makefile
40-
run-make/extra-filename-with-temp-outputs/Makefile
4140
run-make/fmt-write-bloat/Makefile
4241
run-make/foreign-double-unwind/Makefile
4342
run-make/foreign-exceptions/Makefile

tests/run-make/extra-filename-with-temp-outputs/Makefile

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// In order to prevent temporary files from overwriting each other in parallel
2+
// compilation, rustc was changed to mix an extra filename with temporary
3+
// outputs. However, as this is a similar behavior with the codegen flag
4+
// -C extra-filename, this test checks that the manually passed flag
5+
// is not overwritten by this feature, and that the output files
6+
// are named as expected.
7+
// See https://github.com/rust-lang/rust/pull/15686
8+
9+
//FIXME(Oneirical): ignore-cross-compile
10+
11+
use run_make_support::{
12+
bin_name, cwd, fs_wrapper, has_prefix, has_suffix, rustc, shallow_find_files,
13+
};
14+
15+
fn main() {
16+
rustc().extra_filename("bar").input("foo.rs").arg("-Csave-temps").run();
17+
let object_files = shallow_find_files(cwd(), |path| {
18+
has_prefix(path, "foobar.foo") && has_suffix(path, "0.rcgu.o")
19+
});
20+
let object_file = object_files.get(0).unwrap();
21+
fs_wrapper::remove_file(object_file);
22+
fs_wrapper::remove_file(bin_name("foobar"));
23+
}

0 commit comments

Comments
 (0)