test(windows): make the cmd/bd and storage suites pass on Windows (#4809)

* test(windows): resolve the home dir via USERPROFILE

TestGetClaudePluginVersion and two TestDetectBootstrapAction_* cases override
HOME to point discovery at a temp dir, but the code resolves the home dir with
os.UserHomeDir(), which reads USERPROFILE on Windows and HOME elsewhere. Set
both so the tests are hermetic on every platform.

Agent-Signature: claude-code-opus-4.8-high on behalf of Marco Del Pin

* test(windows): use platform-absolute paths in fixtures

Two tests assert behavior gated on filepath.IsAbs but used the POSIX literals
"/absolute/path" / "/var/run/dolt.sock", which filepath.IsAbs reports as NOT
absolute on Windows (no volume) -- so the assertions were silent no-ops there.
Derive platform-absolute paths (t.TempDir()) instead. Affects
TestContextInfo_SaveStripAbsoluteDataDir and TestNewDatabaseServer_BackendExternal.

Agent-Signature: claude-code-opus-4.8-high on behalf of Marco Del Pin

* test: skip embedded hook-firing test on Windows (GH#3800)

The test writes an extensionless #!/bin/sh hook, which Windows CreateProcess
cannot execute (no shebang dispatch), so no payload is ever logged and the
assertions fail. Guard it with the same runtime.GOOS == "windows" skip already
used for this class in internal/hooks/hooks_test.go (GH#3800).

Agent-Signature: claude-code-opus-4.8-high on behalf of Marco Del Pin

* test: skip branch-tracking pull test when the dolt CLI is absent

TestPullWithAutoResolve_BranchTrackingFallbackSuccess builds its file:// remote
with the dolt CLI, so it hard-fails with "exec: dolt: executable file not found"
on hosts without the binary. Guard it with exec.LookPath, matching the existing
guards in this package (bootstrap_test.go, fsck_test.go). The store under test
speaks the MySQL protocol and needs no local dolt binary.

Agent-Signature: claude-code-opus-4.8-high on behalf of Marco Del Pin
This commit is contained in:
Marco Del Pin 2026-07-24 07:25:36 +02:00 • committed by GitHub
commit 30fa306b00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 49 additions and 8 deletions

View file

@ -989,9 +989,12 @@ func TestDetectBootstrapAction_SharedServerEnvUsesSharedPath(t *testing.T) {
t.Fatal(err)
}
// Override HOME so SharedDoltDir() resolves to our temp directory
// instead of the real ~/.beads/shared-server/dolt/.
// Override the home dir so SharedDoltDir() resolves to our temp directory
// instead of the real ~/.beads/shared-server/dolt/. It goes through
// os.UserHomeDir(), which reads USERPROFILE on Windows and HOME elsewhere,
// so both must be set for this to be portable.
t.Setenv("HOME", tmpDir)
t.Setenv("USERPROFILE", tmpDir)
// Create a database directory at the shared-server location.
// SharedDoltDir() returns $HOME/.beads/shared-server/dolt/.
@ -1130,7 +1133,11 @@ func TestDetectBootstrapAction_SynthesizedDirWithoutRecoveryStillUsesExistingSha
t.Setenv("BEADS_DOLT_SHARED_SERVER", "1")
homeDir := t.TempDir()
// detectBootstrapAction resolves the home dir with os.UserHomeDir(), which reads
// USERPROFILE on Windows and HOME elsewhere; set both so the shared-server probe
// looks inside the temp home on every platform.
t.Setenv("HOME", homeDir)
t.Setenv("USERPROFILE", homeDir)
worktreeDir := filepath.Join(t.TempDir(), "worktree")
if err := os.MkdirAll(worktreeDir, 0o750); err != nil {

View file

@ -268,9 +268,14 @@ func TestContextInfo_SaveStripAbsoluteDataDir(t *testing.T) {
t.Fatalf("mkdir: %v", err)
}
// Save() strips DoltDataDir when filepath.IsAbs() reports it absolute, so the
// fixture must be absolute ON THIS PLATFORM: a POSIX path like /absolute/path is
// NOT absolute on Windows (no volume), which silently turned this into a no-op
// assertion there. t.TempDir() is always platform-absolute.
absDataDir := filepath.Join(t.TempDir(), "dolt-data")
cfg := &configfile.Config{
Database: "dolt",
DoltDataDir: "/absolute/path/dolt-data",
DoltDataDir: absDataDir,
}
if err := cfg.Save(beadsDir); err != nil {
t.Fatalf("save config: %v", err)

View file

@ -1,6 +1,8 @@
package main
import (
"path/filepath"
"runtime"
"testing"
"github.com/steveyegge/beads/internal/configfile"
@ -34,10 +36,18 @@ func TestNewDatabaseServer_BackendExternal(t *testing.T) {
})
t.Run("unix socket config builds an ExternalDoltServer", func(t *testing.T) {
// ExternalDoltConfig.Validate() requires an absolute Socket via filepath.IsAbs,
// which is platform-dependent: /var/run/dolt.sock is NOT absolute on Windows
// (no volume). Use a platform-absolute socket path so the same construction
// path is exercised everywhere.
socket := "/var/run/dolt.sock"
if runtime.GOOS == "windows" {
socket = filepath.Join(t.TempDir(), "dolt.sock")
}
srv, err := newDatabaseServer(
proxy.BackendExternal,
"", "", "", "", "",
configfile.ExternalDoltConfig{Socket: "/var/run/dolt.sock"},
configfile.ExternalDoltConfig{Socket: socket},
)
require.NoError(t, err)
require.NotNil(t, srv)

View file

@ -544,10 +544,11 @@ func TestGetClaudePluginVersion(t *testing.T) {
t.Fatal(err)
}
// Temporarily override home directory
origHome := os.Getenv("HOME")
os.Setenv("HOME", tmpHome)
defer os.Setenv("HOME", origHome)
// Temporarily override the home directory. GetClaudePluginVersion resolves it
// with os.UserHomeDir(), which reads USERPROFILE on Windows and HOME elsewhere,
// so both must be set for this to be portable (t.Setenv also restores them).
t.Setenv("HOME", tmpHome)
t.Setenv("USERPROFILE", tmpHome)
version, installed, err := doctor.GetClaudePluginVersion()

View file

@ -65,6 +65,15 @@ func TestPullWithAutoResolve_BranchTrackingFallback(t *testing.T) {
}
func TestPullWithAutoResolve_BranchTrackingFallbackSuccess(t *testing.T) {
// The fallback assertion needs a real file:// remote, which is built with the
// dolt CLI (runDoltCmdForBranchTracking / runDoltSQLForBranchTracking). Skip when
// the binary is absent, matching the existing guard in this package
// (bootstrap_test.go, fsck_test.go). The store itself talks the MySQL protocol
// and needs no local dolt binary.
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("dolt CLI not available")
}
remoteDir := filepath.Join(t.TempDir(), "remote")
if err := os.MkdirAll(remoteDir, 0o755); err != nil {
t.Fatalf("mkdir remote: %v", err)

View file

@ -8,6 +8,7 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"sort"
"strings"
"testing"
@ -1265,6 +1266,14 @@ func TestCreateIssues(t *testing.T) {
}
func TestHookFiringStoreCreateIssuesFiresDependencyUpdatesFromEmbeddedStore(t *testing.T) {
if runtime.GOOS == "windows" {
// The hook runner on Windows executes hook files directly via CreateProcess,
// which has no shebang dispatch. The extensionless #!/bin/sh hook written by
// newEmbeddedHookStore cannot be executed as a shell script, so no payload is
// ever logged and the assertions fail. Same limitation already skipped in
// internal/hooks/hooks_test.go. See: https://github.com/gastownhall/beads/issues/3800
t.Skip("hook script execution not supported on Windows - see GH#3800")
}
t.Run("non_transactional", func(t *testing.T) {
te := newTestEnv(t, "hk")
ctx := t.Context()