--- /dev/null
+Vagrant.configure("2") do |config|
+ config.vm.box = "threatstack/debian6"
+ config.vm.box_version = "1.0.0"
+
+ config.vm.define 'debian6'
+end
strategy:
fail-fast: false
matrix:
- goos:
- - android
- - darwin
- - freebsd
- - ios
- - linux
- - windows
- goarch:
- - amd64
- - arm64
+ go:
+ - '1.16'
+ - '1.18'
runs-on: ubuntu-latest
steps:
- name: setup Go
uses: actions/setup-go@v3
with:
- go-version: '1.18'
+ go-version: ${{ matrix.go }}
- name: checkout
uses: actions/checkout@v3
- - name: build-${{ matrix.goos }}-${{ matrix.goarch }}
+ - name: build
run: |
- GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build
+ for a in $(go tool dist list); do
+ GOOS=${a%%/*} GOARCH=${a#*/} go build
+ done
--- /dev/null
+name: test
+on:
+ push:
+ pull_request:
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+ steps:
+ - name: setup Go
+ uses: actions/setup-go@v3
+ with:
+ go-version: '1.18'
+
+ - name: checkout
+ uses: actions/checkout@v3
+
+ - name: gofmt
+ run: |
+ test -z "$(gofmt -s -d . | tee /dev/stderr)"
+
+ - name: vet
+ run: |
+ go vet ./...
+
+ - name: golangci-lint
+ uses: golangci/golangci-lint-action@v3
+ continue-on-error: true
+ with:
+ version: latest
+ skip-go-installation: true
matrix:
os:
- ubuntu-latest
- - macos-latest
+ - macos-11
+ - macos-12
- windows-latest
go:
- - '1.18'
- - '1.17'
- '1.16'
+ - '1.18'
runs-on: ${{ matrix.os }}
steps:
- name: setup Go
- name: test
run: |
- go test --race ./...
+ go test -race ./...
testFreeBSD:
- runs-on: macos-10.15
+ runs-on: macos-12
name: test (freebsd, 1.18)
steps:
- uses: actions/checkout@v3
usesh: true
prepare: pkg install -y go
run: |
- go test
+ go test -race ./...
- lint:
- runs-on: ubuntu-latest
+ testOpenBSD:
+ runs-on: macos-12
+ name: test (openbsd, 1.17)
steps:
- - name: setup Go
- uses: actions/setup-go@v3
+ - uses: actions/checkout@v3
+ - name: test (openbsd, 1.17)
+ id: test
+ uses: vmactions/openbsd-vm@v0.0.6
with:
- go-version: '1.18'
-
- - name: checkout
- uses: actions/checkout@v3
-
- - name: gofmt
- run: |
- test -z "$(gofmt -s -d . | tee /dev/stderr)"
+ prepare: pkg_add go
+ run: |
+ # Default of 512 leads to "too many open files".
+ ulimit -n 1024
- - name: vet
- run: |
- go vet ./...
+ # No -race as the VM doesn't include the comp set.
+ #
+ # TODO: should probably add this, but on my local machine the tests
+ # time out with -race as the waits aren't long enough (OpenBSD
+ # is kind of slow), so should probably look into that first.
+ # Go 1.19 is supposed to have a much faster race detector, so
+ # maybe waiting until we have that is enough.
+ go test ./...
- - name: golangci-lint
- uses: golangci/golangci-lint-action@v3
- continue-on-error: true
+ testNetBSD:
+ runs-on: macos-12
+ name: test (netbsd, 1.17)
+ steps:
+ - uses: actions/checkout@v3
+ - name: test (netbsd, 1.17)
+ id: test
+ uses: vmactions/netbsd-vm@v0.0.4
with:
- version: latest
- skip-go-installation: true
+ prepare: pkg_add go
+ run: |
+ # TODO: no -race for the same reason as OpenBSD (the timing; it does run).
+ go117 test ./...
--- /dev/null
+name: vagrant
+on:
+ push:
+ pull_request:
+jobs:
+ test:
+ strategy:
+ fail-fast: false
+ matrix:
+ image:
+ - debian6
+ runs-on: macos-12
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: setup Go
+ uses: actions/setup-go@v3
+ with:
+ go-version: '1.18'
+
+ - name: test
+ run: |
+ cp -f .github/workflows/Vagrantfile.${{ matrix.image }} Vagrantfile
+ GOOS=linux GOARCH=amd64 go test -o fsnotify.test -c ./...
+ vagrant up
+ vagrant ssh -c "/vagrant/fsnotify.test"
`fsnotify` supports Windows, Linux, BSD and macOS with a common API.
-| Adapter | OS | Status |
-| --------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
-| inotify | Linux 2.6.27 or later, Android\* | Supported |
-| kqueue | BSD, macOS, iOS\* | Supported |
-| ReadDirectoryChangesW | Windows | Supported |
-| FSEvents | macOS | [Planned](https://github.com/fsnotify/fsnotify/issues/11) |
-| FEN | Solaris 11 | [In Progress](https://github.com/fsnotify/fsnotify/pull/371) |
-| fanotify | Linux 2.6.37+ | [Maybe](https://github.com/fsnotify/fsnotify/issues/114) |
-| USN Journals | Windows | [Maybe](https://github.com/fsnotify/fsnotify/issues/53) |
-| Polling | *All* | [Maybe](https://github.com/fsnotify/fsnotify/issues/9) |
+| Adapter | OS | Status |
+| --------------------- | -------------------------| -------------------------------------------------------------|
+| inotify | Linux 2.6.32+, Android\* | Supported |
+| kqueue | BSD, macOS, iOS\* | Supported |
+| ReadDirectoryChangesW | Windows | Supported |
+| FSEvents | macOS | [Planned](https://github.com/fsnotify/fsnotify/issues/11) |
+| FEN | Solaris 11 | [In Progress](https://github.com/fsnotify/fsnotify/pull/371) |
+| fanotify | Linux 2.6.37+ | [Maybe](https://github.com/fsnotify/fsnotify/issues/114) |
+| USN Journals | Windows | [Maybe](https://github.com/fsnotify/fsnotify/issues/53) |
+| Polling | *All* | [Maybe](https://github.com/fsnotify/fsnotify/issues/9) |
\* Android and iOS are untested.
-Please see [the documentation](https://pkg.go.dev/github.com/fsnotify/fsnotify) and consult the [FAQ](#faq) for usage information.
+fsnotify requires Go 1.16 or newer. Please see
+[the documentation](https://pkg.go.dev/github.com/fsnotify/fsnotify)
+and consult the [FAQ](#faq) for usage information.
-NOTE: fsnotify utilizes [`golang.org/x/sys`](https://pkg.go.dev/golang.org/x/sys) rather than [`syscall`](https://pkg.go.dev/syscall) from the standard library.
+NOTE: fsnotify utilizes
+[`golang.org/x/sys`](https://pkg.go.dev/golang.org/x/sys) rather than
+[`syscall`](https://pkg.go.dev/syscall) from the standard library.
## API stability
"path"
"path/filepath"
"runtime"
+ "strings"
"sync"
"sync/atomic"
"testing"
}
func TestFsnotifyMultipleOperations(t *testing.T) {
+ if runtime.GOOS == "netbsd" {
+ t.Skip("NetBSD behaviour is not fully correct") // TODO: investigate and fix.
+ }
+
watcher := newWatcher(t)
// Receive errors on the error channel on a separate goroutine
for i := 0; i < 150; i++ {
w, err := NewWatcher()
if err != nil {
+ if strings.Contains(err.Error(), "too many") { // syscall.EMFILE
+ time.Sleep(100 * time.Millisecond)
+ continue
+ }
t.Fatal(err)
}
go w.Close()