remove hardcoded filename in test event generator

This commit is contained in:
Daniel Barlow 2024-03-05 22:57:20 +00:00
parent 7173b6fb1c
commit e1b932ec27

View file

@ -1,15 +1,21 @@
(local fennel (require :fennel))
(fn event-fn [groups]
(let [data (with-open [e (io.open "events-fixture" "r")] (e:read "*a"))
(fn event-generator [events]
(coroutine.wrap
(fn []
(each [_ e (ipairs events)] (coroutine.yield e)))))
(fn file-events [path]
(let [data (with-open [e (io.open path "r")] (e:read "*a"))
parse (fennel.parser data)]
(coroutine.wrap
(fn []
(each [ok ast parse]
(if ok (coroutine.yield ast)))))))
(icollect [_ ast parse]
ast)))
(set _G.arg (doto ["-v" "dummy0" "up"] (tset 0 "test")))
(local ifwait (require :ifwait))
(ifwait.run event-fn)
(ifwait.run #(event-generator (file-events "events-fixture")))