diff options
| author | 2024-08-20 18:30:56 -0500 | |
|---|---|---|
| committer | 2024-08-20 18:30:56 -0500 | |
| commit | c5a9602be9fcf883dff0e16a7d3b78e5e07dcf39 (patch) | |
| tree | 8570c523eb4ce7d17b64dd14321b8e5b67e978a9 /test | |
| parent | Fix mingw build warnings. (diff) | |
Better handle extra filewatch events on wine.filewatch
Diffstat (limited to 'test')
| -rw-r--r-- | test/suite-filewatch.janet | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/test/suite-filewatch.janet b/test/suite-filewatch.janet index ddd296a4..f921597b 100644 --- a/test/suite-filewatch.janet +++ b/test/suite-filewatch.janet @@ -54,6 +54,18 @@ # Drain if not empty, help with failures after this (while (pos? (ev/count chan)) (printf "extra: %p" (ev/take chan)))) +(defn- expect-maybe + "On wine + mingw, we get an extra event. This is a wine peculiarity." + [key value] + (ev/with-deadline + 1 + (ev/sleep 0) + (when (pos? (ev/count chan)) + (def event (ev/take chan)) + (when is-verbose (pp event)) + (assert event "check event") + (assert (= value (get event key)) (string/format "got %p, expected %p" (get event key) value))))) + (defn spit-file [dir name] (def path (string dir "/" name)) @@ -88,7 +100,7 @@ (spit-file td1 "file1.txt") (expect :type :added) (expect :type :modified) - (expect-empty) + (expect-maybe :type :modified) # for mingw + wine (gccollect) (spit-file td1 "file1.txt") (expect :type :modified) @@ -100,7 +112,7 @@ (spit-file td2 "file2.txt") (expect :type :added) (expect :type :modified) - (expect-empty) + (expect-maybe :type :modified) # Remove a file, then wait for remove event (rmrf (string td1 "/file1.txt")) @@ -118,12 +130,12 @@ (spit-file td1 "file1.txt") (expect :type :added) (expect :type :modified) - (expect-empty) + (expect-maybe :type :modified) (gccollect) (spit-file td1 "file1.txt") (expect :type :modified) (expect :type :modified) - (expect-empty) + (expect-maybe :type :modified) (gccollect)) # |
