From 832e9155fa95b7f98d3ce42e64b888588c1de8aa Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 17 Oct 2015 11:32:32 +0100 Subject: [PATCH] Code cleanup in the test running script --- test/run | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/test/run b/test/run index 9905583e..a1c2ec60 100755 --- a/test/run +++ b/test/run @@ -24,19 +24,20 @@ main() { kak_commands=" set global autoreload yes try %{ - source rc + source rc } try %{ - exec '%s%\(\K[^)]+ld(hHdi' + exec '%s%\(\K[^)]+ld(hHdi' } \ 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}