Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

darwin tests: Exchangedata is deprecated on 10.13 #267

Merged
merged 2 commits into from Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Expand Up @@ -6,7 +6,6 @@ go:
- "1.10.4"
- "1.9.x"
- "1.8.x"
- tip

matrix:
allow_failures:
Expand All @@ -17,7 +16,7 @@ before_script:
- go get -u golang.org/x/lint/golint

script:
- go test -v --race ./...
- go test --race ./...

after_script:
- test -z "$(gofmt -s -l -w . | tee /dev/stderr)"
Expand Down
20 changes: 20 additions & 0 deletions integration_darwin_test.go
Expand Up @@ -7,19 +7,39 @@ 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.
//
// 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)

Expand Down