Browse code

build: improve sanity_check.sh

- use full path instead of relative path
- fail on script errors

Change-Id: I500ea793cbd950449df810b964d722506eddadf3
Signed-off-by: Kiril Nesenko <knesenko@vmware.com>
Reviewed-on: http://photon-jenkins.eng.vmware.com/296
Tested-by: jenkins-photon <wangnan2015@hotmail.com>
Reviewed-by: Sharath George

Kiril Nesenko authored on 2015/12/16 03:31:16
Showing 1 changed files
... ...
@@ -1,8 +1,22 @@
1 1
 #!/bin/bash
2 2
 
3
+SCRIPTS_DIR="$(dirname ${0})"
4
+
3 5
 # Sanify check for all json files.
4 6
 echo "Sanity check for all json files..."
5
-for i in `find . -name "*.json" -type f -not -path "*stage*"`; do echo $i; json_pp -t null < $i || break -1 ; done
7
+while read f; do
8
+	echo "Checking:${f}"
9
+	if ! json_pp -t null < "${f}" >& /dev/null; then
10
+		echo "Please check:${f} for syntax errors"
11
+		exit 1
12
+	fi
13
+done < <(find "${SCRIPTS_DIR}/../" -name "*.json" -type f -not -path "*stage*")
6 14
 
7 15
 echo "Checking all python code is compilable..."
8
-for i in `find . -name "*.py" -type f -not -path "*stage*"`; do echo $i; python -m py_compile $i || break -1 ; done
16
+while read f; do
17
+	echo "Checking:${f}"
18
+	if ! python -m py_compile "${f}"; then
19
+		echo "Please check:${f} for complitation errors"
20
+		exit 1
21
+	fi
22
+done < <(find "${SCRIPTS_DIR}/../" -name "*.py" -type f -not -path "*stage*")