forked from grafana/grafonnet-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.sh
executable file
·45 lines (40 loc) · 821 Bytes
/
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
#!/bin/sh
x=0
for i in `find . -name '*.jsonnet' -or -name '*.libsonnet'`
do
t="Formating $i..."
if [[ $1 == "update" ]]; then
jsonnet fmt -i -n 4 $i
fi
if jsonnet fmt --test -n 4 $i;
then
echo $t OK
else
echo $t NOK
x=1
fi
done
for i in tests/*/*.jsonnet examples/*.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 . $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 $json_e
then
echo $t OK
else
echo $t NOK
x=1
fi
done
exit $x