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:
@@ -12,13 +12,13 @@ import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/build"
|
||||
"github.com/syncthing/syncthing/lib/config"
|
||||
"github.com/syncthing/syncthing/lib/events"
|
||||
"github.com/syncthing/syncthing/lib/fs"
|
||||
@@ -72,7 +72,7 @@ func TestRequestSimple(t *testing.T) {
|
||||
func TestSymlinkTraversalRead(t *testing.T) {
|
||||
// Verify that a symlink can not be traversed for reading.
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
if build.IsWindows {
|
||||
t.Skip("no symlink support on CI")
|
||||
return
|
||||
}
|
||||
@@ -115,7 +115,7 @@ func TestSymlinkTraversalRead(t *testing.T) {
|
||||
func TestSymlinkTraversalWrite(t *testing.T) {
|
||||
// Verify that a symlink can not be traversed for writing.
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
if build.IsWindows {
|
||||
t.Skip("no symlink support on CI")
|
||||
return
|
||||
}
|
||||
@@ -214,7 +214,7 @@ func TestRequestCreateTmpSymlink(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRequestVersioningSymlinkAttack(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
if build.IsWindows {
|
||||
t.Skip("no symlink support on Windows")
|
||||
}
|
||||
|
||||
@@ -613,7 +613,7 @@ func TestParentDeletion(t *testing.T) {
|
||||
// TestRequestSymlinkWindows checks that symlinks aren't marked as deleted on windows
|
||||
// Issue: https://github.com/syncthing/syncthing/issues/5125
|
||||
func TestRequestSymlinkWindows(t *testing.T) {
|
||||
if runtime.GOOS != "windows" {
|
||||
if !build.IsWindows {
|
||||
t.Skip("windows specific test")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user