-
Notifications
You must be signed in to change notification settings - Fork 11
/
tests.sh
executable file
·72 lines (64 loc) · 1.42 KB
/
tests.sh
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
#!/bin/bash
jsonnet_fmt='-n 2 --max-blank-lines 2 --sort-imports --string-style s --comment-style s'
x=0
for i in `find ./dashboard ./tests -name '*.jsonnet' -or -name '*.libsonnet'`
do
t="Formatting $i..."
if [[ "$1" == "update" ]]; then
jsonnetfmt -i $jsonnet_fmt $i
fi
if jsonnetfmt --test $jsonnet_fmt $i;
then
echo $t OK
else
echo $t NOK
x=1
fi
done
for i in tests/*/*.jsonnet
do
json=$(dirname $i)/$( basename $i .jsonnet )_test_output.json
json_e=$(dirname $i)/$( basename $i .jsonnet )_compiled.json
t="Compiling $i..."
if jsonnet -J . -J ./vendor $i > $json
then
echo $t OK
else
echo $t NOK
x=1
continue
fi
if [[ "$1" == "update" ]]; then cp $json $json_e; fi
t="Checking $i..."
if diff -urt $json_e $json
then
echo $t OK
else
echo $t NOK
x=1
fi
done
for i in tests/*/*.yml
do
json=$(dirname $i)/$( basename $i .yml )_test_output.json
json_e=$(dirname $i)/$( basename $i .yml )_compiled.json
t="Building $i..."
if CONFIG=$i OUTPUT=$json make build > /dev/null
then
echo $t OK
else
echo $t NOK
x=1
continue
fi
if [[ "$1" == "update" ]]; then cp $json $json_e; fi
t="Checking $i..."
if diff -urt $json_e $json
then
echo $t OK
else
echo $t NOK
x=1
fi
done
exit $x