build: Modified integration tests so they don't run when cross-compiling to non-x86 systems
Check / stable / fmt (push) Successful in 9m54s
Check / beta / clippy (push) Failing after 39s
Check / stable / clippy (push) Failing after 40s
Check / nightly / doc (push) Failing after 37s
Check / 1.89.0 / check (push) Failing after 38s
Test Suite / ubuntu / beta (push) Failing after 38s
Test Suite / ubuntu / stable (push) Failing after 39s
Test Suite / ubuntu / stable / coverage (push) Failing after 1m3s
Test Suite / macos-latest / stable (push) Has been cancelled
Test Suite / windows-latest / stable (push) Has been cancelled

This commit is contained in:
2026-02-01 18:03:51 -07:00
parent 2615b23d6e
commit f9fd9692aa
+40
View File
@@ -1,3 +1,8 @@
//! CLI integration tests that execute the gman binary.
//!
//! These tests are skipped when cross-compiling because the compiled binary
//! cannot be executed on a different architecture (e.g., ARM64 binary on x86_64 host).
use assert_cmd::prelude::*; use assert_cmd::prelude::*;
use predicates::prelude::*; use predicates::prelude::*;
use std::fs; use std::fs;
@@ -11,6 +16,16 @@ fn gman_bin() -> PathBuf {
PathBuf::from(env!("CARGO_BIN_EXE_gman")) PathBuf::from(env!("CARGO_BIN_EXE_gman"))
} }
/// Check if the gman binary can be executed on this system.
/// Returns false when cross-compiling (e.g., ARM64 binary on x86_64 host).
fn can_execute_binary() -> bool {
Command::new(gman_bin())
.arg("--version")
.output()
.map(|o| o.status.success())
.unwrap_or(false)
}
fn setup_env() -> (TempDir, PathBuf, PathBuf) { fn setup_env() -> (TempDir, PathBuf, PathBuf) {
let td = tempfile::tempdir().expect("tempdir"); let td = tempfile::tempdir().expect("tempdir");
let cfg_home = td.path().join("config"); let cfg_home = td.path().join("config");
@@ -65,6 +80,11 @@ fn create_password_file(path: &Path, content: &[u8]) {
#[test] #[test]
#[cfg(unix)] #[cfg(unix)]
fn cli_config_no_changes() { fn cli_config_no_changes() {
if !can_execute_binary() {
eprintln!("Skipping test: cannot execute cross-compiled binary");
return;
}
let (td, xdg_cfg, xdg_cache) = setup_env(); let (td, xdg_cfg, xdg_cache) = setup_env();
let pw_file = td.path().join("pw.txt"); let pw_file = td.path().join("pw.txt");
create_password_file(&pw_file, b"pw\n"); create_password_file(&pw_file, b"pw\n");
@@ -90,6 +110,11 @@ fn cli_config_no_changes() {
#[test] #[test]
#[cfg(unix)] #[cfg(unix)]
fn cli_config_updates_and_persists() { fn cli_config_updates_and_persists() {
if !can_execute_binary() {
eprintln!("Skipping test: cannot execute cross-compiled binary");
return;
}
let (td, xdg_cfg, xdg_cache) = setup_env(); let (td, xdg_cfg, xdg_cache) = setup_env();
let pw_file = td.path().join("pw.txt"); let pw_file = td.path().join("pw.txt");
create_password_file(&pw_file, b"pw\n"); create_password_file(&pw_file, b"pw\n");
@@ -132,6 +157,11 @@ exit 0
#[test] #[test]
fn cli_shows_help() { fn cli_shows_help() {
if !can_execute_binary() {
eprintln!("Skipping test: cannot execute cross-compiled binary");
return;
}
let (_td, cfg, cache) = setup_env(); let (_td, cfg, cache) = setup_env();
let mut cmd = Command::new(gman_bin()); let mut cmd = Command::new(gman_bin());
cmd.env("XDG_CACHE_HOME", &cache) cmd.env("XDG_CACHE_HOME", &cache)
@@ -144,6 +174,11 @@ fn cli_shows_help() {
#[test] #[test]
fn cli_add_get_list_update_delete_roundtrip() { fn cli_add_get_list_update_delete_roundtrip() {
if !can_execute_binary() {
eprintln!("Skipping test: cannot execute cross-compiled binary");
return;
}
let (td, xdg_cfg, xdg_cache) = setup_env(); let (td, xdg_cfg, xdg_cache) = setup_env();
let pw_file = td.path().join("pw.txt"); let pw_file = td.path().join("pw.txt");
create_password_file(&pw_file, b"testpw\n"); create_password_file(&pw_file, b"testpw\n");
@@ -230,6 +265,11 @@ fn cli_add_get_list_update_delete_roundtrip() {
#[test] #[test]
fn cli_wrap_dry_run_env_injection() { fn cli_wrap_dry_run_env_injection() {
if !can_execute_binary() {
eprintln!("Skipping test: cannot execute cross-compiled binary");
return;
}
let (td, xdg_cfg, xdg_cache) = setup_env(); let (td, xdg_cfg, xdg_cache) = setup_env();
let pw_file = td.path().join("pw.txt"); let pw_file = td.path().join("pw.txt");
create_password_file(&pw_file, b"pw\n"); create_password_file(&pw_file, b"pw\n");