forked from grafana/grafonnet-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.sh
executable file
·46 lines (41 loc) · 933 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
46
#!/bin/bash
jsonnet_fmt='-n 2 --max-blank-lines 2 --sort-imports --string-style s --comment-style s'
x=0
for i in `find . -name '*.jsonnet' -or -name '*.libsonnet'`
do
t="Formatting $i..."
if [[ "$1" == "update" ]]; then
jsonnet fmt -i $jsonnet_fmt $i
fi
if jsonnet fmt --test $jsonnet_fmt $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