test watch, split commands
This commit is contained in:
parent
6b84ecb806
commit
d146127911
3 changed files with 65 additions and 4 deletions
52
test/watch.test.nix
Normal file
52
test/watch.test.nix
Normal file
|
@ -0,0 +1,52 @@
|
|||
{describe, it, ... }:
|
||||
let
|
||||
mockpkgs = {
|
||||
writeShellScriptBin = name: content: content;
|
||||
inotify-tools = "inotify-tools";
|
||||
};
|
||||
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
|
||||
'';
|
||||
}))
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue