fix(test): skip permission test on WSL (#1115)
WSL doesn't fully respect Unix file permission semantics - the file owner can bypass read-only restrictions, similar to macOS. Add isWSL() helper and skip TestMergeDriverWithLockedConfig_E2E on WSL. Fixes bd-srv Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,21 @@ func skipIfTestBinary(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// isWSL returns true if running under Windows Subsystem for Linux.
|
||||
// WSL doesn't fully respect Unix file permission semantics - the file owner
|
||||
// can bypass read-only restrictions similar to macOS.
|
||||
func isWSL() bool {
|
||||
if runtime.GOOS != "linux" {
|
||||
return false
|
||||
}
|
||||
data, err := os.ReadFile("/proc/version")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
version := strings.ToLower(string(data))
|
||||
return strings.Contains(version, "microsoft") || strings.Contains(version, "wsl")
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// End-to-End Fix Tests
|
||||
// =============================================================================
|
||||
@@ -753,6 +768,10 @@ func TestMergeDriverWithLockedConfig_E2E(t *testing.T) {
|
||||
if runtime.GOOS == "darwin" {
|
||||
t.Skip("skipping on macOS: file owner can write to read-only files")
|
||||
}
|
||||
// Skip on WSL - similar to macOS, file owner can bypass read-only permissions
|
||||
if isWSL() {
|
||||
t.Skip("skipping on WSL: file owner can write to read-only files")
|
||||
}
|
||||
// Skip in CI - containers may have CAP_DAC_OVERRIDE or other capabilities
|
||||
// that bypass file permission checks
|
||||
if os.Getenv("CI") == "true" || os.Getenv("GITHUB_ACTIONS") == "true" {
|
||||
|
||||
Reference in New Issue
Block a user