Debian Codegraph @

test_suite/run_fmt_tests.sh

raw
1 #!/usr/bin/env bash
2
3 # Copyright 2015 Google Inc. All rights reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 cd "$(dirname $0)"
18
19 source "tests.source"
20
21 # Enable next line to test the garbage collector
22 #PARAMS="--gc-min-objects 1 --gc-growth-trigger 1"
23
24 # Enable next line for a slow and thorough test
25 #VALGRIND="valgrind -q"
26
27 #VERBOSE=true
28
29 init
30
31 for TEST in *.jsonnet ../examples/*.jsonnet ../examples/terraform/*.jsonnet ../benchmarks/*.jsonnet ../gc_stress/*.jsonnet ; do
32
33 GOLDEN_OUTPUT="$(cat $TEST)"
34 GOLDEN_KIND="PLAIN"
35
36 if [ -r "$TEST.fmt.golden" ] ; then
37 GOLDEN_OUTPUT=$(cat "$TEST.fmt.golden")
38 fi
39
40 if [ $(echo "$TEST" | cut -b 1-12) == "error.parse." ] ; then
41 continue # No point testing these
42 fi
43
44 EXPECTED_EXIT_CODE=0
45 JSONNETFMT_CMD="$VALGRIND "$JSONNETFMT_BIN""
46 test_eval "$JSONNETFMT_CMD" "$TEST" "$EXPECTED_EXIT_CODE" "$GOLDEN_OUTPUT" "$GOLDEN_KIND"
47 done
48
49 if [ $FAILED -eq 0 ] ; then
50 echo "$0: All $EXECUTED test scripts pass."
51 else
52 echo "$0: FAILED: $FAILED / $EXECUTED"
53 exit 1
54 fi
55
56 deinit