]> go.fuhry.dev Git - fsnotify.git/commitdiff
windows: test symlinks (#491)
authorMartin Tournoij <martin@arp242.net>
Fri, 5 Aug 2022 21:45:16 +0000 (23:45 +0200)
committerGitHub <noreply@github.com>
Fri, 5 Aug 2022 21:45:16 +0000 (23:45 +0200)
Symlinks are supported since Windows Vista; there's no reason to not
test it.

helpers_test.go
integration_test.go

index c858a6ff6562bbf755be83ec85710d755ac84bb4..a3ce4587747771dd0ffc0e85dd056ba6d9c24179 100644 (file)
@@ -348,12 +348,15 @@ func (e Events) copy() Events {
 //   # Windows-specific test.
 //   windows:
 //     WRITE    path
+//
+// You can specify multiple platforms with a comma (e.g. "windows, linux:").
+// "kqueue" is a shortcut for all kqueue systems (BSD, macOS).
 func newEvents(t *testing.T, s string) Events {
        t.Helper()
 
        var (
                lines  = strings.Split(s, "\n")
-               group  string
+               groups = []string{""}
                events = make(map[string]Events)
        )
        for no, line := range lines {
@@ -365,7 +368,10 @@ func newEvents(t *testing.T, s string) Events {
                        continue
                }
                if strings.HasSuffix(line, ":") {
-                       group = strings.TrimRight(line, ":")
+                       groups = strings.Split(strings.TrimRight(line, ":"), ",")
+                       for i := range groups {
+                               groups[i] = strings.TrimSpace(groups[i])
+                       }
                        continue
                }
 
@@ -398,7 +404,10 @@ func newEvents(t *testing.T, s string) Events {
                                }
                        }
                }
-               events[group] = append(events[group], Event{Name: path, Op: op})
+
+               for _, g := range groups {
+                       events[g] = append(events[g], Event{Name: path, Op: op})
+               }
        }
 
        if e, ok := events[runtime.GOOS]; ok {
index 8768fbfeaf4993e1a14bc04f591cb0bea87cabb7..3367e8044e9dc98b68a3c82aae87f88e8d3ceaad 100644 (file)
@@ -196,10 +196,6 @@ func TestWatchRename(t *testing.T) {
 }
 
 func TestWatchSymlink(t *testing.T) {
-       if runtime.GOOS == "windows" {
-               t.Skip("symlinks don't work on Windows")
-       }
-
        tests := []testCase{
                {"create unresolvable symlink", func(t *testing.T, w *Watcher, tmp string) {
                        addWatch(t, w, tmp)
@@ -207,6 +203,10 @@ func TestWatchSymlink(t *testing.T) {
                        symlink(t, filepath.Join(tmp, "target"), tmp, "link")
                }, `
                        create /link
+
+                       windows:
+                create    /link
+                write     /link
                `},
 
                {"cyclic symlink", func(t *testing.T, w *Watcher, tmp string) {
@@ -234,7 +234,7 @@ func TestWatchSymlink(t *testing.T) {
                        write  /link
                        create /link
 
-                       linux:
+                       linux, windows:
                                remove    /link
                                create    /link
                                write     /link