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="
set global autoreload yes
try %{
source rc
source rc
}
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 %{
exec gg
exec gg
}
exec '$(cat cmd | sed -e s/\'/\\\\\'/g)'
eval -buffer *debug* write debug
nop %sh{ IFS==
echo \"\$kak_selections\" > selections
echo \"\$kak_selections_desc\" > state
nop %sh{
IFS==
echo \"\$kak_selections\" > selections
echo \"\$kak_selections_desc\" > state
}
write out
quit!
@ -55,7 +56,12 @@ main() {
echo
diff -u $test/$dir/$expect $expect | while read -r line; do
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
done
echo
@ -79,27 +85,6 @@ main() {
# 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() {
color_name=${1:-none}
style_name=${2:-none}