remove hardcoded filename in test event generator
This commit is contained in:
parent
7173b6fb1c
commit
e1b932ec27
1 changed files with 13 additions and 7 deletions
|
@ -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")))
|
||||
|
|
Loading…
Reference in a new issue