From 8ad4de11eb252ddeca451e97eb3c9225270f83eb Mon Sep 17 00:00:00 2001 From: AIOSAI Date: Mon, 15 Jun 2026 20:45:25 -0700 Subject: [PATCH] test(api,daemon,skills): skipif(win32) for Linux-only tests (green CI Windows) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Once the collection-level blockers were fixed, the Windows runner finally ran the suite and surfaced 7 pre-existing failures — all tests asserting Linux-only behavior, while the production code already handles non-Linux gracefully: - api test_secrets: chmod(0o000) can't make a file unreadable to its owner on Windows (the 'unreadable -> None' precondition is unreachable) - daemon test_scheduler_cron: patches fcntl.flock; fcntl is None on Windows (scheduler_cron already skips locking on non-Unix) - skills test_runner: system_status memory/uptime/processes/summary read Linux /proc (skill returns a graceful error on Windows; disk test stays, it's portable) Guard each with @pytest.mark.skipif(sys.platform == 'win32', reason=...). 68 tests pass on Linux, ruff clean, api+daemon audit 100%. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/aipass/api/tests/test_secrets.py | 7 +++++++ .../daemon/tests/test_scheduler_cron.py | 9 +++++++++ src/aipass/skills/tests/test_runner.py | 20 +++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/src/aipass/api/tests/test_secrets.py b/src/aipass/api/tests/test_secrets.py index 6ab41db7..3c91b38b 100644 --- a/src/aipass/api/tests/test_secrets.py +++ b/src/aipass/api/tests/test_secrets.py @@ -33,9 +33,12 @@ Tests — api_key.py (get_secret_cmd): from __future__ import annotations import json +import sys from pathlib import Path from unittest.mock import patch, MagicMock +import pytest + from aipass.api.apps.modules.api_key import handle_command as _hc # noqa: F401 — seedgo test_coverage detection from aipass.api.apps.handlers.auth.secrets import ( get_secret, @@ -140,6 +143,10 @@ class TestGetSecret: assert result is None mock_logger.warning.assert_called() + @pytest.mark.skipif( + sys.platform == "win32", + reason="chmod(0o000) does not make a file unreadable to its owner on Windows", + ) def test_unreadable_file_returns_none(self, tmp_path: Path) -> None: """OSError when reading file returns None.""" provider_dir = tmp_path / "telegram" diff --git a/src/aipass/daemon/tests/test_scheduler_cron.py b/src/aipass/daemon/tests/test_scheduler_cron.py index 3e4f26d1..2ae13ef9 100644 --- a/src/aipass/daemon/tests/test_scheduler_cron.py +++ b/src/aipass/daemon/tests/test_scheduler_cron.py @@ -16,6 +16,7 @@ """Tests for scheduler_cron dispatch paths.""" import subprocess +import sys from datetime import datetime from unittest.mock import MagicMock, patch @@ -443,6 +444,10 @@ class TestMain: mock_help.assert_called_once() assert exc_info.value.code == 0 + @pytest.mark.skipif( + sys.platform == "win32", + reason="patches fcntl.flock; fcntl is Unix-only (None on Windows). Scheduler skips locking on non-Unix.", + ) def test_lock_acquisition_failure(self, tmp_path): from aipass.daemon.apps.scheduler_cron import main @@ -460,6 +465,10 @@ class TestMain: assert code == 0 # graceful skip when another instance is running mock_fd.close.assert_called() + @pytest.mark.skipif( + sys.platform == "win32", + reason="patches fcntl.flock; fcntl is Unix-only (None on Windows). Scheduler skips locking on non-Unix.", + ) def test_lock_acquired_runs_locked(self, tmp_path): from aipass.daemon.apps.scheduler_cron import main diff --git a/src/aipass/skills/tests/test_runner.py b/src/aipass/skills/tests/test_runner.py index 09db2cf6..876749e0 100644 --- a/src/aipass/skills/tests/test_runner.py +++ b/src/aipass/skills/tests/test_runner.py @@ -8,6 +8,10 @@ """Tests for the skills runner module.""" +import sys + +import pytest + from aipass.skills.apps.modules.runner import run_skill @@ -18,21 +22,37 @@ class TestRunSkillHandler: assert "Disk Usage" in result["output"] assert result["error"] is None + @pytest.mark.skipif( + sys.platform == "win32", + reason="system_status memory reads Linux /proc/meminfo; unavailable on Windows (skill returns graceful error)", + ) def test_run_system_status_memory(self): result = run_skill("system_status", action="memory") assert result["success"] is True assert "Memory" in result["output"] + @pytest.mark.skipif( + sys.platform == "win32", + reason="system_status uptime reads Linux /proc/uptime; unavailable on Windows (skill returns graceful error)", + ) def test_run_system_status_uptime(self): result = run_skill("system_status", action="uptime") assert result["success"] is True assert "Uptime" in result["output"] + @pytest.mark.skipif( + sys.platform == "win32", + reason="system_status processes reads Linux /proc; unavailable on Windows (skill returns graceful error)", + ) def test_run_system_status_processes(self): result = run_skill("system_status", action="processes") assert result["success"] is True assert "processes" in result["output"].lower() + @pytest.mark.skipif( + sys.platform == "win32", + reason="system_status summary needs Linux /proc memory data; unavailable on Windows", + ) def test_run_system_status_summary(self): result = run_skill("system_status", action="summary") assert result["success"] is True