Skip to content

Commit

Permalink
test(trim-paths): make test adapt to macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Oct 25, 2023
1 parent f645224 commit 77edec0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions crates/cargo-test-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ fn has_command(command: &str) -> bool {
}
};
if !output.status.success() {
// `strings` from Apple Xcode toolchain doesn't have `--version` flag.
// If we see "unknown flag" then we've found its existence!
if command == "strings"
&& String::from_utf8(output.stderr.clone())
.expect("utf8")
.find("unknown flag")
.is_some()
{
return true;
}
panic!(
"expected command `{}` to be runnable, got error {}:\n\
stderr:{}\n\
Expand Down
4 changes: 3 additions & 1 deletion tests/testsuite/profile_trim_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ warning: unused variable: `unused`
.run();
}

#[cfg(target_os = "linux")]
#[cfg(unix)]
#[cargo_test(requires_strings, nightly, reason = "-Zremap-path-scope is unstable")]
fn object_works() {
use std::os::unix::ffi::OsStrExt;
Expand Down Expand Up @@ -541,5 +541,7 @@ fn object_works() {
let stdout = run_strings(bin_path).stdout;
assert!(memchr::memmem::find(&stdout, rust_src).is_none());
assert!(memchr::memmem::find(&stdout, registry_src_bytes).is_none());
// TODO: on macOS codegen unit partitions `.rcgu.o` are still there.
#[cfg(not(target_os = "macos"))]
assert!(memchr::memmem::find(&stdout, pkg_root).is_none());
}

0 comments on commit 77edec0

Please sign in to comment.