rework watch command

This commit is contained in:
Tristan 2024-01-03 06:47:16 +00:00
parent 4f6c21ec77
commit 3faf0e6354
6 changed files with 32 additions and 61 deletions

View file

@ -10,46 +10,10 @@
watch = import ../tix/watch.nix mockpkgs;
in
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
'';
(it "contains the command" {
actual = builtins.match ".*(run me).*" ( watch {
cmd = "run me";
} );
expected = ["run me"];
})
]