fix(ci): address Windows test failures and timeout
- Extract inode function to platform-specific files (inode_unix.go, inode_windows.go) to fix syscall.Stat_t compile error on Windows - Add skipOnWindows helper and skip Unix permission/symlink tests on Windows where chmod semantics differ - Increase Windows test timeout from 10m to 20m since full test suite runs slower without race detector Fixes Windows CI failures introduced when PR #904 expanded Windows testing from smoke tests to full test suite. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
ffe0dca2a3
commit
2fb6fd074a
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -64,7 +64,7 @@ jobs:
|
|||||||
# Windows: full test suite, no race detector (slower on Windows)
|
# Windows: full test suite, no race detector (slower on Windows)
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
coverage: false
|
coverage: false
|
||||||
test-flags: '-v -short'
|
test-flags: '-v -short -timeout=20m'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
|||||||
@@ -815,6 +815,9 @@ func TestMergeDriverWithLockedConfig_E2E(t *testing.T) {
|
|||||||
|
|
||||||
// TestPermissionsWithWrongPermissions_E2E tests fixing wrong permissions on .beads
|
// TestPermissionsWithWrongPermissions_E2E tests fixing wrong permissions on .beads
|
||||||
func TestPermissionsWithWrongPermissions_E2E(t *testing.T) {
|
func TestPermissionsWithWrongPermissions_E2E(t *testing.T) {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
t.Skip("skipping Unix permission test on Windows")
|
||||||
|
}
|
||||||
if os.Getuid() == 0 {
|
if os.Getuid() == 0 {
|
||||||
t.Skip("skipping permission tests when running as root")
|
t.Skip("skipping permission tests when running as root")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -352,6 +353,9 @@ func TestGitHooks_EdgeCases(t *testing.T) {
|
|||||||
// TestMergeDriver_EdgeCases tests MergeDriver with edge cases
|
// TestMergeDriver_EdgeCases tests MergeDriver with edge cases
|
||||||
func TestMergeDriver_EdgeCases(t *testing.T) {
|
func TestMergeDriver_EdgeCases(t *testing.T) {
|
||||||
t.Run("read-only git config file", func(t *testing.T) {
|
t.Run("read-only git config file", func(t *testing.T) {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
t.Skip("skipping Unix permission test on Windows")
|
||||||
|
}
|
||||||
dir := setupTestGitRepo(t)
|
dir := setupTestGitRepo(t)
|
||||||
gitDir := filepath.Join(dir, ".git")
|
gitDir := filepath.Join(dir, ".git")
|
||||||
gitConfigPath := filepath.Join(gitDir, "config")
|
gitConfigPath := filepath.Join(gitDir, "config")
|
||||||
@@ -665,6 +669,9 @@ func TestMigrateTombstones_EdgeCases(t *testing.T) {
|
|||||||
|
|
||||||
// TestPermissions_EdgeCases tests Permissions with edge cases
|
// TestPermissions_EdgeCases tests Permissions with edge cases
|
||||||
func TestPermissions_EdgeCases(t *testing.T) {
|
func TestPermissions_EdgeCases(t *testing.T) {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
t.Skip("skipping Unix permission/symlink test on Windows")
|
||||||
|
}
|
||||||
t.Run("symbolic link to .beads directory", func(t *testing.T) {
|
t.Run("symbolic link to .beads directory", func(t *testing.T) {
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,18 @@ package fix
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// skipOnWindows skips tests that rely on Unix file permissions or symlinks.
|
||||||
|
func skipOnWindows(t *testing.T) {
|
||||||
|
t.Helper()
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
t.Skip("skipping Unix permission/symlink test on Windows")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TestPermissions_SkipsSymlinkedBeadsDir verifies that permission fixes are skipped
|
// TestPermissions_SkipsSymlinkedBeadsDir verifies that permission fixes are skipped
|
||||||
// when .beads directory is a symlink (common on NixOS with home-manager).
|
// when .beads directory is a symlink (common on NixOS with home-manager).
|
||||||
//
|
//
|
||||||
@@ -13,6 +22,7 @@ import (
|
|||||||
// - When .beads is a symlink, Permissions() should return nil without changing anything
|
// - When .beads is a symlink, Permissions() should return nil without changing anything
|
||||||
// - This prevents attempts to chmod symlink targets (which may be read-only like /nix/store)
|
// - This prevents attempts to chmod symlink targets (which may be read-only like /nix/store)
|
||||||
func TestPermissions_SkipsSymlinkedBeadsDir(t *testing.T) {
|
func TestPermissions_SkipsSymlinkedBeadsDir(t *testing.T) {
|
||||||
|
skipOnWindows(t)
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
// Create target .beads directory with wrong permissions
|
// Create target .beads directory with wrong permissions
|
||||||
@@ -62,6 +72,7 @@ func TestPermissions_SkipsSymlinkedBeadsDir(t *testing.T) {
|
|||||||
// TestPermissions_SkipsSymlinkedDatabase verifies that chmod is skipped for
|
// TestPermissions_SkipsSymlinkedDatabase verifies that chmod is skipped for
|
||||||
// symlinked database files, but .beads directory permissions are still fixed.
|
// symlinked database files, but .beads directory permissions are still fixed.
|
||||||
func TestPermissions_SkipsSymlinkedDatabase(t *testing.T) {
|
func TestPermissions_SkipsSymlinkedDatabase(t *testing.T) {
|
||||||
|
skipOnWindows(t)
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
// Create real .beads directory with wrong permissions
|
// Create real .beads directory with wrong permissions
|
||||||
@@ -125,6 +136,7 @@ func TestPermissions_SkipsSymlinkedDatabase(t *testing.T) {
|
|||||||
// TestPermissions_FixesRegularFiles verifies that permissions ARE fixed for
|
// TestPermissions_FixesRegularFiles verifies that permissions ARE fixed for
|
||||||
// regular (non-symlinked) files.
|
// regular (non-symlinked) files.
|
||||||
func TestPermissions_FixesRegularFiles(t *testing.T) {
|
func TestPermissions_FixesRegularFiles(t *testing.T) {
|
||||||
|
skipOnWindows(t)
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
// Create .beads directory with wrong permissions
|
// Create .beads directory with wrong permissions
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -15,20 +14,6 @@ import (
|
|||||||
_ "github.com/ncruces/go-sqlite3/embed"
|
_ "github.com/ncruces/go-sqlite3/embed"
|
||||||
)
|
)
|
||||||
|
|
||||||
// getInode returns the inode of a file (Unix only)
|
|
||||||
func getInode(path string) uint64 {
|
|
||||||
info, err := os.Stat(path)
|
|
||||||
if err != nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
if sys := info.Sys(); sys != nil {
|
|
||||||
if stat, ok := sys.(*syscall.Stat_t); ok {
|
|
||||||
return stat.Ino
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// testFreshnessEnv creates two independent connections to the same database file.
|
// testFreshnessEnv creates two independent connections to the same database file.
|
||||||
// conn1 simulates the daemon's long-lived connection.
|
// conn1 simulates the daemon's long-lived connection.
|
||||||
// conn2 simulates an external process (like git merge bringing in new data).
|
// conn2 simulates an external process (like git merge bringing in new data).
|
||||||
|
|||||||
23
internal/storage/sqlite/inode_unix.go
Normal file
23
internal/storage/sqlite/inode_unix.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
//go:build !windows
|
||||||
|
|
||||||
|
package sqlite
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
// getInode returns the inode of a file (Unix only).
|
||||||
|
// Used for debugging file replacement detection in tests.
|
||||||
|
func getInode(path string) uint64 {
|
||||||
|
info, err := os.Stat(path)
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if sys := info.Sys(); sys != nil {
|
||||||
|
if stat, ok := sys.(*syscall.Stat_t); ok {
|
||||||
|
return stat.Ino
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
9
internal/storage/sqlite/inode_windows.go
Normal file
9
internal/storage/sqlite/inode_windows.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package sqlite
|
||||||
|
|
||||||
|
// getInode returns 0 on Windows as inodes don't exist.
|
||||||
|
// Used for debugging file replacement detection in tests.
|
||||||
|
func getInode(_ string) uint64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user