Add python3 syntax checking to CI
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 03 Oct 2018 11:47:04 +0300
changeset 2420 290b77b72123
parent 2419 c081dabc0f63
child 2421 a5994ee1f6a7
Add python3 syntax checking to CI
tests/tools/check_source.sh
--- a/tests/tools/check_source.sh	Wed Oct 03 11:44:57 2018 +0300
+++ b/tests/tools/check_source.sh	Wed Oct 03 11:47:04 2018 +0300
@@ -52,6 +52,32 @@
     echo ""
 }
 
+
+python3_compile_checks()
+{
+    echo "Syntax checking using python3 ..."
+    python3 --version
+
+    # remove compiled Python files
+    find . -name '*.pyc' -exec rm -f {} \;
+
+    for i in $py_files; do
+        # echo $i
+        python3 -m py_compile $i
+        if [ $? -ne 0 ]; then
+            echo "Syntax error in $i"
+            set_exit_error
+        fi
+    done
+
+    # remove compiled Python files
+    find . -name '*.pyc' -exec rm -f {} \;
+
+    echo "DONE"
+    echo ""
+}
+
+
 # pep8 was renamed to pycodestyle
 # detect existed version
 pep8_detect()
@@ -390,6 +416,7 @@
 main()
 {
     get_files_to_check $@
+    python3_compile_checks
     compile_checks
     pep8_checks_default
     # pep8_checks_selected