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
15 changes: 5 additions & 10 deletions .github/workflows/multi-system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ jobs:
echo '=== Fedora Test ===' &&
fixos --version || true &&
fixos scan --help &&
pip install pytest pytest-mock --quiet &&
python -m pytest tests/unit/ -v --tb=short -x
python3 -m pytest tests/unit/ -v --tb=short -x
"

# ═══════════════════════════════════════════════════════════
Expand All @@ -59,8 +58,7 @@ jobs:
echo '=== Ubuntu Test ===' &&
fixos --version || true &&
fixos scan --help &&
pip install pytest pytest-mock --quiet &&
python -m pytest tests/unit/ -v --tb=short -x
python3 -m pytest tests/unit/ -v --tb=short -x
"

# ═══════════════════════════════════════════════════════════
Expand All @@ -84,8 +82,7 @@ jobs:
echo '=== Debian Test ===' &&
fixos --version || true &&
fixos scan --help &&
pip install pytest pytest-mock --quiet &&
python -m pytest tests/unit/ -v --tb=short -x
python3 -m pytest tests/unit/ -v --tb=short -x
"

# ═══════════════════════════════════════════════════════════
Expand All @@ -110,8 +107,7 @@ jobs:
echo '=== Arch Linux Test ===' &&
fixos --version || true &&
fixos scan --help &&
pip install pytest pytest-mock --quiet &&
python -m pytest tests/unit/ -v --tb=short -x
python3 -m pytest tests/unit/ -v --tb=short -x
" || echo "Arch test may fail due to rolling updates"

# ═══════════════════════════════════════════════════════════
Expand All @@ -136,8 +132,7 @@ jobs:
echo '=== Alpine Test ===' &&
fixos --version || true &&
fixos scan --help &&
pip install pytest pytest-mock --quiet &&
python -m pytest tests/unit/ -v --tb=short -x
python3 -m pytest tests/unit/ -v --tb=short -x
" || echo "Alpine test may fail due to musl libc differences"

# ═══════════════════════════════════════════════════════════
Expand Down
17 changes: 12 additions & 5 deletions tests/unit/test_service_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
from __future__ import annotations

from datetime import datetime, timezone
from pathlib import Path

from fixos.diagnostics.service_cleanup import ServiceCleaner
from fixos.diagnostics.service_scanner import ServiceDataInfo, ServiceType


def _home_path(*parts: str) -> str:
return str(Path.home().joinpath(*parts))


class TestChromeCleanup:
def test_chrome_cleanup_command_targets_scanned_profile(self):
path = "/home/tom/.config/google-chrome"
path = _home_path(".config", "google-chrome")

command = ServiceCleaner.get_cleanup_command(ServiceType.CHROME, path)

Expand All @@ -22,15 +27,15 @@ def test_chrome_cleanup_command_targets_scanned_profile(self):
assert "Service Worker" in command

def test_chrome_cache_cleanup_does_not_run_find_on_removed_path(self):
path = "/home/tom/.cache/google-chrome"
path = _home_path(".cache", "google-chrome")

command = ServiceCleaner.get_cleanup_command(ServiceType.CHROME, path)

assert command == f"rm -rf {path}"
assert "find" not in command

def test_cleanup_service_reports_freed_space_for_chrome(self, monkeypatch):
path = "/home/tom/.config/google-chrome"
path = _home_path(".config", "google-chrome")
initial_size_mb = 537.0
service = ServiceDataInfo(
service_type=ServiceType.CHROME,
Expand Down Expand Up @@ -513,8 +518,10 @@ def test_conda_package_cache_is_safe(self):
assert ServiceCleaner.get_risk_level(ServiceType.CONDA) == "safe"

def test_steam_shadercache_is_safe_but_library_is_dangerous(self):
shadercache = "/home/tom/.local/share/Steam/steamapps/shadercache"
library_root = "/home/tom/.local/share/Steam"
shadercache = _home_path(
".local", "share", "Steam", "steamapps", "shadercache"
)
library_root = _home_path(".local", "share", "Steam")

assert ServiceCleaner.get_risk_level(ServiceType.STEAM, shadercache) == "safe"
assert (
Expand Down
30 changes: 19 additions & 11 deletions tests/unit/test_service_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

from pathlib import Path

from fixos.diagnostics.service_scanner import (
ServiceDataInfo,
ServiceDataScanner,
Expand All @@ -10,10 +12,14 @@
from fixos.diagnostics.service_cleanup import ServiceCleaner


def _home_path(*parts: str) -> str:
return str(Path.home().joinpath(*parts))


class TestChromeSafetyClassification:
def test_chrome_profile_is_marked_for_review(self, monkeypatch):
scanner = ServiceDataScanner(threshold_mb=1)
profile_path = "/home/tom/.config/google-chrome"
profile_path = _home_path(".config", "google-chrome")

monkeypatch.setattr(scanner, "_get_path_size_mb", lambda path: 537.0)
monkeypatch.setattr(
Expand All @@ -28,7 +34,7 @@ def test_chrome_profile_is_marked_for_review(self, monkeypatch):

def test_chrome_cache_path_is_marked_safe(self, monkeypatch):
scanner = ServiceDataScanner(threshold_mb=1)
cache_path = "/home/tom/.cache/google-chrome"
cache_path = _home_path(".cache", "google-chrome")

monkeypatch.setattr(scanner, "_get_path_size_mb", lambda path: 40.0)
monkeypatch.setattr(
Expand All @@ -45,11 +51,13 @@ def test_chrome_cache_path_is_marked_safe(self, monkeypatch):
class TestServiceMerge:
def test_scan_service_merges_multiple_paths(self, monkeypatch):
scanner = ServiceDataScanner(threshold_mb=1)
cursor_cache = _home_path(".config", "Cursor", "Cache")
cursor_extensions = _home_path(".cursor", "extensions")

def fake_analyze(service_type, path):
sizes = {
"/home/tom/.config/Cursor/Cache": 16000.0,
"/home/tom/.cursor/extensions": 800.0,
cursor_cache: 16000.0,
cursor_extensions: 800.0,
}
size_mb = sizes.get(path, 0.0)
if size_mb <= 0:
Expand Down Expand Up @@ -91,7 +99,7 @@ class TestRiskLevelClassification:

def test_cursor_extensions_dir_is_dangerous_not_safe(self, monkeypatch):
scanner = ServiceDataScanner(threshold_mb=1)
path = "/home/tom/.cursor/extensions"
path = _home_path(".cursor", "extensions")

monkeypatch.setattr(scanner, "_get_path_size_mb", lambda p: 1200.0)
monkeypatch.setattr(
Expand All @@ -107,7 +115,7 @@ def test_cursor_extensions_dir_is_dangerous_not_safe(self, monkeypatch):

def test_cursor_cache_dir_is_safe(self, monkeypatch):
scanner = ServiceDataScanner(threshold_mb=1)
path = "/home/tom/.config/Cursor/Cache"
path = _home_path(".config", "Cursor", "Cache")

monkeypatch.setattr(scanner, "_get_path_size_mb", lambda p: 900.0)
monkeypatch.setattr(
Expand All @@ -122,7 +130,7 @@ def test_cursor_cache_dir_is_safe(self, monkeypatch):

def test_vscode_extensions_dir_is_dangerous(self, monkeypatch):
scanner = ServiceDataScanner(threshold_mb=1)
path = "/home/tom/.vscode/extensions"
path = _home_path(".vscode", "extensions")

monkeypatch.setattr(scanner, "_get_path_size_mb", lambda p: 2000.0)
monkeypatch.setattr(
Expand All @@ -141,9 +149,9 @@ def test_scan_service_splits_cursor_cache_and_extensions(self, monkeypatch):
merged into a single "safe" blob."""
scanner = ServiceDataScanner(threshold_mb=1)
sizes = {
"/home/tom/.config/Cursor/Cache": 900.0,
"/home/tom/.config/Cursor/CachedData": 100.0,
"/home/tom/.cursor/extensions": 1200.0,
_home_path(".config", "Cursor", "Cache"): 900.0,
_home_path(".config", "Cursor", "CachedData"): 100.0,
_home_path(".cursor", "extensions"): 1200.0,
}

monkeypatch.setattr(scanner, "_get_path_size_mb", lambda p: sizes.get(p, 0.0))
Expand Down Expand Up @@ -223,7 +231,7 @@ def fake_daemon_size():
scanner._details_provider, "get_details", lambda service_type, path: {}
)

scanner._analyze_service_path(ServiceType.NPM, "/home/tom/.npm")
scanner._analyze_service_path(ServiceType.NPM, _home_path(".npm"))

assert called["count"] == 0

Expand Down
Loading