Code cleanup in the test running script

This commit is contained in:
Maxime Coste 2015-10-17 11:32:32 +01:00
parent 76fadd8108
commit 832e9155fa

View File

@ -24,19 +24,20 @@ main() {
kak_commands=" kak_commands="
set global autoreload yes set global autoreload yes
try %{ try %{
source rc source rc
} }
try %{ try %{
exec '%s%\(\K[^)]+<ret><c-s>ld<a-t>(hHdi<c-u><esc><c-o>' exec '%s%\(\K[^)]+<ret><c-s>ld<a-t>(hHdi<c-u><esc><c-o>'
} \ } \
catch %{ catch %{
exec gg exec gg
} }
exec '$(cat cmd | sed -e s/\'/\\\\\'/g)' exec '$(cat cmd | sed -e s/\'/\\\\\'/g)'
eval -buffer *debug* write debug eval -buffer *debug* write debug
nop %sh{ IFS== nop %sh{
echo \"\$kak_selections\" > selections IFS==
echo \"\$kak_selections_desc\" > state echo \"\$kak_selections\" > selections
echo \"\$kak_selections_desc\" > state
} }
write out write out
quit! quit!
@ -55,7 +56,12 @@ main() {
echo echo
diff -u $test/$dir/$expect $expect | while read -r line; do diff -u $test/$dir/$expect $expect | while read -r line; do
first_character=$(echo "$line" | cut -b 1) first_character=$(echo "$line" | cut -b 1)
color=$(match $first_character + green - red @ magenta none) case $first_character in
+) color=green ;;
-) color=red ;;
@) color=magenta ;;
*) color=none ;;
esac
echo "$line" | colorize $color normal echo "$line" | colorize $color normal
done done
echo echo
@ -79,27 +85,6 @@ main() {
# Utility ├───────────────────────────────────────────────────────────────────── # Utility ├─────────────────────────────────────────────────────────────────────
match() {
expression="$1";
shift
while [ $# > 0 ]; do
pattern="$1"
shift
value="$1"
next="$1"
default_value="$pattern"
if [ -z "$next" ]; then
echo $default_value
return 1
fi
if [ "$expression" = "$pattern" ]; then
echo "$value"
return 0
fi
shift
done
}
get_ansi_code() { get_ansi_code() {
color_name=${1:-none} color_name=${1:-none}
style_name=${2:-none} style_name=${2:-none}