diff --git a/.travis.sh b/.travis.sh index 75d80b45..ad4b6057 100755 --- a/.travis.sh +++ b/.travis.sh @@ -4,7 +4,7 @@ set -x title() { set +x - echo -e '\n\033[1;33m '$@' \033[0m\n' + echo -e '\n\033[1;33m '$@' \033[0m\n' set -x } @@ -40,7 +40,7 @@ tests_sequence() { && ! $CARGO_DINGHY -d $1 test fails \ && ! $CARGO_DINGHY -d $1 test \ ) - + title "testing from project directory" ( \ cd test-ws/test-app \ @@ -49,7 +49,7 @@ tests_sequence() { && ! $CARGO_DINGHY -d $1 test fails \ && ! $CARGO_DINGHY -d $1 test \ ) - + title "test from workspace directory with project filter" ( \ cd test-ws \ @@ -69,7 +69,7 @@ tests_sequence_aarch64_ios_sim() { && ! $CARGO_DINGHY -d $1 -p auto-ios-aarch64-sim test fails \ && ! $CARGO_DINGHY -d $1 -p auto-ios-aarch64-sim test \ ) - + title "testing from project directory" ( \ cd test-ws/test-app \ @@ -78,7 +78,7 @@ tests_sequence_aarch64_ios_sim() { && ! $CARGO_DINGHY -d $1 -p auto-ios-aarch64-sim test fails \ && ! $CARGO_DINGHY -d $1 -p auto-ios-aarch64-sim test \ ) - + title "test from workspace directory with project filter" ( \ cd test-ws \ @@ -89,6 +89,39 @@ tests_sequence_aarch64_ios_sim() { ) } +tests_sequence_unstable_target() { + # There's something odd with using the .cargo/config runner attribute and + # workspaces when the runner uses `cargo run --manifest-path ../Cargo.toml + # --bin cargo-dinghy ...` + title "testing from project directory for rust target $1 on device $2" + title "testing from workspace directory" + ( \ + cd test-ws \ + && cargo clean \ + && $CARGO_DINGHY -d $1 -p $2 +nightly test -Zbuild-std pass \ + && ! $CARGO_DINGHY -d $1 -p $2 +nightly test -Zbuild-std fails \ + && ! $CARGO_DINGHY -d $1 -p $2 +nightly test -Zbuild-std \ + ) + + title "testing from project directory" + ( \ + cd test-ws/test-app \ + && cargo clean \ + && $CARGO_DINGHY -d $1 -p $2 +nightly test -Zbuild-std pass \ + && ! $CARGO_DINGHY -d $1 -p $2 +nightly test -Zbuild-std fails \ + && ! $CARGO_DINGHY -d $1 -p $2 +nightly test -Zbuild-std \ + ) + + title "test from workspace directory with project filter" + ( \ + cd test-ws \ + && cargo clean \ + && $CARGO_DINGHY -d $1 -p $2 +nightly test -p test-app -Zbuild-std pass \ + && ! $CARGO_DINGHY -d $1 -p $2 +nightly test -p test-app -Zbuild-std fails \ + && ! $CARGO_DINGHY -d $1 -p $2 +nightly test -p test-app -Zbuild-std \ + ) +} + if [ `uname` = Darwin ] then @@ -124,6 +157,37 @@ then rustup target add aarch64-apple-ios tests_sequence $device fi + + title "••••• Darwin: tvos simulator tests •••••" + title "boot a simulator" + + # *-apple-{tvos,watchos}[-sim] require `-Zbuild-std` + rustup toolchain add nightly --component rust-src; + TVOS_RUNTIME_ID=$(xcrun simctl list runtimes | grep tvOS | cut -d ' ' -f 7 | tail -1) + export TV_SIM_ID=$(xcrun simctl create My-4ktv com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-3rd-generation-4K $TVOS_RUNTIME_ID) + + xcrun simctl boot $TV_SIM_ID + if [ "$(uname -m)" = "arm64" ]; then + tests_sequence_unstable_target ${TV_SIM_ID} auto-tvos-aarch64-sim + else + # The x86 tvOS simulator tripple does not end in -sim. + tests_sequence_unstable_target ${TV_SIM_ID} auto-tvos-x86_64 + fi + xcrun simctl delete $TV_SIM_ID + + title "••••• Darwin: watchvos simulator tests •••••" + title "boot a simulator" + WATCHOS_RUNTIME_ID=$(xcrun simctl list runtimes | grep watchOS | cut -d ' ' -f 7 | tail -1) + export WATCHOS_SIM_ID=$(xcrun simctl create My-apple-watch com.apple.CoreSimulator.SimDeviceType.Apple-Watch-SE-44mm-2nd-generation $WATCHOS_RUNTIME_ID) + + xcrun simctl boot $WATCHOS_SIM_ID + if [ "$(uname -m)" = "arm64" ]; then + tests_sequence_unstable_target ${WATCHOS_SIM_ID} auto-watchos-aarch64-sim + else + tests_sequence_unstable_target ${WATCHOS_SIM_ID} auto-watchos-x86_64-sim + fi + xcrun simctl delete $WATCHOS_SIM_ID + rustup default stable else if [ -n "$ANDROID_SDK_ROOT" ] then @@ -150,7 +214,7 @@ else echo no | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager create avd -n testdinghy -k "system-images;android-24;default;armeabi-v7a" $EMULATOR @testdinghy -no-audio -no-boot-anim -no-window -accel on -gpu off & timeout 180 $ANDROID_SDK_ROOT/platform-tools/adb wait-for-device - + export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/22.1.7171670 tests_sequence android diff --git a/dinghy-lib/src/ios/device.rs b/dinghy-lib/src/apple/device.rs similarity index 91% rename from dinghy-lib/src/ios/device.rs rename to dinghy-lib/src/apple/device.rs index 55efcd3a..bc5c7ce3 100644 --- a/dinghy-lib/src/ios/device.rs +++ b/dinghy-lib/src/apple/device.rs @@ -1,7 +1,7 @@ -use super::xcode; +use super::{xcode, AppleSimulatorType}; use crate::device::make_remote_app_with_name; use crate::errors::*; -use crate::ios::IosPlatform; +use crate::apple::AppleDevicePlatform; use crate::project::Project; use crate::utils::LogCommandExt; use crate::utils::{get_current_verbosity, user_facing_log}; @@ -27,10 +27,11 @@ pub struct IosDevice { } #[derive(Clone, Debug)] -pub struct IosSimDevice { +pub struct AppleSimDevice { pub id: String, pub name: String, pub os: String, + pub sim_type: AppleSimulatorType, } unsafe impl Send for IosDevice {} @@ -76,7 +77,7 @@ impl IosDevice { .last() .ok_or_else(|| anyhow!("no app id ?"))?; - let build_bundle = make_ios_app(project, build, runnable, &app_id)?; + let build_bundle = make_apple_app(project, build, runnable, &app_id, None)?; super::xcode::sign_app(&build_bundle, &signing)?; Ok(build_bundle) @@ -191,7 +192,7 @@ impl Device for IosDevice { } } -impl IosSimDevice { +impl AppleSimDevice { fn install_app( &self, project: &Project, @@ -203,7 +204,7 @@ impl IosSimDevice { &format!("{} to {}", build.runnable.id, self.id), 0, ); - let build_bundle = IosSimDevice::make_app(project, build, runnable)?; + let build_bundle = self.make_app(project, build, runnable)?; let _ = process::Command::new("xcrun") .args(&["simctl", "uninstall", &self.id, "Dinghy"]) .log_invocation(2) @@ -231,12 +232,12 @@ impl IosSimDevice { } } - fn make_app(project: &Project, build: &Build, runnable: &Runnable) -> Result { - make_ios_app(project, build, runnable, "Dinghy") + fn make_app(&self, project: &Project, build: &Build, runnable: &Runnable) -> Result { + make_apple_app(project, build, runnable, "Dinghy", Some(&self.sim_type)) } } -impl Device for IosSimDevice { +impl Device for AppleSimDevice { fn clean_app(&self, _build_bundle: &BuildBundle) -> Result<()> { unimplemented!() } @@ -312,11 +313,11 @@ impl Display for IosDevice { } } -impl Display for IosSimDevice { +impl Display for AppleSimDevice { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { Ok(fmt.write_str( format!( - "IosSimDevice {{ \"id\": \"{}\", \"name\": {}, \"os\": {} }}", + "AppleSimDevice {{ \"id\": \"{}\", \"name\": {}, \"os\": {} }}", self.id, self.name, self.os ) .as_str(), @@ -325,8 +326,8 @@ impl Display for IosSimDevice { } impl DeviceCompatibility for IosDevice { - fn is_compatible_with_ios_platform(&self, platform: &IosPlatform) -> bool { - if platform.sim { + fn is_compatible_with_simulator_platform(&self, platform: &AppleDevicePlatform) -> bool { + if platform.sim.is_some() { return false; } @@ -337,19 +338,22 @@ impl DeviceCompatibility for IosDevice { } } -impl DeviceCompatibility for IosSimDevice { - fn is_compatible_with_ios_platform(&self, platform: &IosPlatform) -> bool { - platform.sim - && (platform.toolchain.rustc_triple == "x86_64-apple-ios" - || platform.toolchain.rustc_triple == "aarch64-apple-ios-sim") +impl DeviceCompatibility for AppleSimDevice { + fn is_compatible_with_simulator_platform(&self, platform: &AppleDevicePlatform) -> bool { + if let Some(sim) = &platform.sim { + self.sim_type == *sim + } else { + false + } } } -fn make_ios_app( +fn make_apple_app( project: &Project, build: &Build, runnable: &Runnable, app_id: &str, + sim_type: Option<&AppleSimulatorType>, ) -> Result { use crate::project; let build_bundle = make_remote_app_with_name(project, build, Some("Dinghy.app"))?; @@ -368,11 +372,12 @@ fn make_ios_app( .split(" ") .last() .ok_or_else(|| anyhow!("empty magic"))?; - xcode::add_plist_to_app(&build_bundle, target, app_id)?; + xcode::add_plist_to_app(&build_bundle, target, app_id, sim_type)?; Ok(build_bundle) } -fn launch_app(dev: &IosSimDevice, app_args: &[&str], _envs: &[&str]) -> Result<()> { + +fn launch_app(dev: &AppleSimDevice, app_args: &[&str], _envs: &[&str]) -> Result<()> { use std::io::Write; let dir = ::tempdir::TempDir::new("mobiledevice-rs-lldb")?; let tmppath = dir.path(); @@ -397,6 +402,7 @@ fn launch_app(dev: &IosSimDevice, app_args: &[&str], _envs: &[&str]) -> Result<( .log_invocation(1) .output()?; let launch_output = String::from_utf8_lossy(&launch_output.stdout); + debug!("xcrun simctl launch output: {:?}", launch_output); // Output from the launch command should be "Dinghy: $PID" which is after the 8th character. let dinghy_pid = launch_output.split_at(8).1; @@ -458,12 +464,12 @@ fn launch_app(dev: &IosSimDevice, app_args: &[&str], _envs: &[&str]) -> Result<( ); } } else { - panic!("Failed to get the exit status line from lldb: {:?}", output); + panic!("Failed to get the exit status line from lldb: {}", output); } } fn launch_lldb_simulator( - dev: &IosSimDevice, + dev: &AppleSimDevice, installed: &str, args: &[&str], envs: &[&str], diff --git a/dinghy-lib/src/ios/helpers.py b/dinghy-lib/src/apple/helpers.py similarity index 100% rename from dinghy-lib/src/ios/helpers.py rename to dinghy-lib/src/apple/helpers.py diff --git a/dinghy-lib/src/ios/mod.rs b/dinghy-lib/src/apple/mod.rs similarity index 53% rename from dinghy-lib/src/ios/mod.rs rename to dinghy-lib/src/apple/mod.rs index 0f1d7edc..aa2ab44c 100644 --- a/dinghy-lib/src/ios/mod.rs +++ b/dinghy-lib/src/apple/mod.rs @@ -1,5 +1,7 @@ -pub use self::device::{IosDevice, IosSimDevice}; -pub use self::platform::IosPlatform; +use std::fmt::Display; + +pub use self::device::{IosDevice, AppleSimDevice}; +pub use self::platform::AppleDevicePlatform; use crate::{Device, Platform, PlatformManager, Result}; mod device; @@ -25,6 +27,23 @@ pub struct SigningIdentity { pub team: String, } +#[derive(Debug, Clone, PartialEq)] +pub enum AppleSimulatorType { + Ios, + Watchos, + Tvos, +} +impl Display for AppleSimulatorType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let val = match self { + AppleSimulatorType::Ios => "ios", + AppleSimulatorType::Watchos => "watchos", + AppleSimulatorType::Tvos => "tvos", + }; + f.write_str(val) + } +} + pub struct IosManager { devices: Vec>, } @@ -35,7 +54,7 @@ impl IosManager { .context("Could not list iOS devices")? .into_iter() .chain( - simulators() + simulators(AppleSimulatorType::Ios) .context("Could not list iOS simulators")? .into_iter(), ) @@ -66,9 +85,117 @@ impl PlatformManager for IosManager { } else { format!("aarch64-apple-ios-sim") }; - IosPlatform::new( + + let simulator = if *arch == "x86_64" || *arch == "aarch64-sim" { + Some(AppleSimulatorType::Ios) + } else { + None + }; + + AppleDevicePlatform::new( + id, + &rustc_triple, + simulator, + crate::config::PlatformConfiguration::default(), + ) + .map(|pf| pf as Box) + }) + .collect() + } +} + +pub struct WatchosManager { + devices: Vec>, +} + +impl WatchosManager { + pub fn new() -> Result> { + let devices = simulators(AppleSimulatorType::Watchos)?; + Ok(Some(Self { devices })) + } +} +impl PlatformManager for WatchosManager { + fn devices(&self) -> Result>> { + Ok(self.devices.clone()) + } + + fn platforms(&self) -> Result>> { + [ + "arm64_32", + "aarch64", + "x86_64-sim", + "aarch64-sim", + ] + .iter() + .map(|arch| { + let id = format!("auto-watchos-{}", arch); + + // Apple watch simulator targets are x86_64-apple-watchos-sim or + // aarch64-apple-watchos-sim + let rustc_triple = if *arch == "aarch64-sim" { + format!("aarch64-apple-watchos-sim") + } else if *arch == "x86_64-sim" { + format!("x86_64-apple-watchos-sim") + } else { + format!("{}-apple-watchos", arch) + }; + let simulator = if *arch == "x86_64-sim" || *arch == "aarch64-sim" { + Some(AppleSimulatorType::Watchos) + } else { + None + }; + + AppleDevicePlatform::new( + id, + &rustc_triple, + simulator, + crate::config::PlatformConfiguration::default(), + ) + .map(|pf| pf as Box) + }) + .collect() + } +} + +pub struct TvosManager { + devices: Vec>, +} + +impl TvosManager { + pub fn new() -> Result> { + let devices = simulators(AppleSimulatorType::Tvos)?; + Ok(Some(Self { devices })) + } +} + +impl PlatformManager for TvosManager { + fn devices(&self) -> Result>> { + Ok(self.devices.clone()) + } + + fn platforms(&self) -> Result>> { + [ + "aarch64", + "x86_64", + "aarch64-sim", + ] + .iter() + .map(|arch| { + let id = format!("auto-tvos-{}", arch); + let rustc_triple = if *arch != "aarch64-sim" { + format!("{}-apple-tvos", arch) + } else { + format!("aarch64-apple-tvos-sim") + }; + let simulator = if *arch == "x86_64" || *arch == "aarch64-sim" { + Some(AppleSimulatorType::Tvos) + } else { + None + }; + AppleDevicePlatform::new( id, &rustc_triple, + simulator, crate::config::PlatformConfiguration::default(), ) .map(|pf| pf as Box) @@ -77,9 +204,9 @@ impl PlatformManager for IosManager { } } -fn simulators() -> Result>> { +fn simulators(sim_type: AppleSimulatorType) -> Result>> { let sims_list = ::std::process::Command::new("xcrun") - .args(&["simctl", "list", "--json", "devices"]) + .args(&["simctl", "list", "--json", "devices", sim_type.to_string().as_str()]) .output()?; if !sims_list.status.success() { info!( @@ -94,7 +221,7 @@ fn simulators() -> Result>> { for (ref k, ref v) in sims_list["devices"].entries() { for ref sim in v.members() { if sim["state"] == "Booted" { - sims.push(Box::new(IosSimDevice { + sims.push(Box::new(AppleSimDevice { name: sim["name"] .as_str() .ok_or_else(|| anyhow!("unexpected simulator list format (missing name)"))? @@ -104,6 +231,7 @@ fn simulators() -> Result>> { .ok_or_else(|| anyhow!("unexpected simulator list format (missing udid)"))? .to_string(), os: k.split(" ").last().unwrap().to_string(), + sim_type: sim_type.clone(), })) } } diff --git a/dinghy-lib/src/ios/platform.rs b/dinghy-lib/src/apple/platform.rs similarity index 74% rename from dinghy-lib/src/ios/platform.rs rename to dinghy-lib/src/apple/platform.rs index 86dc178f..e2dfe852 100644 --- a/dinghy-lib/src/ios/platform.rs +++ b/dinghy-lib/src/apple/platform.rs @@ -11,28 +11,31 @@ use dinghy_build::build_env::set_env; use std::fmt::{Debug, Display, Formatter}; use std::process; -pub struct IosPlatform { +use super::AppleSimulatorType; + +pub struct AppleDevicePlatform { id: String, - pub sim: bool, + pub sim: Option, pub toolchain: Toolchain, pub configuration: PlatformConfiguration, } -impl Debug for IosPlatform { +impl Debug for AppleDevicePlatform { fn fmt(&self, fmt: &mut Formatter) -> ::std::fmt::Result { write!(fmt, "{}", self.id) } } -impl IosPlatform { +impl AppleDevicePlatform { pub fn new( id: String, rustc_triple: &str, + simulator: Option, configuration: PlatformConfiguration, ) -> Result> { - Ok(Box::new(IosPlatform { + Ok(Box::new(AppleDevicePlatform { id, - sim: rustc_triple.contains("86") || rustc_triple.contains("sim"), + sim: simulator, toolchain: Toolchain { rustc_triple: rustc_triple.to_string(), }, @@ -41,10 +44,17 @@ impl IosPlatform { } fn sysroot_path(&self) -> Result { - let sdk_name = if self.sim { - "iphonesimulator" - } else { - "iphoneos" + let sdk_name = match self.sim { + Some(AppleSimulatorType::Ios) => { + "iphonesimulator" + } + Some(AppleSimulatorType::Tvos) => { + "appletvsimulator" + } + Some(AppleSimulatorType::Watchos) => { + "watchsimulator" + } + None => "iphoneos" }; let xcrun = process::Command::new("xcrun") .args(&["--sdk", sdk_name, "--show-sdk-path"]) @@ -53,7 +63,7 @@ impl IosPlatform { } } -impl Platform for IosPlatform { +impl Platform for AppleDevicePlatform { fn setup_env(&self, project: &Project, setup_args: &SetupArgs) -> Result<()> { let sysroot = self.sysroot_path()?; Overlayer::overlay(&self.configuration, self, project, &self.sysroot_path()?)?; @@ -75,7 +85,7 @@ impl Platform for IosPlatform { } fn is_compatible_with(&self, device: &dyn Device) -> bool { - device.is_compatible_with_ios_platform(self) + device.is_compatible_with_simulator_platform(self) } fn is_host(&self) -> bool { @@ -98,10 +108,10 @@ impl Platform for IosPlatform { } } -impl Display for IosPlatform { +impl Display for AppleDevicePlatform { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::result::Result<(), ::std::fmt::Error> { - if self.sim { - write!(f, "XCode targetting Ios Simulator") + if self.sim.is_some() { + write!(f, "XCode targetting Apple device Simulator") } else { write!(f, "XCode targetting Ios Device") } diff --git a/dinghy-lib/src/ios/xcode.rs b/dinghy-lib/src/apple/xcode.rs similarity index 82% rename from dinghy-lib/src/ios/xcode.rs rename to dinghy-lib/src/apple/xcode.rs index 25c61204..7f0f2856 100644 --- a/dinghy-lib/src/ios/xcode.rs +++ b/dinghy-lib/src/apple/xcode.rs @@ -1,4 +1,4 @@ -use super::{SignatureSettings, SigningIdentity}; +use super::{AppleSimulatorType, SignatureSettings, SigningIdentity}; use crate::errors::*; use log::{debug, trace}; use std::io::Write; @@ -7,7 +7,12 @@ use std::{fs, io, process}; use crate::utils::LogCommandExt; use crate::BuildBundle; -pub fn add_plist_to_app(bundle: &BuildBundle, arch: &str, app_bundle_id: &str) -> Result<()> { +pub fn add_plist_to_app( + bundle: &BuildBundle, + arch: &str, + app_bundle_id: &str, + sim_type: Option<&AppleSimulatorType> +) -> Result<()> { let mut plist = fs::File::create(bundle.bundle_dir.join("Info.plist"))?; writeln!(plist, r#""#)?; writeln!( @@ -24,52 +29,29 @@ pub fn add_plist_to_app(bundle: &BuildBundle, arch: &str, app_bundle_id: &str) - "CFBundleIdentifier{}", app_bundle_id )?; - writeln!(plist, "UIRequiredDeviceCapabilities")?; - writeln!(plist, "{}", arch)?; writeln!(plist, "CFBundleVersion")?; writeln!(plist, "{}", arch)?; writeln!(plist, "CFBundleShortVersionString")?; writeln!(plist, "{}", arch)?; - writeln!(plist, "UILaunchStoryboardName")?; - writeln!(plist, "")?; - writeln!(plist, r#""#)?; - /* - let app_name = app_bundle_id.split(".").last().unwrap(); - let app_path = app_path.as_ref().join(format!("{}.app", app_name)); - println!("WRAP AS APP: {:?} -> {:?}", executable.as_ref(), app_path); - let _ = fs::remove_dir_all(&app_path); - fs::create_dir_all(&app_path)?; - fs::copy(&executable, app_path.join(app_name))?; - - - let mut plist = fs::File::create(app_path.join("Info.plist"))?; - writeln!(plist, r#""#)?; - writeln!(plist, r#""#)?; - writeln!(plist, r#""#)?; - writeln!( - plist, - "CFBundleExecutable{}", - app_name - )?; - writeln!( - plist, - "CFBundleIdentifier{}", - app_bundle_id - )?; - writeln!(plist, "UIRequiredDeviceCapabilities")?; - writeln!( - plist, - "{}", - target.split("-").next().unwrap() - )?; + match sim_type { + // The iOS/tvOS simulator have the same plist as an iOS device. + Some(AppleSimulatorType::Ios) | Some(AppleSimulatorType::Tvos) | None => { + writeln!(plist, "UIRequiredDeviceCapabilities")?; + writeln!(plist, "{}", arch)?; + writeln!(plist, "UILaunchStoryboardName")?; + writeln!(plist, "")?; + }, + Some(AppleSimulatorType::Watchos) => { + writeln!(plist, "MinimumOSVersion8.0",)?; + writeln!(plist, "WKApplication",)?; + writeln!(plist, "WKWatchOnly")?; + }, + } writeln!(plist, r#""#)?; - - project.rec_copy(&source, &app_path, false)?; - project.copy_test_data(&app_path)?; - */ Ok(()) } + pub fn sign_app(bundle: &BuildBundle, settings: &SignatureSettings) -> Result<()> { debug!( "Will sign {:?} with team: {} using key: {} and profile: {}", diff --git a/dinghy-lib/src/lib.rs b/dinghy-lib/src/lib.rs index ab7a4b34..7270bf98 100644 --- a/dinghy-lib/src/lib.rs +++ b/dinghy-lib/src/lib.rs @@ -11,7 +11,7 @@ pub mod config; pub mod device; mod host; #[cfg(target_os = "macos")] -mod ios; +mod apple; pub mod overlay; pub mod platform; pub mod project; @@ -24,7 +24,12 @@ pub use crate::config::Configuration; use crate::config::PlatformConfiguration; #[cfg(target_os = "macos")] -use crate::ios::IosManager; +use crate::apple::{ + IosManager, + TvosManager, + WatchosManager, +}; + use crate::platform::regular_platform::RegularPlatform; use crate::project::Project; use anyhow::{anyhow, Context}; @@ -60,6 +65,12 @@ impl Dinghy { if let Some(man) = IosManager::new().context("Could not initialize iOS manager")? { managers.push(Box::new(man)); } + if let Some(man) = TvosManager::new().context("Could not initialize tvOS manager")? { + managers.push(Box::new(man)); + } + if let Some(man) = WatchosManager::new().context("Could not initialize tvOS manager")? { + managers.push(Box::new(man)); + } } let mut devices = vec![]; @@ -167,7 +178,7 @@ pub trait DeviceCompatibility { } #[cfg(target_os = "macos")] - fn is_compatible_with_ios_platform(&self, _platform: &ios::IosPlatform) -> bool { + fn is_compatible_with_simulator_platform(&self, _platform: &apple::AppleDevicePlatform) -> bool { false } } diff --git a/dinghy-test/src/lib.rs b/dinghy-test/src/lib.rs index 2c63457d..1798e7c9 100644 --- a/dinghy-test/src/lib.rs +++ b/dinghy-test/src/lib.rs @@ -4,7 +4,13 @@ use std::io::prelude::*; use std::path::PathBuf; pub fn test_project_path() -> PathBuf { - if cfg!(any(target_os = "ios", target_os = "android")) || env::var("DINGHY").is_ok() { + if cfg!( + any( + target_os = "ios", + target_os = "watchos", + target_os = "tvos", + target_os = "android" + )) || env::var("DINGHY").is_ok() { let current_exe = env::current_exe().expect("Current exe path not accessible"); current_exe @@ -26,7 +32,13 @@ pub fn test_file_path(test_data_id: &str) -> PathBuf { pub fn try_test_file_path(test_data_id: &str) -> Option { let current_exe = env::current_exe().expect("Current exe path not accessible"); - if cfg!(any(target_os = "ios", target_os = "android")) || env::var("DINGHY").is_ok() { + if cfg!( + any( + target_os = "ios", + target_os = "watchos", + target_os = "tvos", + target_os = "android" + )) || env::var("DINGHY").is_ok() { current_exe .parent() .map(|it| it.join("test_data"))