mirror of
https://github.com/eth-p/bat-extras.git
synced 2024-11-07 16:24:06 +01:00
Add skip for batgrep tests if ripgrep is not installed
This commit is contained in:
parent
b08128e550
commit
b72a495de1
24
build.sh
24
build.sh
@ -317,22 +317,36 @@ if "$OPT_VERIFY"; then
|
||||
|
||||
# Run the tests.
|
||||
FAIL=0
|
||||
SKIP=0
|
||||
while read -r action data1 data2 splat; do
|
||||
[[ "$action" == "result" ]] || continue
|
||||
|
||||
printf "\x1B[G\x1B[K%s" "$data1" 1>&2
|
||||
if [[ "$data2" == "fail" ]]; then
|
||||
printf " failed.\n" 1>&2
|
||||
((FAIL++)) || true
|
||||
fi
|
||||
case "$data2" in
|
||||
fail)
|
||||
printf " failed.\n" 1>&2
|
||||
((FAIL++)) || true
|
||||
;;
|
||||
|
||||
skip)
|
||||
((SKIP++)) || true
|
||||
;;
|
||||
esac
|
||||
done < <("${HERE}/test.sh" --compiled --porcelain)
|
||||
|
||||
# Print the overall result.
|
||||
printf "\x1B[G\x1B[K%s" 1>&2
|
||||
|
||||
if [[ "$FAIL" -ne 0 ]]; then
|
||||
printc "%{RED}One or more tests failed.\n" 1>&2
|
||||
printc "Run ./test.sh for more detailed information.%{CLEAR}\n" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printc "\x1B[G\x1B[K%{YELLOW}Verified successfully.%{CLEAR}\n" 1>&2
|
||||
if [[ "$SKIP" -gt 0 ]]; then
|
||||
printc "%{CYAN}One or more tests were skipped.\n" 1>&2
|
||||
printc "Run ./test.sh for more detailed information.%{CLEAR}\n" 1>&2
|
||||
fi
|
||||
|
||||
printc "%{YELLOW}Verified successfully.%{CLEAR}\n" 1>&2
|
||||
fi
|
||||
|
@ -1,5 +1,17 @@
|
||||
HAS_RIPGREP=false
|
||||
|
||||
setup() {
|
||||
use_shim 'batgrep'
|
||||
|
||||
if command -v rg &>/dev/null; then
|
||||
HAS_RIPGREP=true
|
||||
fi
|
||||
}
|
||||
|
||||
require_rg() {
|
||||
if ! "$HAS_RIPGREP"; then
|
||||
skip "Ripgrep (rg) is not installed."
|
||||
fi
|
||||
}
|
||||
|
||||
test:regular_file() {
|
||||
@ -7,6 +19,8 @@ test:regular_file() {
|
||||
snapshot stdout
|
||||
snapshot stderr
|
||||
|
||||
require_rg
|
||||
|
||||
batgrep "ca" file.txt
|
||||
}
|
||||
|
||||
@ -15,6 +29,8 @@ test:symlink_file() {
|
||||
snapshot stdout
|
||||
snapshot stderr
|
||||
|
||||
require_rg
|
||||
|
||||
batgrep "ca" link.txt
|
||||
}
|
||||
|
||||
@ -23,6 +39,8 @@ test:output_with_color() {
|
||||
snapshot stdout
|
||||
snapshot stderr
|
||||
|
||||
require_rg
|
||||
|
||||
batgrep "ca" file.txt --color=always
|
||||
}
|
||||
|
||||
@ -31,6 +49,8 @@ test:output_without_color() {
|
||||
snapshot stdout
|
||||
snapshot stderr
|
||||
|
||||
require_rg
|
||||
|
||||
batgrep "ca" file.txt --color=never
|
||||
}
|
||||
|
||||
@ -39,6 +59,8 @@ test:search_regex() {
|
||||
snapshot stdout
|
||||
snapshot stderr
|
||||
|
||||
require_rg
|
||||
|
||||
batgrep "^[cb]" file.txt
|
||||
}
|
||||
|
||||
@ -47,6 +69,8 @@ test:search_fixed() {
|
||||
snapshot stdout
|
||||
snapshot stderr
|
||||
|
||||
require_rg
|
||||
|
||||
batgrep --fixed-strings '$' file.txt
|
||||
}
|
||||
|
||||
@ -55,5 +79,7 @@ test:option_context() {
|
||||
snapshot stdout
|
||||
snapshot stderr
|
||||
|
||||
require_rg
|
||||
|
||||
batgrep -C 0 '\$' file.txt
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user