ifwait: don't run on load if in test harness

This commit is contained in:
Daniel Barlow 2024-03-05 17:56:59 +00:00
parent 38ed91f641
commit 0787807a7f
2 changed files with 17 additions and 10 deletions

View file

@ -33,7 +33,8 @@
(when (. got params.expecting)
(os.exit 0))))
(let [parameters
(fn run []
(let [parameters
(assert (parse-args arg)
(.. "Usage: " (. arg 0) " [-v] ifname [present|up|running]"))]
(when parameters.verbose
@ -41,4 +42,8 @@
parameters.link " to be " parameters.expecting)))
(each [event (nl.events {:link true})]
(run-event parameters event)))
(run-event parameters event))))
(when (not (= (. arg 0) "test")) (run))
{ : run }

View file

@ -11,6 +11,8 @@
(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)