forked from DGNum/liminix
clean up uevent-watch test using writeFennel and mainFunction
requires less cavorting with globals and stuff
This commit is contained in:
parent
771585546d
commit
450d3820b2
3 changed files with 13 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
lua
|
||||
, nellie
|
||||
, writeFennelScript
|
||||
, writeFennel
|
||||
, runCommand
|
||||
, anoia
|
||||
, fennel
|
||||
|
@ -14,7 +14,10 @@ stdenv.mkDerivation {
|
|||
nativeBuildInputs = [ fennelrepl ];
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp -p ${writeFennelScript "uevent-watch" [fennel anoia nellie lua.pkgs.luafilesystem] ./watch.fnl} $out/bin/uevent-watch
|
||||
cp -p ${writeFennel "uevent-watch" {
|
||||
packages = [fennel anoia nellie lua.pkgs.luafilesystem];
|
||||
mainFunction = "run";
|
||||
} ./watch.fnl} $out/bin/uevent-watch
|
||||
'';
|
||||
checkPhase = ''
|
||||
fennelrepl ./test.fnl
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
(local { : view} (require :fennel))
|
||||
(import-macros { : expect= } :anoia.assert)
|
||||
|
||||
(set _G.arg (doto [] (tset 0 "test")))
|
||||
(local subject (require :watch))
|
||||
|
||||
(let [params
|
||||
|
@ -35,7 +34,9 @@
|
|||
|
||||
;; this tests event parsing but not whether anything
|
||||
;; happens as a result of processing them
|
||||
(subject.run
|
||||
["-s" "foo" "-n" (os.getenv "TMPDIR") "partname=backup-disk" ]
|
||||
(subject.run-with-fh
|
||||
{ :read (next-event) }
|
||||
["-s" "foo" "-n" (os.getenv "TMPDIR") "partname=backup-disk" ]
|
||||
)
|
||||
|
||||
(print "OK")
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
"(%g-)=(%g+)")]
|
||||
(k:lower) v))))
|
||||
|
||||
(fn run [args fh]
|
||||
(fn run-with-fh [fh args]
|
||||
(set up :unknown)
|
||||
(let [parameters
|
||||
(assert (parse-args args) (.. "can't parse args: " (table.concat args " ")))]
|
||||
|
@ -62,9 +62,9 @@
|
|||
(set finished? (= e nil))
|
||||
))))
|
||||
|
||||
(when (not (= (. arg 0) "test"))
|
||||
(fn run [args]
|
||||
(let [nellie (require :nellie)
|
||||
netlink (nellie.open 4)]
|
||||
(run arg netlink)))
|
||||
(run-with-fh netlink arg)))
|
||||
|
||||
{ : run : event-matches? }
|
||||
{ : run : run-with-fh : event-matches? }
|
||||
|
|
Loading…
Reference in a new issue