Exclude unsupported keepawake backend from FreeBSD CI builds

This commit is contained in:
Dandaedre 2026-11-20 06:43:09 +01:00
parent 251110a7a4
commit 4f5665f8e2
7 changed files with 36 additions and 3 deletions

2
Cargo.lock generated
View File

@ -2212,7 +2212,7 @@ dependencies = [
[[package]]
name = "pdf-presenter"
version = "0.1.33"
version = "0.1.34"
dependencies = [
"bytemuck",
"chrono",

View File

@ -4,7 +4,7 @@ default-members = ["crates/pdf-presenter"]
resolver = "3"
[workspace.package]
version = "0.1.33"
version = "0.1.34"
edition = "2024"
license = "MIT"
repository = "https://proxy.dandaedre.com/gitea/idle-org/pdf-presenter"

View File

@ -25,9 +25,11 @@ sha2 = "0.10"
image = { version = "=0.25.10", default-features = false, features = ["png", "jpeg", "webp", "gif", "bmp", "tiff"] }
hayro = "=0.9.0"
chrono = "0.4"
keepawake = "=0.6.1"
rfd = "=0.15.4"
[target.'cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))'.dependencies]
keepawake = "=0.6.1"
[target.'cfg(unix)'.dependencies]
libc = "0.2"

View File

@ -239,6 +239,7 @@ impl Drop for SleepLease {
}
}
pub fn keep_awake() -> Result<(), String> {
#[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))]
let guard = keepawake::Builder::default()
.display(true)
.idle(true)
@ -246,6 +247,11 @@ pub fn keep_awake() -> Result<(), String> {
.app_name("PDF Presenter")
.app_reverse_domain("com.beffroi.pdfpresenter")
.create();
#[cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))]
let guard: Result<(), String> = Err(format!(
"No native sleep-inhibition backend for {}",
std::env::consts::OS
));
#[cfg(target_os = "linux")]
let x11 = X11Lease::new();
let status = match &guard {

View File

@ -7,6 +7,7 @@ use std::{
fn run_native(args: &[&str]) -> Output {
let mut child = Command::new(env!("CARGO_BIN_EXE_pdf-presenter"))
.args(args)
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
@ -562,3 +563,13 @@ fn wayland_browser_parents_to_presenter_before_first_buffer() {
"Only the browser is parented"
);
}
#[test]
#[cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))]
fn unsupported_sleep_backend_reports_unavailable_and_exits_on_parent_eof() {
let output = run_native(&["--keep-awake"]);
assert!(output.status.success());
let status: String = serde_json::from_slice(&output.stdout).unwrap();
assert!(status.starts_with("Sleep protection unavailable:"));
assert!(status.contains(std::env::consts::OS));
}

View File

@ -2,6 +2,15 @@
## Unreleased
### 0.1.34
- Restrict keepawake to its supported Linux, Windows and macOS targets so the
FreeBSD CI worker can compile. Other platforms explicitly report sleep protection
as unavailable while retaining the helper status/parent-pipe lifecycle.
- FreeBSD cross-target Clippy passes for all targets/features; native FreeBSD
execution awaits Jenkins. Linux checks/native tests and 13 Python tests pass;
whole-application line coverage is 86.40%.
### 0.1.33
- Prepare local Linux/Windows x86_64 preview artifacts with rust_realease; verify

View File

@ -57,3 +57,8 @@ the ordinary tests remain headless and explicitly skip native-window smoke. CI u
neither the flag nor the virtual-display wrapper. Xvfb tests cannot
validate actual monitor routing, compositor policy, macOS Spaces or Windows desktop
behavior. The wrapper starts no network listener and alters no physical display.
The FreeBSD worker compiles without `keepawake`, whose native backends only support
Linux, Windows and macOS. The helper reports sleep protection as unavailable on
FreeBSD and waits for its parent pipe to close as usual. This does not establish
FreeBSD sleep-inhibition support; supported desktop platforms retain their backends.