Skip to content

Fix 7 pre-existing test failures in isolated HOME environment #222

@malpern

Description

@malpern

Summary

7 tests consistently fail when run via Scripts/run-tests-safe.sh because the script sets HOME to a temp directory for isolation, but these tests expect real system plist paths or launchctl state.

Failing Tests

  • PrivilegedOperationsCoordinatorTests.testRegenerateServiceConfigurationAllowsPendingApprovalPostcondition
  • PrivilegedOperationsCoordinatorTests.testRestartUnhealthyServicesFailsWhenPostconditionTimesOut
  • ServiceBootstrapperTests.testLoadServicesInTestModeReturnsFalseWhenAnyPlistMissing
  • ServiceBootstrapperTests.testRepairVHIDDaemonServicesInTestModeSetsOutput
  • ServiceBootstrapperTests.testUnloadAndInstallPathsReturnSuccessInTestMode
  • ServiceHealthCheckerTests.testCheckKanataServiceHealthDoesNotProbeSystemInTestMode
  • ServiceHealthCheckerTests.testIsServiceLoadedUsesPlistExistenceInTestMode

Root Cause

run-tests-safe.sh sets HOME to a temp directory to prevent parallel-agent collisions and keep tests hermetic. These tests rely on system paths derived from HOME (e.g., ~/Library/LaunchDaemons/) which don't exist in the temp directory.

Proposed Fix

  • Add test-mode path remapping or mock the plist existence checks
  • Ensure TestEnvironment.isRunningTests guards are in place for system-dependent operations
  • Alternatively, create required directory structure in the temp HOME during test setUp

Context

Discovered while fixing CI for PR #217 (Karabiner converter). These failures are pre-existing on master and unrelated to that feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions