Fix macOS gate: docs, Linux-only test helpers, NSGraphicsContext feature for AppKit event tests

This commit is contained in:
aiongg
2026-11-17 19:34:21 +00:00
parent 17aef21bc6
commit 12dfe2c497
6 changed files with 16 additions and 4 deletions
+8 -1
View File
@@ -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<Self> {
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<u32> {
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")
+1 -1
View File
@@ -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]
+1 -1
View File
@@ -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
};
+1
View File
@@ -14,6 +14,7 @@ pub fn candidates(app: &App) -> Vec<PathBuf> {
out
}
/// Finds the installed bundle of `app` among the standard Applications folders.
pub fn detect(app: &App) -> Option<Installed> {
candidates(app).iter().find_map(|p| read_bundle(app, p))
}
+4
View File
@@ -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,
+1 -1
View File
@@ -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()));