Skip to content

feat: support WTF_CONFIG_DIR env var for hermetic test builds - #2129

Merged
Seanstoppable merged 1 commit into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-hermetic-test-config-dir
Jul 24, 2026
Merged

Seanstoppable merged 1 commit into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-hermetic-test-config-dir

Conversation

@Seanstoppable

Copy link
Copy Markdown
Collaborator

Summary

Adds a WTF_CONFIG_DIR environment variable that allows overriding the WTF configuration directory path. This enables hermetic build systems (Bazel, Nix) to run tests without needing filesystem access outside the project.

Closes #1612

Changes

  • cfg/config_files.go: WtfConfigDir() now checks WTF_CONFIG_DIR first (highest priority), then XDG_CONFIG_HOME, then the default ~/.config/wtf/.
  • logger/log.go: LogFilePath() respects WTF_CONFIG_DIR for the log file location.
  • utils/homedir_test.go: Assertions are now cross-platform compatible.
  • cfg/config_files_test.go: New tests for the env var override.

Usage

export WTF_CONFIG_DIR=$(mktemp -d)
go test ./...

Add WTF_CONFIG_DIR environment variable that takes highest priority when
resolving the config directory. This allows hermetic build systems (Bazel,
Nix) to run tests without needing access to \C:\Users\seand/.config/wtf/.

Changes:
- cfg/config_files.go: Check WTF_CONFIG_DIR before XDG_CONFIG_HOME
- logger/log.go: Respect WTF_CONFIG_DIR for log file path
- utils/homedir_test.go: Make assertions cross-platform compatible
- cfg/config_files_test.go: Add tests for the new env var override

Closes wtfutil#1612

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@Seanstoppable
Seanstoppable merged commit 131d5ff into wtfutil:trunk Jul 24, 2026
4 checks passed
@Seanstoppable
Seanstoppable deleted the seanstoppable-hermetic-test-config-dir branch July 24, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Make unit tests entirely contained to the project

1 participant

⌂ 换网址