1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-24 12:02:15 +03:00

Optimize the test run script

This commit is contained in:
Maxime Coste 2014-10-28 23:28:10 +00:00
parent d29419bcd6
commit ec09fc3a75

View File

@ -14,9 +14,9 @@ main() {
cd $test/$dir; cd $test/$dir;
test_files=$(find * -name out -o -name selections -o -name state) test_files=$(find * -name out -o -name selections -o -name state)
cd $work/$dir; cd $work/$dir;
indent="$(repeat ' ' $(pwd | sed "s|$test||" | tr -d -c / | awk '{ print length }'))" indent="$(echo "${dir}/" | sed "s|[^/]*/\+| |g")"
name=$(basename $PWD) name=$(basename $PWD)
if ! exists cmd; then if ! test -e cmd; then
echo "$indent$name" echo "$indent$name"
else else
number_tests=$(($number_tests + 1)) number_tests=$(($number_tests + 1))
@ -27,12 +27,12 @@ main() {
source rc source rc
} }
try %{ try %{
exec '%s%[(](.+?)[)]<ret>i<del><del><esc>a<backspace><c-u><esc>' exec '%s%\((.+?)\)<ret>i<del><del><esc>a<backspace><c-u><esc>'
} \ } \
catch %{ catch %{
exec gg exec gg
} }
exec '$(<cmd)' exec '$(cat cmd)'
eval -buffer *debug* write debug eval -buffer *debug* write debug
nop %sh{ IFS== nop %sh{ IFS==
echo \"\$kak_selections\" > selections echo \"\$kak_selections\" > selections
@ -42,7 +42,6 @@ main() {
quit! quit!
" "
kak out -n -e "$kak_commands" kak out -n -e "$kak_commands"
IFS=$'\n'
for expect in $test_files; do for expect in $test_files; do
if cmp -s $test/$dir/$expect $expect; then if cmp -s $test/$dir/$expect $expect; then
echo "$indent$name" | colorize green normal echo "$indent$name" | colorize green normal
@ -50,9 +49,7 @@ main() {
number_failures=$(($number_failures + 1)) number_failures=$(($number_failures + 1))
echo "$indent$name" | colorize red normal echo "$indent$name" | colorize red normal
echo echo
IFS=$'\n' diff -u $test/$dir/$expect $expect | while read -r line; do
for line in $(diff -u $test/$dir/$expect $expect); do
IFS=¬
first_character=$(echo "$line" | cut -b 1) first_character=$(echo "$line" | cut -b 1)
color=$(match $first_character + green - red @ magenta none) color=$(match $first_character + green - red @ magenta none)
echo "$line" | colorize $color normal echo "$line" | colorize $color normal
@ -98,40 +95,30 @@ match() {
done done
} }
repeat() {
text=$1
count=${2:-0}
echo $(yes $text | head -n $count | join)
}
join() {
tr -d "\n"
}
exists() {
test -e $@
}
get_ansi_code() { get_ansi_code() {
color_name=${1:-none} color_name=${1:-none}
style_name=${2:-none} style_name=${2:-none}
color='none 00 case "$color_name" in
red 31 none) color_nr=00 ;;
green 32 red) color_nr=31 ;;
yellow 33 green) color_nr=32 ;;
magenta 35' yellow) color_nr=33 ;;
style='none 00 magenta) color_nr=35 ;;
bold 01' *) color_nr=00 ;;
color_nr=$(echo "$color" | awk "/$color_name/ { print \$2 }") esac
style_nr=$(echo "$style" | awk "/$style_name/ { print \$2 }") case "$style_name" in
echo '\e[STYLE_NR;COLOR_NRm' | sed s/COLOR_NR/$color_nr/';'s/STYLE_NR/$style_nr/ none) style_nr=00 ;;
bold) style_nr=01 ;;
*) style_nr=00 ;;
esac
printf '\033[%s;%sm' $style_nr $color_nr
} }
colorize() { colorize() {
text=$(cat) text=$(cat)
color_name=${1:-none} color_name=${1:-none}
style_name=${2:-none} style_name=${2:-none}
printf "$(get_ansi_code $color_name $style_name)$text$(get_ansi_code none none)\n" echo "$(get_ansi_code $color_name $style_name)$text$(get_ansi_code none none)"
} }