Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/neomacs-display-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ parking_lot = { workspace = true, optional = true }
portable-pty = { workspace = true, optional = true }

[dev-dependencies]
neomacs-infra.workspace = true
tempfile.workspace = true

[features]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::MacOsBundleRuntime;
use std::fs;

fn workspace_tempdir() -> tempfile::TempDir {
let workspace_tmp = std::path::Path::new(env!("CARGO_WORKSPACE_DIR")).join("tmp");
let workspace_tmp = neomacs_infra::workspace_root().as_path().join("tmp");
fs::create_dir_all(&workspace_tmp).expect("workspace tmp directory");
tempfile::Builder::new()
.prefix("macos-bundle-runtime.")
Expand Down
2 changes: 1 addition & 1 deletion crates/neomacs-gui-tests/tests/desktop_font_startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ fn check_fixture_with_font(
desktop: WestonDesktop,
font: Option<&str>,
) -> GuiRunResult {
let root = PathBuf::from(env!("CARGO_WORKSPACE_DIR"));
let root = neomacs_infra::workspace_root();
let artifacts = root.join("target/neomacs-gui-tests").join(scenario);
let receipt = artifacts.join("presentation.sexp");
match fs::remove_file(&receipt) {
Expand Down
8 changes: 4 additions & 4 deletions crates/neomacs-gui-tests/tests/harness_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ fn svg_package_defaults_are_checkout_relative_and_preserve_explicit_overrides()
#[cfg(target_os = "linux")]
#[test]
fn wayland_session_owns_runtime_below_long_artifact_root() {
let root = PathBuf::from(env!("CARGO_WORKSPACE_DIR"))
let root = neomacs_infra::workspace_root()
.join("target/neomacs-gui-tests")
.join(format!(
"long-wayland-{}-{}",
Expand Down Expand Up @@ -271,7 +271,7 @@ fn wayland_session_owns_runtime_below_long_artifact_root() {
#[cfg(target_os = "linux")]
#[test]
fn x11_session_owns_authenticated_tcp_display_below_artifact_root() {
let workspace = PathBuf::from(env!("CARGO_WORKSPACE_DIR"));
let workspace = neomacs_infra::workspace_root();
let root = workspace.join(format!(
"target/neomacs-gui-tests/xvfb-contract-{}",
std::process::id()
Expand Down Expand Up @@ -439,7 +439,7 @@ fn test_plan_can_drive_an_init_directory_startup_surface() {

#[test]
fn test_plan_materializes_json_manifest_artifact() {
let workspace_root = PathBuf::from(env!("CARGO_WORKSPACE_DIR"));
let workspace_root = neomacs_infra::workspace_root();
let artifact_root = workspace_root.join("target/neomacs-gui-tests");
let artifacts = GuiArtifactSet::new(&artifact_root, GuiBackend::LinuxWayland, "startup-smoke");
let _ = std::fs::remove_file(&artifacts.json);
Expand Down Expand Up @@ -693,7 +693,7 @@ fn run_with_runner_records_frame_snapshot_artifacts() {
}

fn workspace_root() -> PathBuf {
PathBuf::from(env!("CARGO_WORKSPACE_DIR"))
neomacs_infra::workspace_root()
}

struct FakeRunner {
Expand Down
2 changes: 1 addition & 1 deletion crates/neomacs-gui-tests/tests/native_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn native_resource_font_drives_first_window() {
}

fn run_native_contract(name: &str, fixture: &str, resources: bool) -> GuiRunResult {
let root = PathBuf::from(env!("CARGO_WORKSPACE_DIR"));
let root = neomacs_infra::workspace_root();
let backend = if cfg!(target_os = "macos") {
GuiBackend::Macos
} else if cfg!(windows) {
Expand Down
2 changes: 1 addition & 1 deletion crates/neomacs-gui-tests/tests/native_frame_focus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn native_x11_focus_routes_typing_to_the_focused_frame() {
}
Some(other) => panic!("unsupported NEOMACS_GUI_TEST_BACKEND={other:?}"),
}
let root = PathBuf::from(env!("CARGO_WORKSPACE_DIR"));
let root = neomacs_infra::workspace_root();
let artifacts = root.join(format!(
"target/neomacs-gui-tests/native-frame-focus-{}",
std::process::id()
Expand Down
2 changes: 1 addition & 1 deletion crates/neomacs-gui-tests/tests/native_menus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct Ready {

#[test]
fn native_submenu_hover_keeps_editor_and_compositor_alive() {
let root = PathBuf::from(env!("CARGO_WORKSPACE_DIR"));
let root = neomacs_infra::workspace_root();
let artifacts = root.join(format!(
"target/neomacs-gui-tests/native-submenu-{}-{}",
std::process::id(),
Expand Down
2 changes: 1 addition & 1 deletion crates/neomacs-gui-tests/tests/native_scrolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ enum ScrollTarget {
}

fn run_native_scroll(kind: ScrollKind, target: ScrollTarget) {
let root = PathBuf::from(env!("CARGO_WORKSPACE_DIR"));
let root = neomacs_infra::workspace_root();
let artifact_root = root.join("target/neomacs-gui-tests");
fs::create_dir_all(&artifact_root).unwrap();
let artifacts = artifact_root.join(format!(
Expand Down
2 changes: 1 addition & 1 deletion crates/neomacs-gui-tests/tests/present_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl ContractApp {
#[test]
fn resize_then_present_shows_the_new_frame_on_the_current_backend() {
let backend_label = std::env::var("WGPU_BACKEND").unwrap_or_else(|_| "default".to_owned());
let artifact_root = PathBuf::from(env!("CARGO_WORKSPACE_DIR")).join("target/neomacs-gui-tests");
let artifact_root = neomacs_infra::workspace_root().join("target/neomacs-gui-tests");
std::fs::create_dir_all(&artifact_root).unwrap();
let artifacts = artifact_root.join(format!("present-contract-{backend_label}"));
std::fs::create_dir_all(&artifacts).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/neomacs-gui-tests/tests/real_gui_smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ fn requested_backend() -> Option<GuiBackend> {
}

fn workspace_root() -> PathBuf {
PathBuf::from(env!("CARGO_WORKSPACE_DIR"))
neomacs_infra::workspace_root()
}

fn neomacs_binary(workspace_root: &std::path::Path) -> PathBuf {
Expand Down
2 changes: 1 addition & 1 deletion crates/neomacs-gui-tests/tests/resize_presentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ fn x11_backend_requested() -> bool {
}

fn workspace_root() -> PathBuf {
PathBuf::from(env!("CARGO_WORKSPACE_DIR"))
neomacs_infra::workspace_root()
}

fn neomacs_binary(workspace_root: &Path) -> PathBuf {
Expand Down
6 changes: 3 additions & 3 deletions crates/neomacs-gui-tests/tests/startup_failure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn check_pending_gpu(action: GpuStartupAction) {
time::Instant,
};

let root = PathBuf::from(env!("CARGO_WORKSPACE_DIR"));
let root = neomacs_infra::workspace_root();
let artifacts = root.join("target/neomacs-gui-tests").join(format!(
"startup-pending-gpu-{}-{}",
action.as_ref(),
Expand Down Expand Up @@ -298,7 +298,7 @@ enum PendingFontAction {
fn run_with_pending_font(action: PendingFontAction) -> neomacs_gui_tests::GuiRunResult {
use std::{io::Write, os::unix::fs::OpenOptionsExt, process::Command, time::Instant};

let root = PathBuf::from(env!("CARGO_WORKSPACE_DIR"));
let root = neomacs_infra::workspace_root();
let artifacts = root.join("target/neomacs-gui-tests");
fs::create_dir_all(&artifacts).unwrap();
let scenario = match action {
Expand Down Expand Up @@ -410,7 +410,7 @@ fn successful_exit_during_lisp_startup_remains_successful() {
}

fn check_lisp_startup_exit_status(status: i32) {
let root = PathBuf::from(env!("CARGO_WORKSPACE_DIR"));
let root = neomacs_infra::workspace_root();
let artifacts = root.join("target/neomacs-gui-tests");
let backend = GuiBackend::LinuxWayland;
let session = DisplayHarness::for_backend(backend)
Expand Down
27 changes: 27 additions & 0 deletions crates/neomacs-infra/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,34 @@
pub mod display;

use std::fs;
use std::os::unix::fs::PermissionsExt;

Check failure on line 14 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / MELPA direct adapter Job Object contracts (windows x86_64)

cannot find `unix` in `os`

Check failure on line 14 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-aarch64)

cannot find `unix` in `os`

Check failure on line 14 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / native terminal output (windows-msvc-x86_64)

cannot find `unix` in `os`

Check failure on line 14 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-x86_64)

cannot find `unix` in `os`
/// The workspace root baked in at compile time.
///
/// This is the **build** machine's path — for binaries shipped through
/// `cargo nextest archive`, wrong on every other runner. Only
/// [`workspace_root`] should read it; call sites never choose it directly.
pub fn cargo_workspace_root() -> PathBuf {
PathBuf::from(env!("CARGO_WORKSPACE_DIR"))
}

/// The workspace root nextest exports at runtime: the live workspace on
/// the machine *running* the test, already adjusted by
/// `--workspace-remap`. `None` outside nextest (`cargo test`, plain
/// `cargo run`).
pub fn nextest_workspace_root() -> Option<PathBuf> {
std::env::var_os("NEXTEST_WORKSPACE_ROOT").map(PathBuf::from)
}

/// The workspace root of the machine *running* the test: nextest's
/// runtime value when present, the compile-time constant otherwise.
///
/// One archive job landing on a runner pool with a different home
/// (`/home/ubuntu` vs `/home/runner`) turned every downstream artifact
/// write into EACCES and wiped out a whole CI run — which is why this
/// fallback order lives here, once, instead of at each call site.
pub fn workspace_root() -> PathBuf {
nextest_workspace_root().unwrap_or_else(cargo_workspace_root)
}
use std::path::{Path, PathBuf};
use std::process::Command;

Expand Down Expand Up @@ -106,7 +133,7 @@
let root = Self::cache_root().join(format!("doom-{}", &revision[..12.min(revision.len())]));
let tree = root.join("tree");
let sealed = fs::metadata(&root)
.map(|meta| meta.permissions().mode() & 0o222 == 0)

Check failure on line 136 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / MELPA direct adapter Job Object contracts (windows x86_64)

no method named `mode` found for struct `Permissions` in the current scope

Check failure on line 136 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-aarch64)

no method named `mode` found for struct `Permissions` in the current scope

Check failure on line 136 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / native terminal output (windows-msvc-x86_64)

no method named `mode` found for struct `Permissions` in the current scope

Check failure on line 136 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-x86_64)

no method named `mode` found for struct `Permissions` in the current scope
.unwrap_or(false);
(root.join("MANIFEST").is_file() && tree.is_dir() && sealed).then_some(Self { root })
}
Expand Down Expand Up @@ -283,7 +310,7 @@
let straight = self.tree().join(".local").join("straight");
let link = local.join("straight");
if straight.is_dir() && !link.exists() {
std::os::unix::fs::symlink(&straight, &link).map_err(|error| {

Check failure on line 313 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / MELPA direct adapter Job Object contracts (windows x86_64)

cannot find `unix` in `os`

Check failure on line 313 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-aarch64)

cannot find `unix` in `os`

Check failure on line 313 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / native terminal output (windows-msvc-x86_64)

cannot find `unix` in `os`

Check failure on line 313 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-x86_64)

cannot find `unix` in `os`
format!(
"symlink {} -> {}: {error}",
link.display(),
Expand Down Expand Up @@ -321,7 +348,7 @@

fn open_at(root: &Path) -> Option<Self> {
let sealed = fs::metadata(root)
.map(|meta| meta.permissions().mode() & 0o222 == 0)

Check failure on line 351 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / MELPA direct adapter Job Object contracts (windows x86_64)

no method named `mode` found for struct `Permissions` in the current scope

Check failure on line 351 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-aarch64)

no method named `mode` found for struct `Permissions` in the current scope

Check failure on line 351 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / native terminal output (windows-msvc-x86_64)

no method named `mode` found for struct `Permissions` in the current scope

Check failure on line 351 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-x86_64)

no method named `mode` found for struct `Permissions` in the current scope
.unwrap_or(false);
(root.join("MANIFEST").is_file() && root.join("tree").is_dir() && sealed).then(|| Self {
root: root.to_owned(),
Expand All @@ -339,7 +366,7 @@
// the link itself rather than copying through it.
let target = fs::read_link(source)
.map_err(|error| format!("readlink {}: {error}", source.display()))?;
std::os::unix::fs::symlink(&target, destination).map_err(|error| {

Check failure on line 369 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / MELPA direct adapter Job Object contracts (windows x86_64)

cannot find `unix` in `os`

Check failure on line 369 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-aarch64)

cannot find `unix` in `os`

Check failure on line 369 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / native terminal output (windows-msvc-x86_64)

cannot find `unix` in `os`

Check failure on line 369 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-x86_64)

cannot find `unix` in `os`
format!(
"symlink {} -> {}: {error}",
destination.display(),
Expand Down Expand Up @@ -380,7 +407,7 @@
.map_err(|error| format!("stat {}: {error}", path.display()))?;
if meta.is_dir() {
let mut permissions = meta.permissions();
permissions.set_mode(meta.permissions().mode() & !0o222);

Check failure on line 410 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / MELPA direct adapter Job Object contracts (windows x86_64)

no method named `mode` found for struct `Permissions` in the current scope

Check failure on line 410 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / MELPA direct adapter Job Object contracts (windows x86_64)

no method named `set_mode` found for struct `Permissions` in the current scope

Check failure on line 410 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-aarch64)

no method named `mode` found for struct `Permissions` in the current scope

Check failure on line 410 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-aarch64)

no method named `set_mode` found for struct `Permissions` in the current scope

Check failure on line 410 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / native terminal output (windows-msvc-x86_64)

no method named `mode` found for struct `Permissions` in the current scope

Check failure on line 410 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / native terminal output (windows-msvc-x86_64)

no method named `set_mode` found for struct `Permissions` in the current scope

Check failure on line 410 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-x86_64)

no method named `mode` found for struct `Permissions` in the current scope

Check failure on line 410 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-x86_64)

no method named `set_mode` found for struct `Permissions` in the current scope
fs::set_permissions(path, permissions)
.map_err(|error| format!("seal {}: {error}", path.display()))?;
let entries =
Expand All @@ -394,7 +421,7 @@
}
} else if meta.is_file() {
let mut permissions = meta.permissions();
permissions.set_mode(meta.permissions().mode() & !0o222);

Check failure on line 424 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / MELPA direct adapter Job Object contracts (windows x86_64)

no method named `mode` found for struct `Permissions` in the current scope

Check failure on line 424 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / MELPA direct adapter Job Object contracts (windows x86_64)

no method named `set_mode` found for struct `Permissions` in the current scope

Check failure on line 424 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-aarch64)

no method named `mode` found for struct `Permissions` in the current scope

Check failure on line 424 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-aarch64)

no method named `set_mode` found for struct `Permissions` in the current scope

Check failure on line 424 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / native terminal output (windows-msvc-x86_64)

no method named `mode` found for struct `Permissions` in the current scope

Check failure on line 424 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / native terminal output (windows-msvc-x86_64)

no method named `set_mode` found for struct `Permissions` in the current scope

Check failure on line 424 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-x86_64)

no method named `mode` found for struct `Permissions` in the current scope

Check failure on line 424 in crates/neomacs-infra/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (windows-msvc-x86_64)

no method named `set_mode` found for struct `Permissions` in the current scope
fs::set_permissions(path, permissions)
.map_err(|error| format!("seal {}: {error}", path.display()))?;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/neomacs-melpa-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn workspace_root() -> PathBuf {
if let Some(root) = std::env::var_os("NEXTEST_WORKSPACE_ROOT") {
return PathBuf::from(root);
}
Path::new(env!("CARGO_WORKSPACE_DIR")).to_path_buf()
PathBuf::from(env!("CARGO_WORKSPACE_DIR"))
}

/// Per-scenario filesystem and subprocess isolation.
Expand Down
1 change: 1 addition & 0 deletions crates/neomacs-melpa-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ libc.workspace = true
windows-sys = { workspace = true, features = ["Win32_System_Diagnostics_ToolHelp", "Win32_System_JobObjects"] }

[dev-dependencies]
neomacs-infra.workspace = true
expect-test.workspace = true
neomacs-melpa-test-support = { workspace = true, features = ["tui"] }

Expand Down
2 changes: 1 addition & 1 deletion crates/neomacs-melpa-tests/src/parity_tests/tide/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6697,7 +6697,7 @@ fn assert_typed_contracts() {
2,
);

let workspace = PathBuf::from(env!("CARGO_WORKSPACE_DIR"));
let workspace = neomacs_melpa_test_support::workspace_root();
assert!(OwnedAbsoluteRoot::new("relative", workspace.join("tmp/owned")).is_err());
assert!(OwnedAbsoluteRoot::new(&workspace, "/tmp/ambient").is_err());
assert!(OwnedAbsoluteRoot::new(&workspace, workspace.join("tmp")).is_err());
Expand Down
2 changes: 1 addition & 1 deletion crates/neomacs-perf/src/build_provenance_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::fs;
use std::path::PathBuf;

Check warning on line 2 in crates/neomacs-perf/src/build_provenance_test.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (linux-aarch64)

unused import: `std::path::PathBuf`

Check warning on line 2 in crates/neomacs-perf/src/build_provenance_test.rs

View workflow job for this annotation

GitHub Actions / cargo check workspace (linux-x86_64)

unused import: `std::path::PathBuf`

Check warning on line 2 in crates/neomacs-perf/src/build_provenance_test.rs

View workflow job for this annotation

GitHub Actions / workspace test archive (linux x86_64)

unused import: `std::path::PathBuf`
use std::process::Command;

#[allow(dead_code)]
Expand All @@ -18,7 +18,7 @@

#[test]
fn git_metadata_watch_paths_are_absolute_and_worktree_aware() {
let workspace_tmp = PathBuf::from(env!("CARGO_WORKSPACE_DIR")).join("tmp");
let workspace_tmp = crate::workspace_root().join("tmp");
fs::create_dir_all(&workspace_tmp).expect("create workspace-local test scratch root");
let scratch = tempfile::Builder::new()
.prefix("neomacs-perf-build-provenance-")
Expand Down
Loading
Loading