Skip to content

fix(tests): stabilize local Windows test runs by handling EPERM on temp dir cleanup #25

Description

@kok-o

Problem Statement

While the automated GitHub Actions CI runner on \windows-latest\ runs the entire test suite cleanly, developers running
pm test\ locally on Windows occasionally encounter \EPERM: operation not permitted\ errors during teardown of temporary project folders.

This happens because background file indexing, antivirus scanners, or lingering file descriptors temporarily lock directories before \ s.rmSync(dir, { recursive: true })\ completes.

Objective

Make the local test runner completely resilient to transient Windows file locks so that
pm test\ runs 100% green on local developer machines without manual retries.

Scope of Work

  1. Safe Teardown Helper:
    • Implement a shared test helper \safeRemoveDir(dir)\ that wraps directory cleanup with exponential retry and backoff (e.g. \ s.rmSync(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 })).
  2. File Handle Auditing:
    • Verify that tests involving \SafeWriter, \JournaledTransaction, and git worktrees explicitly close file descriptors before invoking assertions or teardowns.
  3. Npm Cache / Sandbox Isolation:
    • Ensure local temporary npm cache directories used during \install.test.js\ or \update.test.js\ avoid conflicting locks with the global user .npm\ cache.

Acceptance Criteria

  • All 350+ unit and integration tests run to completion on local Windows environments without \EPERM\ failures.
  • No flaky test teardown crashes in CI or local developer machines.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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