Skip to content

Commit

Permalink
rewrite extra-filename-with-temp-outputs to rmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jul 12, 2024
1 parent b286722 commit cef8a04
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ pub fn filename_not_in_denylist<P: AsRef<Path>, V: AsRef<[String]>>(path: P, exp
.is_some_and(|name| !expected.contains(&name.to_str().unwrap().to_owned()))
}

/// Returns true if the filename at `path` ends with `suffix`.
pub fn has_suffix<P: AsRef<Path>>(path: P, suffix: &str) -> bool {
path.as_ref().file_name().is_some_and(|name| name.to_str().unwrap().ends_with(suffix))
}

/// Gathers all files in the current working directory that have the extension `ext`, and counts
/// the number of lines within that contain a match with the regex pattern `re`.
pub fn count_regex_matches_in_files_with_extension(re: &regex::Regex, ext: &str) -> usize {
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ run-make/extern-fn-with-packed-struct/Makefile
run-make/extern-fn-with-union/Makefile
run-make/extern-multiple-copies/Makefile
run-make/extern-multiple-copies2/Makefile
run-make/extra-filename-with-temp-outputs/Makefile
run-make/fmt-write-bloat/Makefile
run-make/foreign-double-unwind/Makefile
run-make/foreign-exceptions/Makefile
Expand Down
7 changes: 0 additions & 7 deletions tests/run-make/extra-filename-with-temp-outputs/Makefile

This file was deleted.

23 changes: 23 additions & 0 deletions tests/run-make/extra-filename-with-temp-outputs/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// In order to prevent temporary files from overwriting each other in parallel
// compilation, rustc was changed to mix an extra filename with temporary
// outputs. However, as this is a similar behavior with the codegen flag
// -C extra-filename, this test checks that the manually passed flag
// is not overwritten by this feature, and that the output files
// are named as expected.
// See https://github.com/rust-lang/rust/pull/15686

//FIXME(Oneirical): ignore-cross-compile

use run_make_support::{
bin_name, cwd, fs_wrapper, has_prefix, has_suffix, rustc, shallow_find_files,
};

fn main() {
rustc().extra_filename("bar").input("foo.rs").arg("-Csave-temps").run();
let object_files = shallow_find_files(cwd(), |path| {
has_prefix(path, "foobar.foo") && has_suffix(path, "0.rcgu.o")
});
let object_file = object_files.get(0).unwrap();
fs_wrapper::remove_file(object_file);
fs_wrapper::remove_file(bin_name("foobar"));
}

0 comments on commit cef8a04

Please sign in to comment.