From be2fb0cfd215154cd8869859d24b2daafdad3220 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Mon, 9 Dec 2024 18:04:24 +0700 Subject: [PATCH] sprinkle macos cfg compilations limits --- tests/osakit.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/osakit.rs b/tests/osakit.rs index 680d8bf..ba9920a 100644 --- a/tests/osakit.rs +++ b/tests/osakit.rs @@ -1,20 +1,29 @@ // Separate file to force running the tests on the main thread, required for any macOS OSAkit APIs, which otherwise fail after a 2-min stall // Uses cargo-nextest and a custom libtest_mimic test harness for that since the default Cargo test doesn't. // ADD "test_main_thread_" prefix to test names so that the main cargo test run filter them out with `--skip "test_main_thread_"` +#[cfg(target_os = "macos")] #[path = "../src/tests.rs"] mod trash_tests; +#[cfg(target_os = "macos")] use serial_test::serial; +#[cfg(target_os = "macos")] +use std::{fs::File, path::PathBuf}; +#[cfg(target_os = "macos")] use trash::{ macos::{DeleteMethod, ScriptMethod, TrashContextExtMacos}, TrashContext, }; +#[cfg(target_os = "macos")] use trash_tests::{get_unique_name, init_logging}; // not pub, so import directly -use std::fs::File; -use std::path::PathBuf; -use libtest_mimic::{Arguments, Trial}; #[ignore] fn main() { + #[cfg(target_os = "macos")] + main_mac() +} +#[cfg(target_os = "macos")] +fn main_mac() { + use libtest_mimic::{Arguments, Trial}; let args = Arguments::from_args(); // Parse command line arguments let tests = vec![ // Create a list of tests and/or benchmarks @@ -25,7 +34,9 @@ fn main() { libtest_mimic::run(&args, tests).exit(); // Run all tests and exit the application appropriatly } +#[cfg(target_os = "macos")] use std::thread; +#[cfg(target_os = "macos")] #[serial] pub fn test_main_thread_delete_with_finder_osakit_with_info() { // OSAkit must be run on the main thread