2024-03-05 00:06:03 +01:00
|
|
|
(local fennel (require :fennel))
|
|
|
|
|
2024-03-05 23:57:20 +01:00
|
|
|
(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"))
|
2024-03-05 00:06:03 +01:00
|
|
|
parse (fennel.parser data)]
|
2024-03-05 23:57:20 +01:00
|
|
|
(icollect [_ ast parse]
|
|
|
|
ast)))
|
|
|
|
|
2024-03-05 00:06:03 +01:00
|
|
|
|
2024-03-05 18:56:59 +01:00
|
|
|
(set _G.arg (doto ["-v" "dummy0" "up"] (tset 0 "test")))
|
2024-03-05 00:06:03 +01:00
|
|
|
|
2024-03-05 18:56:59 +01:00
|
|
|
(local ifwait (require :ifwait))
|
|
|
|
|
2024-03-05 23:57:20 +01:00
|
|
|
|
|
|
|
|
2024-03-06 00:22:46 +01:00
|
|
|
(let [gen (event-generator (file-events "events-fixture"))]
|
|
|
|
(ifwait.run #gen)
|
|
|
|
(match (pcall gen)
|
|
|
|
(true _) true
|
|
|
|
(false msg) (error "didn't detect dummy0 up event")))
|