Skip to content

tests: Port split-debuginfo to rmake.rs #135572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 6, 2025
12 changes: 12 additions & 0 deletions src/tools/run-make-support/src/external_deps/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,18 @@ impl Rustc {
self
}

/// Specify `-C debuginfo=...`.
pub fn debuginfo(&mut self, level: &str) -> &mut Self {
self.cmd.arg(format!("-Cdebuginfo={level}"));
self
}

/// Specify `-C split-debuginfo={packed,unpacked,off}`.
pub fn split_debuginfo(&mut self, split_kind: &str) -> &mut Self {
self.cmd.arg(format!("-Csplit-debuginfo={split_kind}"));
self
}

/// Pass the `--verbose` flag.
pub fn verbose(&mut self) -> &mut Self {
self.cmd.arg("--verbose");
Expand Down
4 changes: 1 addition & 3 deletions src/tools/run-make-support/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,7 @@ pub fn set_permissions<P: AsRef<Path>>(path: P, perm: std::fs::Permissions) {
));
}

/// A function which prints all file names in the directory `dir` similarly to Unix's `ls`.
/// Useful for debugging.
/// Usage: `eprintln!("{:#?}", shallow_find_dir_entries(some_dir));`
/// List directory entries immediately under the given `dir`.
#[track_caller]
pub fn shallow_find_dir_entries<P: AsRef<Path>>(dir: P) -> Vec<PathBuf> {
let paths = read_dir(dir);
Expand Down
4 changes: 2 additions & 2 deletions src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ pub use artifact_names::{

/// Path-related helpers.
pub use path_helpers::{
cwd, filename_contains, filename_not_in_denylist, has_extension, has_prefix, has_suffix,
not_contains, path, shallow_find_files, build_root, source_root,
build_root, cwd, filename_contains, filename_not_in_denylist, has_extension, has_prefix,
has_suffix, not_contains, path, shallow_find_directories, shallow_find_files, source_root,
};

/// Helpers for scoped test execution where certain properties are attempted to be maintained.
Expand Down
19 changes: 19 additions & 0 deletions src/tools/run-make-support/src/path_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ pub fn shallow_find_files<P: AsRef<Path>, F: Fn(&PathBuf) -> bool>(
matching_files
}

/// Browse the directory `path` non-recursively and return all directories which respect the
/// parameters outlined by `closure`.
#[track_caller]
pub fn shallow_find_directories<P: AsRef<Path>, F: Fn(&PathBuf) -> bool>(
path: P,
filter: F,
) -> Vec<PathBuf> {
let mut matching_files = Vec::new();
for entry in rfs::read_dir(path) {
let entry = entry.expect("failed to read directory entry.");
let path = entry.path();

if path.is_dir() && filter(&path) {
matching_files.push(path);
}
}
matching_files
}

/// Returns true if the filename at `path` does not contain `expected`.
pub fn not_contains<P: AsRef<Path>>(path: P, expected: &str) -> bool {
!path.as_ref().file_name().is_some_and(|name| name.to_str().unwrap().contains(expected))
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
@@ -1 +0,0 @@
run-make/split-debuginfo/Makefile
Loading
Loading