Skip to content

Commit ae2a95e

Browse files
committed
test(trim-paths): make test adapt to macOS
1 parent f645224 commit ae2a95e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

crates/cargo-test-macro/src/lib.rs

+10
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,16 @@ fn has_command(command: &str) -> bool {
221221
}
222222
};
223223
if !output.status.success() {
224+
// `strings` from Apple Xcode toolchain doesn't have `--version` flag.
225+
// If we see "unknown flag" then we've found its existence!
226+
if command == "strings"
227+
&& String::from_utf8(output.stdout.clone())
228+
.expect("utf8")
229+
.find("unknown flag")
230+
.is_some()
231+
{
232+
return true;
233+
}
224234
panic!(
225235
"expected command `{}` to be runnable, got error {}:\n\
226236
stderr:{}\n\

tests/testsuite/profile_trim_paths.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ warning: unused variable: `unused`
447447
.run();
448448
}
449449

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

0 commit comments

Comments
 (0)