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))
|
(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")))
|
||||||
|
|
Loading…
Reference in a new issue