2
2
3
3
# Run Clojure.vim indentation tests.
4
4
5
- # TODO: colour messages?
5
+ # TODO: option to enable/disable (Lua / Vim9script) versions.
6
+
7
+ C_GREEN=' \033[1;32m'
8
+ C_RED=' \033[1;31m'
9
+ C_YELLOW=' \033[1;33m'
10
+ C_BLUE=' \033[1;34m'
11
+ C_RESET=' \033[0m'
12
+
13
+ log () { printf " $* $C_RESET \n" ; }
14
+ logc () { log " $1$2 " ; }
15
+ succ () { logc " $C_GREEN " " $* " ; }
16
+ warn () { logc " $C_YELLOW " " $* " ; }
17
+ err () { logc " $C_RED " " $* " ; }
18
+ info () { logc " $C_BLUE " " $* " ; }
19
+ abort () { err " ABORT: $* " ; exit 1; }
6
20
7
21
pushd " $( dirname " $0 " ) /.."
8
22
9
23
if [ " $EDITOR " != ' vim' ] && [ " $EDITOR " != ' nvim' ]; then
10
- echo ' ERROR: Set the "EDITOR" environment variable to "vim" or "nvim" and run again.'
11
- exit 1
24
+ abort ' Set the "EDITOR" environment variable to "vim" or "nvim" and run again.'
12
25
fi
13
26
14
27
extra_opts=()
@@ -23,24 +36,22 @@ mkdir -p "$tmp_base_dir"
23
36
tmp_dir=" $( mktemp --directory " $tmp_base_dir /XXXXXX" ) "
24
37
test_case_dir=' tests'
25
38
26
- test_pass () { PASSED+=(" $1 " ); echo ' ::endgroup:: ' ; }
39
+ test_pass () { PASSED+=(" $1 " ); }
27
40
test_fail () {
28
41
FAILED+=(" $1 " )
29
- echo ' ::endgroup::'
30
- echo " ::error file=dev/$test_case_dir /$1 /out.clj::Failed indent test case."
42
+ err " ::error file=dev/$test_case_dir /$1 /out.clj::Failed indent test case."
31
43
}
32
44
test_skip () {
33
45
SKIPPED+=(" $1 " )
34
- echo ' ::endgroup::'
35
- echo " ::warning file=dev/$test_case_dir /$1 /out.clj::Skipped indent test case."
46
+ warn " ::warning file=dev/$test_case_dir /$1 /out.clj::Skipped indent test case."
36
47
}
37
48
38
49
run_test_case () {
39
50
test_case=" $1 "
40
51
in_file=" $test_case_dir /$test_case /in.clj"
41
52
expected_file=" $test_case_dir /$test_case /out.clj"
42
53
43
- echo " ::group:: $EDITOR : $test_case "
54
+ info " > $EDITOR : $test_case "
44
55
45
56
if [ -f " $test_case_dir /$test_case /SKIP" ]; then
46
57
test_skip " $test_case "
@@ -56,7 +67,8 @@ run_test_case() {
56
67
test_cmd=(' +normal! gg=G' )
57
68
fi
58
69
59
- " $EDITOR " " ${extra_opts[@]} " --clean -EsNXnu test-vimrc.vim " ${test_cmd[@]} " ' +xall!' -- " $actual_file "
70
+ " $EDITOR " " ${extra_opts[@]} " --clean -EsNXnu test-vimrc.vim \
71
+ " ${test_cmd[@]} " ' +xall!' -- " $actual_file "
60
72
61
73
diff --color=always -u " $expected_file " " $actual_file "
62
74
@@ -68,9 +80,10 @@ for tcase in $test_case_dir/*/; do
68
80
run_test_case " $( basename " $tcase " ) "
69
81
done
70
82
71
- echo " passed: ${# PASSED[@]} , failed: ${# FAILED[@]} , skipped: ${# SKIPPED[@]} "
83
+ printf " passed: $C_GREEN %s$C_RESET , failed: $C_RED %s$C_RESET , skipped: $C_YELLOW %s$C_RESET \n" \
84
+ " ${# PASSED[@]} " " ${# FAILED[@]} " " ${# SKIPPED[@]} "
72
85
73
86
# If none passed, or some failed, exit with error.
74
87
if [ ${# PASSED[@]} -eq 0 ] || [ ${# FAILED[@]} -gt 0 ]; then
75
- exit 1
88
+ abort ' Failed test cases. '
76
89
fi
0 commit comments