Skip to content

Windows: init/track tests write through to the real user config.yaml — HOME isolation no-ops #503

Description

@pbednarcik

Windows: init/track tests write through to the real user config.yaml — HOME isolation no-ops

Symptom

On Windows, running the cmd/gortex test suite pollutes the developer's live repo inventory: after a plain

go test ./cmd/gortex/

the real user-level config.yaml gains tracked-repo entries pointing at the suite's temp directories:

repos:
    - path: D:\Cache\Temp\TestInitCreatesProjectMarker3612887292\001
    - path: D:\Cache\Temp\TestInitRefusesHomeDirectory551333095\001

The temp dirs are gone by then (t.TempDir cleanup), so the next daemon start greets you with

!! 4 tracked repos no longer exist on disk — the path was deleted, renamed, or unmounted

and each corpse has to be untracked by hand. I've hit this four times in the past week — every local verification run over cmd/gortex regrows a few TestInit* entries.

Cause

The tests DO try to isolate: init_integration_test.go sets t.Setenv("HOME", t.TempDir()) before running runInit. But the config path is resolved through os.UserHomeDir() (cmd/gortex/init.go:235, :374), and on Windows that reads %USERPROFILE%, not HOME — so the override is a silent no-op and the init/track side effects land in the real ~/.gortex/config.yaml. On macOS/Linux the isolation works, which is why CI never sees it.

Repro (Windows)

  1. Note your user-level config.yaml repo list.
  2. go test -count=1 -run "TestInit" ./cmd/gortex/
  3. Diff the config: new repos: entries under the temp root appear; the directories themselves are already gone.

Suggested fix

Either per-test: set USERPROFILE alongside HOME in the same t.Setenv blocks (cheap, but every future test must remember both), or centrally: a shared test helper that redirects the user config dir cross-platform — the daemon integration suite's spinUpDaemonWithConfig pattern already points everything at a test-scoped config and never leaks. Belt and braces: fail the suite if the real user config's mtime changes during a run, so the isolation can't regress silently again.

Happy to send a PR — the per-test fix is a handful of lines.

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