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
|
lua
|
||||||
, nellie
|
, nellie
|
||||||
, writeFennelScript
|
, writeFennel
|
||||||
, runCommand
|
, runCommand
|
||||||
, anoia
|
, anoia
|
||||||
, fennel
|
, fennel
|
||||||
|
@ -14,7 +14,10 @@ stdenv.mkDerivation {
|
||||||
nativeBuildInputs = [ fennelrepl ];
|
nativeBuildInputs = [ fennelrepl ];
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
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 = ''
|
checkPhase = ''
|
||||||
fennelrepl ./test.fnl
|
fennelrepl ./test.fnl
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
(local { : view} (require :fennel))
|
(local { : view} (require :fennel))
|
||||||
(import-macros { : expect= } :anoia.assert)
|
(import-macros { : expect= } :anoia.assert)
|
||||||
|
|
||||||
(set _G.arg (doto [] (tset 0 "test")))
|
|
||||||
(local subject (require :watch))
|
(local subject (require :watch))
|
||||||
|
|
||||||
(let [params
|
(let [params
|
||||||
|
@ -35,7 +34,9 @@
|
||||||
|
|
||||||
;; this tests event parsing but not whether anything
|
;; this tests event parsing but not whether anything
|
||||||
;; happens as a result of processing them
|
;; happens as a result of processing them
|
||||||
(subject.run
|
(subject.run-with-fh
|
||||||
["-s" "foo" "-n" (os.getenv "TMPDIR") "partname=backup-disk" ]
|
|
||||||
{ :read (next-event) }
|
{ :read (next-event) }
|
||||||
|
["-s" "foo" "-n" (os.getenv "TMPDIR") "partname=backup-disk" ]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(print "OK")
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
"(%g-)=(%g+)")]
|
"(%g-)=(%g+)")]
|
||||||
(k:lower) v))))
|
(k:lower) v))))
|
||||||
|
|
||||||
(fn run [args fh]
|
(fn run-with-fh [fh args]
|
||||||
(set up :unknown)
|
(set up :unknown)
|
||||||
(let [parameters
|
(let [parameters
|
||||||
(assert (parse-args args) (.. "can't parse args: " (table.concat args " ")))]
|
(assert (parse-args args) (.. "can't parse args: " (table.concat args " ")))]
|
||||||
|
@ -62,9 +62,9 @@
|
||||||
(set finished? (= e nil))
|
(set finished? (= e nil))
|
||||||
))))
|
))))
|
||||||
|
|
||||||
(when (not (= (. arg 0) "test"))
|
(fn run [args]
|
||||||
(let [nellie (require :nellie)
|
(let [nellie (require :nellie)
|
||||||
netlink (nellie.open 4)]
|
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