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