fix(cli): skip platform-specific test assertions when tools are unavailable (#5386)

The test_harnesses::run_harness test panics on machines without
Android NDK/SDK installed and on non-macOS platforms for iOS
assertions. Skip these assertions gracefully instead of failing
the entire test suite.

- Android assertions: skip when get_android_tools() returns None
- iOS assertions: skip when not running on macOS
This commit is contained in:
Brock authored and GitHub committed 2026-03-26 23:35:25 -07:00
1 parent 232a8dc83d
commit 0d94a51ec8
1 file changed
+19
+19
View File
@@ -100,16 +100,27 @@ async fn test_harnesses() {
assert_eq!(t.client.bundle, BundleFormat::host());
})
.asrt(r#"dx build --ios"#, |targets| async move {
if cfg!(not(target_os = "macos")) {
// iOS builds require Xcode toolchain, only available on macOS
return;
}
let t = targets.unwrap();
assert_eq!(t.client.bundle, BundleFormat::Ios);
assert_eq!(t.client.triple, TestHarnessBuilder::host_ios_triple_sim());
})
.asrt(r#"dx build --ios --device"#, |targets| async move {
if cfg!(not(target_os = "macos")) {
return;
}
let targets = targets.unwrap();
assert_eq!(targets.client.bundle, BundleFormat::Ios);
assert_eq!(targets.client.triple, "aarch64-apple-ios".parse().unwrap());
})
.asrt(r#"dx build --android --device"#, |targets| async move {
if crate::get_android_tools().is_none() {
// Skip when Android NDK/SDK is not installed
return;
}
let t = targets.unwrap();
assert_eq!(t.client.bundle, BundleFormat::Android);
assert_eq!(t.client.triple, "aarch64-linux-android".parse().unwrap());
@@ -131,6 +142,10 @@ async fn test_harnesses() {
assert_eq!(server.triple, Triple::host());
})
.asrt(r#"dx build --ios"#, |targets| async move {
if cfg!(not(target_os = "macos")) {
// iOS builds require Xcode toolchain, only available on macOS
return;
}
let t = targets.unwrap();
assert_eq!(t.client.bundle, BundleFormat::Ios);
assert_eq!(t.client.triple, TestHarnessBuilder::host_ios_triple_sim());
@@ -231,6 +246,10 @@ async fn test_harnesses() {
.asrt(
r#"dx build --ios"#,
|targets| async move {
if cfg!(not(target_os = "macos")) {
// iOS builds require Xcode toolchain, only available on macOS
return;
}
let t = targets.unwrap();
assert!(t.server.is_none());
assert_eq!(t.client.bundle, BundleFormat::Ios);