Skip to content

test: a suite member creates /tmp/.git and breaks the find --no-require-git contract #205

Description

@akougkas

Problem

tests/contracts/tool-hardening.test.ts ("find passes --no-require-git only outside a git repo") fails intermittently under npm run test and passes in isolation. The cause is a stray empty /tmp/.git directory that appears during a full suite run. isInsideGitRepo in src/tools/ignore-policy.ts:45 walks up from the scratch directory and, once it reaches /tmp, finds that .git and drops --no-require-git.

Expected: no test creates a .git at the system temp root, and the suite is order-independent.

Reproduce

Observed on 2026-08-24 on WSL2 with fd 10.3.0:

  1. rmdir /tmp/.git (it was an empty directory owned by the test user, mtime 11:49, then again 12:06, both during suite runs).
  2. node --import tsx --import ./tests/harness/tmp-root.ts --test tests/contracts/tool-hardening.test.ts passes 51/51 and does not recreate it.
  3. Running each describe block of that file separately never recreates it.
  4. A concurrent full npm run test in a sibling worktree recreated it at 12:06.

So the creator is a test elsewhere in the suite, likely one that spawns a child with a scrubbed environment (no CLIO_CODER_TEST_TMP_ROOT / TMPDIR) and then creates join(tmpdir(), ".git"), or a product path exercised by a test that writes .git at os.tmpdir().

Evidence

  • src/tools/ignore-policy.ts:45 (isInsideGitRepo walks to the filesystem root).
  • tests/contracts/tool-hardening.test.ts:356.
  • tests/harness/tmp-root.ts repoints TMPDIR for the runner and its children, but only when the child inherits the environment.

Acceptance criteria

  • The creating test is identified and no longer writes outside its scratch root, or the harness refuses a .git at the system temp root and names the test that made it.
  • npm run test passes with no /tmp/.git present before or after the run, twice in a row.
  • tool-hardening "find passes --no-require-git only outside a git repo" is order-independent.

Links

Noticed while integrating v0.3.7 wave 1; unrelated to the /btw and dispatch-intent briefs.

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

    area:testsTest suite, harnesses, CI lanes

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions