mirror of
https://github.com/janet-lang/janet
synced 2025-01-08 06:30:28 +00:00
Better handle extra filewatch events on wine.
This commit is contained in:
parent
e88aab6d68
commit
c5a9602be9
@ -54,6 +54,18 @@
|
|||||||
# Drain if not empty, help with failures after this
|
# Drain if not empty, help with failures after this
|
||||||
(while (pos? (ev/count chan)) (printf "extra: %p" (ev/take chan))))
|
(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
|
(defn spit-file
|
||||||
[dir name]
|
[dir name]
|
||||||
(def path (string dir "/" name))
|
(def path (string dir "/" name))
|
||||||
@ -88,7 +100,7 @@
|
|||||||
(spit-file td1 "file1.txt")
|
(spit-file td1 "file1.txt")
|
||||||
(expect :type :added)
|
(expect :type :added)
|
||||||
(expect :type :modified)
|
(expect :type :modified)
|
||||||
(expect-empty)
|
(expect-maybe :type :modified) # for mingw + wine
|
||||||
(gccollect)
|
(gccollect)
|
||||||
(spit-file td1 "file1.txt")
|
(spit-file td1 "file1.txt")
|
||||||
(expect :type :modified)
|
(expect :type :modified)
|
||||||
@ -100,7 +112,7 @@
|
|||||||
(spit-file td2 "file2.txt")
|
(spit-file td2 "file2.txt")
|
||||||
(expect :type :added)
|
(expect :type :added)
|
||||||
(expect :type :modified)
|
(expect :type :modified)
|
||||||
(expect-empty)
|
(expect-maybe :type :modified)
|
||||||
|
|
||||||
# Remove a file, then wait for remove event
|
# Remove a file, then wait for remove event
|
||||||
(rmrf (string td1 "/file1.txt"))
|
(rmrf (string td1 "/file1.txt"))
|
||||||
@ -118,12 +130,12 @@
|
|||||||
(spit-file td1 "file1.txt")
|
(spit-file td1 "file1.txt")
|
||||||
(expect :type :added)
|
(expect :type :added)
|
||||||
(expect :type :modified)
|
(expect :type :modified)
|
||||||
(expect-empty)
|
(expect-maybe :type :modified)
|
||||||
(gccollect)
|
(gccollect)
|
||||||
(spit-file td1 "file1.txt")
|
(spit-file td1 "file1.txt")
|
||||||
(expect :type :modified)
|
(expect :type :modified)
|
||||||
(expect :type :modified)
|
(expect :type :modified)
|
||||||
(expect-empty)
|
(expect-maybe :type :modified)
|
||||||
(gccollect))
|
(gccollect))
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user