-
Notifications
You must be signed in to change notification settings - Fork 3
/
tests
executable file
·86 lines (74 loc) · 1.77 KB
/
tests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env bash
source ./just-colors > /dev/null
PATH_PREFIX="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
CACHE_PATH=$PATH_PREFIX/cache
TEMPLATE_PATH=$PATH_PREFIX/templates
THEMES_PATH=$PATH_PREFIX/themes
TOTAL_TESTS=0
PASSED_TESTS=0
PATH_TEMPLATES_FOR_TEST=$PATH_PREFIX/templates_for_test
assert() {
TOTAL_TESTS=`expr $TOTAL_TESTS + 1`
arg_1=$1
arg_2=$2
message=$3
case $# in
3)
if [[ $arg_1 == $arg_2 ]]; then
print_log ok $message
PASSED_TESTS=`expr $PASSED_TESTS + 1`
else
print_log error "$arg_1 and $arg_2 is not equal"
fi;;
esac
}
clean_up() {
local files_for_del=$(ls $PATH_TEMPLATES_FOR_TEST/*.cache)
[[ "$files_for_del" ]] && rm $files_for_del
}
base00="181818"
base01="282828"
base02="383838"
base03="585858"
base04="b8b8b8"
base05="d8d8d8"
base06="e8e8e8"
base07="f8f8f8"
base08="ab4642"
base09="dc9656"
base0A="f7ca88"
base0B="a1b56c"
base0C="86c1b9"
base0D="7cafc2"
base0E="ba8baf"
base0F="a16946"
test_parse_theme_get_value() {
parse_theme $THEMES_PATH/default-dark.$THEME_EXT
for number in $(echo {0..9} {A..F}); do
name_of_var="base0${number}"
get_value ${name_of_var}
assert "$RETURN_GET_VALUE" "${!name_of_var}" "$name_of_var"
done
}
test_build_template() {
for template in $(ls $PATH_TEMPLATES_FOR_TEST/*.template); do
solution=${template%.template}.solution
cache=${template%.template}.cache
build_template $template $cache
assert "$(diff $solution $cache)" "" "$template"
done
}
test_all() {
echo "test parse_theme and get_value"
test_parse_theme_get_value
echo "test build_template"
test_build_template
}
test_all
clean_up
echo Total tests: $TOTAL_TESTS
echo Passed tests: $PASSED_TESTS
if [[ $TOTAL_TESTS == $PASSED_TESTS ]]; then
exit 0
fi
exit 1