bat-extras/test/suite/batwatch.sh
Alissa Huskey 4c09718a46 batwatch changes to reveal a bug and add --help
- Add `-h` and `--help` flags to print out basic usage.
- Refactor determine_stat_variant so that it checks to make sure the
value from `stat` is a epoch timestamp, and exit noisily if it is not.
- Change `determine_watcher` to set the `OPT_WATCHER` global directory
directly instead of echoing it then being called from a subshell. There
was an errror that the subshell was obscuring.
- Add a test to reflect the bug.
2020-07-06 17:36:03 -07:00

33 lines
612 B
Bash

#!/bin/bash
setup() {
use_shim 'batwatch'
}
test:version() {
description "Test 'batwatch --version'"
snapshot stdout
snapshot stderr
batwatch --version | awk 'FNR <= 1 { print $1 }'
batwatch --version | awk 'p{print} /^$/ { p=1 }'
}
test:help() {
description "Test 'batwatch --help'"
snapshot stdout
batwatch --help
assert batwatch --help
batwatch --help | grep -q 'Usage'
}
test:watcher() {
description "Test 'batwatch <file>'"
fail "No longer fails silently due to incorrect flag to stat."
# Refactored to get here, but when it passes it will loop forever.
assert batwatch $0
}