From e577dc8524a23e76bc5d37f5288dd4085dec4b02 Mon Sep 17 00:00:00 2001 From: Tom Softreck Date: Thu, 13 Aug 2026 13:34:20 +0200 Subject: [PATCH 1/2] [ci-home-portability] fix(tests): update project Statistics: 2 files changed, 31 insertions, 16 deletions Summary: - Dirs: tests=2 - Exts: .py=2 - A/M/D: 0/2/0 - Symbols: class TestChromeSafetyClassification, _home_path, class TestChromeCleanup Modified files: - tests/unit/test_service_cleanup.py (+12/-5) - tests/unit/test_service_scanner.py (+19/-11) Changes (notes): - tests/unit/test_service_cleanup.py (+12/-5): add functions: _home_path - tests/unit/test_service_scanner.py (+19/-11): add functions: _home_path Implementation notes (heuristics): - Type inferred from file paths + diff keywords + add/delete ratio - Scope prefers 'goal' when goal/* is touched; otherwise based on top-level dirs - For <=6 files: generate short per-file notes from added lines (defs/classes/click options/headings) - A/M/D derived from git name-status; per-file +X/-X from git numstat --- tests/unit/test_service_cleanup.py | 17 ++++++++++++----- tests/unit/test_service_scanner.py | 30 +++++++++++++++++++----------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/tests/unit/test_service_cleanup.py b/tests/unit/test_service_cleanup.py index 622d113..4c5ad0f 100644 --- a/tests/unit/test_service_cleanup.py +++ b/tests/unit/test_service_cleanup.py @@ -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) @@ -22,7 +27,7 @@ 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) @@ -30,7 +35,7 @@ def test_chrome_cache_cleanup_does_not_run_find_on_removed_path(self): 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, @@ -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 ( diff --git a/tests/unit/test_service_scanner.py b/tests/unit/test_service_scanner.py index 5130998..8c37334 100644 --- a/tests/unit/test_service_scanner.py +++ b/tests/unit/test_service_scanner.py @@ -2,6 +2,8 @@ from __future__ import annotations +from pathlib import Path + from fixos.diagnostics.service_scanner import ( ServiceDataInfo, ServiceDataScanner, @@ -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( @@ -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( @@ -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: @@ -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( @@ -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( @@ -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( @@ -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)) @@ -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 From 1440421905672a9874565d89d846dce1dc7d1ef2 Mon Sep 17 00:00:00 2001 From: Tom Softreck Date: Thu, 13 Aug 2026 13:52:18 +0200 Subject: [PATCH 2/2] [ci-home-portability] refactor(tests): changelog generation stats: lines: "+5/-10 (net -5)" files: 1 complexity: "Stable complexity" --- .github/workflows/multi-system-tests.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/multi-system-tests.yml b/.github/workflows/multi-system-tests.yml index b108377..f9871c9 100644 --- a/.github/workflows/multi-system-tests.yml +++ b/.github/workflows/multi-system-tests.yml @@ -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 " # ═══════════════════════════════════════════════════════════ @@ -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 " # ═══════════════════════════════════════════════════════════ @@ -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 " # ═══════════════════════════════════════════════════════════ @@ -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" # ═══════════════════════════════════════════════════════════ @@ -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" # ═══════════════════════════════════════════════════════════