forked from DGNum/liminix
pass command line params to run instead of reffing global
This commit is contained in:
parent
725af00dc9
commit
570d29c368
2 changed files with 8 additions and 11 deletions
|
@ -32,18 +32,19 @@
|
||||||
{})]
|
{})]
|
||||||
(. got params.expecting)))
|
(. got params.expecting)))
|
||||||
|
|
||||||
(fn run [event-fn]
|
(fn run [args event-fn]
|
||||||
(let [parameters
|
(let [parameters
|
||||||
(assert (parse-args arg)
|
(assert (parse-args args)
|
||||||
(.. "Usage: " (. arg 0) " [-v] ifname [present|up|running]"))]
|
(.. "Usage: ifwait [-v] ifname [present|up|running]"))]
|
||||||
(when parameters.verbose
|
(when parameters.verbose
|
||||||
(print (.. (. arg 0) ": waiting for "
|
(print (.. "ifwait: waiting for "
|
||||||
parameters.link " to be " parameters.expecting)))
|
parameters.link " to be " parameters.expecting)))
|
||||||
|
|
||||||
(each [e (event-fn)
|
(each [e (event-fn)
|
||||||
&until (run-event parameters e)]
|
&until (run-event parameters e)]
|
||||||
true)))
|
true)))
|
||||||
|
|
||||||
(when (not (= (. arg 0) "test")) (run #(nl.events {:link true})))
|
(when (not (= (. arg 0) "test"))
|
||||||
|
(run arg #(nl.events {:link true})))
|
||||||
|
|
||||||
{ : run }
|
{ : run }
|
||||||
|
|
|
@ -11,15 +11,11 @@
|
||||||
(icollect [_ ast parse]
|
(icollect [_ ast parse]
|
||||||
ast)))
|
ast)))
|
||||||
|
|
||||||
|
(set _G.arg (doto [] (tset 0 "test")))
|
||||||
(set _G.arg (doto ["-v" "dummy0" "up"] (tset 0 "test")))
|
|
||||||
|
|
||||||
(local ifwait (require :ifwait))
|
(local ifwait (require :ifwait))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(let [gen (event-generator (file-events "events-fixture"))]
|
(let [gen (event-generator (file-events "events-fixture"))]
|
||||||
(ifwait.run #gen)
|
(ifwait.run ["-v" "dummy0" "up"] #gen)
|
||||||
(match (pcall gen)
|
(match (pcall gen)
|
||||||
(true _) true
|
(true _) true
|
||||||
(false msg) (error "didn't detect dummy0 up event")))
|
(false msg) (error "didn't detect dummy0 up event")))
|
||||||
|
|
Loading…
Reference in a new issue