2024-01-03 03:07:39 +00:00
|
|
|
{
|
|
|
|
describe,
|
|
|
|
it,
|
|
|
|
...
|
|
|
|
}: let
|
2024-01-03 01:27:47 +00:00
|
|
|
mockpkgs = {
|
|
|
|
writeShellScriptBin = name: content: content;
|
|
|
|
inotify-tools = "inotify-tools";
|
|
|
|
};
|
|
|
|
watch = import ../tix/watch.nix mockpkgs;
|
|
|
|
in
|
2024-01-03 03:07:39 +00:00
|
|
|
describe "watch" [
|
|
|
|
(it "watches a the local directory and runs command on change" {
|
|
|
|
actual = watch {
|
|
|
|
cmd = "run me";
|
|
|
|
};
|
|
|
|
expected = ''
|
|
|
|
while true
|
|
|
|
do
|
|
|
|
run me &
|
|
|
|
inotify-tools/bin/inotifywait -e modify -r .
|
|
|
|
${""}
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
(it "runs the command provided to stop execution" {
|
|
|
|
actual = watch {
|
|
|
|
cmd = "run me";
|
|
|
|
stop = "kill me";
|
|
|
|
};
|
|
|
|
expected = ''
|
|
|
|
while true
|
|
|
|
do
|
|
|
|
run me &
|
|
|
|
inotify-tools/bin/inotifywait -e modify -r .
|
|
|
|
kill me
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
(it "pipes output to given command" {
|
|
|
|
actual = watch {
|
|
|
|
cmd = "run me";
|
|
|
|
stop = "kill me";
|
|
|
|
view = "less";
|
|
|
|
};
|
|
|
|
expected = ''
|
|
|
|
while true
|
|
|
|
do
|
|
|
|
run me | less &
|
|
|
|
inotify-tools/bin/inotifywait -e modify -r .
|
|
|
|
kill me
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
]
|