diff --git a/crates/atomic/tests/permissions.rs b/crates/atomic/tests/permissions.rs index bd8e63a5b..95702cfe7 100644 --- a/crates/atomic/tests/permissions.rs +++ b/crates/atomic/tests/permissions.rs @@ -6,11 +6,16 @@ use craft_atomic::{NewFilePermissions, WriteOptions, atomic_write, write_new}; use std::fs::{self, File, Permissions}; use std::io::{self, Write}; use std::os::unix::fs::PermissionsExt; -use std::path::{Path, PathBuf}; +use std::path::Path; +#[cfg(target_os = "linux")] +use std::path::PathBuf; use std::process::Command; +#[cfg(target_os = "linux")] use std::sync::atomic::{AtomicU64, Ordering}; +#[cfg(target_os = "linux")] struct TempDir(PathBuf); +#[cfg(target_os = "linux")] impl TempDir { fn new() -> io::Result { static N: AtomicU64 = AtomicU64::new(0); @@ -19,6 +24,7 @@ impl TempDir { Ok(Self(path)) } } +#[cfg(target_os = "linux")] impl Drop for TempDir { fn drop(&mut self) { let _ = fs::remove_dir_all(&self.0); @@ -29,6 +35,7 @@ fn mode(path: &Path) -> io::Result { Ok(fs::metadata(path)?.permissions().mode() & 0o777) } +#[cfg(target_os = "linux")] /// Set umask only in a separate shell process; changing it in a parallel test process races. fn child(dir: &Path, mask: &str, expected: &str, check_acl: bool) -> io::Result<()> { let output = Command::new("sh") diff --git a/crates/menu/Cargo.toml b/crates/menu/Cargo.toml index b597b9488..df82fa938 100644 --- a/crates/menu/Cargo.toml +++ b/crates/menu/Cargo.toml @@ -47,7 +47,7 @@ required-features = ["screen-testing"] # The test reads AppKit's menu bar back and feeds it real events, through safe objc2 calls. [target.'cfg(target_os = "macos")'.dev-dependencies] objc2 = { version = "0.6.4", default-features = false, features = ["std"] } -objc2-app-kit = { version = "0.3.2", default-features = false, features = ["std", "NSApplication", "NSControl", "NSEvent", "NSMenu", "NSMenuItem", "NSResponder"] } +objc2-app-kit = { version = "0.3.2", default-features = false, features = ["std", "NSApplication", "NSControl", "NSEvent", "NSGraphicsContext", "NSMenu", "NSMenuItem", "NSResponder"] } objc2-foundation = { version = "0.3.2", default-features = false, features = ["std", "NSDate", "NSGeometry", "NSRunLoop", "NSString"] } [lints] diff --git a/crates/menu/tests/mac_appkit.rs b/crates/menu/tests/mac_appkit.rs index 0fe512b42..d5ab84d8a 100644 --- a/crates/menu/tests/mac_appkit.rs +++ b/crates/menu/tests/mac_appkit.rs @@ -103,7 +103,7 @@ fn main() { .push(Node::Item(Item::new("layer.mergeVisible", "Merge Visible").alternate(Alternate::new(Mods::ALT, "layer.stampVisible")))); } for n in 1..documents { - bar.documents.push(Document::new(format!("doc.{n}"), format!("Untitled-{}", n + 1))); + bar.documents.push(Document::new(&format!("doc.{n}"), format!("Untitled-{}", n + 1))); } bar }; diff --git a/crates/update/src/detect/macos.rs b/crates/update/src/detect/macos.rs index 6c0da641f..025666209 100644 --- a/crates/update/src/detect/macos.rs +++ b/crates/update/src/detect/macos.rs @@ -14,6 +14,7 @@ pub fn candidates(app: &App) -> Vec { out } +/// Finds the installed bundle of `app` among the standard Applications folders. pub fn detect(app: &App) -> Option { candidates(app).iter().find_map(|p| read_bundle(app, p)) } diff --git a/crates/update/src/install/macos.rs b/crates/update/src/install/macos.rs index 0ad1958f9..745391b3c 100644 --- a/crates/update/src/install/macos.rs +++ b/crates/update/src/install/macos.rs @@ -50,6 +50,7 @@ pub struct Expect<'a> { } impl<'a> Expect<'a> { + /// What the app inside `release`'s download must prove: the team's signature, the version, and a quit app. pub fn release(release: &'a Release) -> Self { Self { team: Some(TEAM_ID), version: release.version.as_ref(), quit_first: true } } @@ -103,7 +104,9 @@ static SIGNATURE_CHECKS: Queue = Queue::new(); /// How a job waits for its turn at the signature check: `phase` hears of the wait, and `stop` /// can cancel it. pub struct CheckTurn<'a> { + /// Cancels the wait. pub stop: &'a Stop, + /// Told of the wait. pub phase: &'a mut dyn FnMut(JobPhase), } @@ -116,6 +119,7 @@ const CODESIGN: &str = "/usr/bin/codesign"; /// Stops a `codesign` that hangs. const CODESIGN_TIMEOUT: Duration = Duration::from_secs(600); +/// Installs the app in `dmg`, replacing `existing` or placing it at `destination`; checks it against `expect` first. #[allow(clippy::too_many_arguments)] pub fn install_dmg( app: &App, diff --git a/crates/update/src/install/tests.rs b/crates/update/src/install/tests.rs index ac6a436c8..528cca611 100644 --- a/crates/update/src/install/tests.rs +++ b/crates/update/src/install/tests.rs @@ -120,7 +120,7 @@ fn a_release_without_a_checksum_is_refused_before_anything_is_fetched() { assert!(!phases.contains(&JobPhase::Installing)); } -#[cfg(unix)] +#[cfg(target_os = "linux")] fn tarball(path: &Path, entries: &[&str]) { let f = std::fs::File::create(path).unwrap(); let mut b = tar::Builder::new(flate2::write::GzEncoder::new(f, flate2::Compression::fast()));