all: Add build constants for runtime.GOOS comparisons (#8442)
all: Add package runtimeos for runtime.GOOS comparisons I grew tired of hand written string comparisons. This adds generated constants for the GOOS values, and predefined Is$OS constants that can be iffed on. In a couple of places I rewrote trivial switch:es to if:s, and added Illumos where we checked for Solaris (because they are effectively the same, and if we're going to target one of them that would be Illumos...).
This commit is contained in:
@@ -11,12 +11,13 @@ import (
|
||||
"fmt"
|
||||
osexec "os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/build"
|
||||
)
|
||||
|
||||
func testWalkSkipSymlink(t *testing.T, fsType FilesystemType, uri string) {
|
||||
if runtime.GOOS == "windows" {
|
||||
if build.IsWindows {
|
||||
t.Skip("Symlinks skipping is not tested on windows")
|
||||
}
|
||||
|
||||
@@ -53,7 +54,7 @@ func createDirJunct(target string, name string) error {
|
||||
}
|
||||
|
||||
func testWalkTraverseDirJunct(t *testing.T, fsType FilesystemType, uri string) {
|
||||
if runtime.GOOS != "windows" {
|
||||
if !build.IsWindows {
|
||||
t.Skip("Directory junctions are available and tested on windows only")
|
||||
}
|
||||
|
||||
@@ -86,7 +87,7 @@ func testWalkTraverseDirJunct(t *testing.T, fsType FilesystemType, uri string) {
|
||||
}
|
||||
|
||||
func testWalkInfiniteRecursion(t *testing.T, fsType FilesystemType, uri string) {
|
||||
if runtime.GOOS != "windows" {
|
||||
if !build.IsWindows {
|
||||
t.Skip("Infinite recursion detection is tested on windows only")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user