mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-06-20 19:57:46 +02: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.
|
# Run the tests.
|
||||||
FAIL=0
|
FAIL=0
|
||||||
|
SKIP=0
|
||||||
while read -r action data1 data2 splat; do
|
while read -r action data1 data2 splat; do
|
||||||
[[ "$action" == "result" ]] || continue
|
[[ "$action" == "result" ]] || continue
|
||||||
|
|
||||||
printf "\x1B[G\x1B[K%s" "$data1" 1>&2
|
printf "\x1B[G\x1B[K%s" "$data1" 1>&2
|
||||||
if [[ "$data2" == "fail" ]]; then
|
case "$data2" in
|
||||||
printf " failed.\n" 1>&2
|
fail)
|
||||||
((FAIL++)) || true
|
printf " failed.\n" 1>&2
|
||||||
fi
|
((FAIL++)) || true
|
||||||
|
;;
|
||||||
|
|
||||||
|
skip)
|
||||||
|
((SKIP++)) || true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
done < <("${HERE}/test.sh" --compiled --porcelain)
|
done < <("${HERE}/test.sh" --compiled --porcelain)
|
||||||
|
|
||||||
# Print the overall result.
|
# Print the overall result.
|
||||||
|
printf "\x1B[G\x1B[K%s" 1>&2
|
||||||
|
|
||||||
if [[ "$FAIL" -ne 0 ]]; then
|
if [[ "$FAIL" -ne 0 ]]; then
|
||||||
printc "%{RED}One or more tests failed.\n" 1>&2
|
printc "%{RED}One or more tests failed.\n" 1>&2
|
||||||
printc "Run ./test.sh for more detailed information.%{CLEAR}\n" 1>&2
|
printc "Run ./test.sh for more detailed information.%{CLEAR}\n" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
fi
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
|
HAS_RIPGREP=false
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
use_shim 'batgrep'
|
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() {
|
test:regular_file() {
|
||||||
@ -7,6 +19,8 @@ test:regular_file() {
|
|||||||
snapshot stdout
|
snapshot stdout
|
||||||
snapshot stderr
|
snapshot stderr
|
||||||
|
|
||||||
|
require_rg
|
||||||
|
|
||||||
batgrep "ca" file.txt
|
batgrep "ca" file.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,6 +29,8 @@ test:symlink_file() {
|
|||||||
snapshot stdout
|
snapshot stdout
|
||||||
snapshot stderr
|
snapshot stderr
|
||||||
|
|
||||||
|
require_rg
|
||||||
|
|
||||||
batgrep "ca" link.txt
|
batgrep "ca" link.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,6 +39,8 @@ test:output_with_color() {
|
|||||||
snapshot stdout
|
snapshot stdout
|
||||||
snapshot stderr
|
snapshot stderr
|
||||||
|
|
||||||
|
require_rg
|
||||||
|
|
||||||
batgrep "ca" file.txt --color=always
|
batgrep "ca" file.txt --color=always
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +49,8 @@ test:output_without_color() {
|
|||||||
snapshot stdout
|
snapshot stdout
|
||||||
snapshot stderr
|
snapshot stderr
|
||||||
|
|
||||||
|
require_rg
|
||||||
|
|
||||||
batgrep "ca" file.txt --color=never
|
batgrep "ca" file.txt --color=never
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,6 +59,8 @@ test:search_regex() {
|
|||||||
snapshot stdout
|
snapshot stdout
|
||||||
snapshot stderr
|
snapshot stderr
|
||||||
|
|
||||||
|
require_rg
|
||||||
|
|
||||||
batgrep "^[cb]" file.txt
|
batgrep "^[cb]" file.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +69,8 @@ test:search_fixed() {
|
|||||||
snapshot stdout
|
snapshot stdout
|
||||||
snapshot stderr
|
snapshot stderr
|
||||||
|
|
||||||
|
require_rg
|
||||||
|
|
||||||
batgrep --fixed-strings '$' file.txt
|
batgrep --fixed-strings '$' file.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,5 +79,7 @@ test:option_context() {
|
|||||||
snapshot stdout
|
snapshot stdout
|
||||||
snapshot stderr
|
snapshot stderr
|
||||||
|
|
||||||
|
require_rg
|
||||||
|
|
||||||
batgrep -C 0 '\$' file.txt
|
batgrep -C 0 '\$' file.txt
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user