]> go.fuhry.dev Git - fsnotify.git/commitdiff
darwin tests: Exchangedata is deprecated on 10.13
authorNathan Youngman <git@nathany.com>
Thu, 30 Aug 2018 20:16:33 +0000 (14:16 -0600)
committerNathan Youngman <git@nathany.com>
Thu, 30 Aug 2018 21:20:37 +0000 (15:20 -0600)
#264

integration_darwin_test.go

index 553767c3896fb65e48e4e06b542bd9de9ba704ed..c43d00c6b5fd40737e51f4de24a633290d03c00c 100644 (file)
@@ -7,12 +7,24 @@ package fsnotify
 import (
        "os"
        "path/filepath"
+       "strconv"
+       "strings"
        "testing"
        "time"
 
        "golang.org/x/sys/unix"
 )
 
+// darwinVersion returns version os Darwin (17 is macOS 10.13).
+func darwinVersion() (int, error) {
+       s, err := unix.Sysctl("kern.osrelease")
+       if err != nil {
+               return 0, err
+       }
+       s = strings.Split(s, ".")[0]
+       return strconv.Atoi(s)
+}
+
 // testExchangedataForWatcher tests the watcher with the exchangedata operation on macOS.
 //
 // This is widely used for atomic saves on macOS, e.g. TextMate and in Apple's NSDocument.
@@ -20,6 +32,14 @@ import (
 // See https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/exchangedata.2.html
 // Also see: https://github.com/textmate/textmate/blob/cd016be29489eba5f3c09b7b70b06da134dda550/Frameworks/io/src/swap_file_data.cc#L20
 func testExchangedataForWatcher(t *testing.T, watchDir bool) {
+       osVersion, err := darwinVersion()
+       if err != nil {
+               t.Fatal("unable to get Darwin version:", err)
+       }
+       if osVersion >= 17 {
+               t.Skip("Exchangedata is deprecated in macOS 10.13")
+       }
+
        // Create directory to watch
        testDir1 := tempMkdir(t)