ifwait: don't run on load if in test harness
This commit is contained in:
parent
38ed91f641
commit
0787807a7f
2 changed files with 17 additions and 10 deletions
|
@ -33,12 +33,17 @@
|
||||||
(when (. got params.expecting)
|
(when (. got params.expecting)
|
||||||
(os.exit 0))))
|
(os.exit 0))))
|
||||||
|
|
||||||
(let [parameters
|
(fn run []
|
||||||
(assert (parse-args arg)
|
(let [parameters
|
||||||
(.. "Usage: " (. arg 0) " [-v] ifname [present|up|running]"))]
|
(assert (parse-args arg)
|
||||||
(when parameters.verbose
|
(.. "Usage: " (. arg 0) " [-v] ifname [present|up|running]"))]
|
||||||
(print (.. (. arg 0) ": waiting for "
|
(when parameters.verbose
|
||||||
parameters.link " to be " parameters.expecting)))
|
(print (.. (. arg 0) ": waiting for "
|
||||||
|
parameters.link " to be " parameters.expecting)))
|
||||||
|
|
||||||
(each [event (nl.events {:link true})]
|
(each [event (nl.events {:link true})]
|
||||||
(run-event parameters event)))
|
(run-event parameters event))))
|
||||||
|
|
||||||
|
(when (not (= (. arg 0) "test")) (run))
|
||||||
|
|
||||||
|
{ : run }
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
(tset package.loaded :anoia.nl { :events events })
|
(tset package.loaded :anoia.nl { :events events })
|
||||||
|
|
||||||
(set _G.arg (doto ["-v" "dummy0" "up"] (tset 0 "ifwait")))
|
(set _G.arg (doto ["-v" "dummy0" "up"] (tset 0 "test")))
|
||||||
|
|
||||||
(fennel.dofile "ifwait.fnl" { :correlate true })
|
(local ifwait (require :ifwait))
|
||||||
|
|
||||||
|
(ifwait.run)
|
||||||
|
|
Loading…
Reference in a new issue