feat(daemon): add BD_SOCKET env var for test isolation (#914)

Add BD_SOCKET environment variable support to override daemon socket path,
enabling parallel test isolation via t.TempDir() + t.Setenv().

Changes:
- getSocketPath() checks BD_SOCKET first, falls back to dbPath-derived path
- getSocketPathForPID() checks BD_SOCKET first (for consistency)
- Add daemon_socket_test.go with isolation pattern examples

This is a minimal tracer bullet to validate the approach before
expanding to full test isolation infrastructure.

Backward compatible: default behavior unchanged without env var set.
This commit is contained in:
Peter Chanthamynavong
2026-01-06 19:13:49 -08:00
committed by GitHub
parent 5dfb838d60
commit e9e0d7f1e5
4 changed files with 92 additions and 4 deletions

7
go.mod
View File

@@ -10,9 +10,12 @@ require (
github.com/charmbracelet/huh v0.8.0
github.com/charmbracelet/lipgloss v1.1.0
github.com/fsnotify/fsnotify v1.9.0
github.com/muesli/termenv v0.16.0
github.com/ncruces/go-sqlite3 v0.30.4
github.com/olebedev/when v1.1.0
github.com/spf13/cobra v1.10.2
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
github.com/tetratelabs/wazero v1.11.0
golang.org/x/mod v0.31.0
golang.org/x/sys v0.39.0
@@ -34,6 +37,7 @@ require (
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
@@ -46,11 +50,10 @@ require (
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/ncruces/julianday v1.0.0 // indirect
github.com/olebedev/when v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.11.0 // indirect
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect