tests/tools/check_source.sh
changeset 2016 2a8cd24a14ca
parent 1881 091005ec69c4
child 2181 52630996e51b
equal deleted inserted replaced
2015:4eeefc6a13fd 2016:2a8cd24a14ca
    32 }
    32 }
    33 
    33 
    34 
    34 
    35 compile_checks()
    35 compile_checks()
    36 {
    36 {
    37     echo "Syntax checking..."
    37     echo "Syntax checking using python ..."
    38     py_files=$(find . -name '*.py')
    38     py_files=$(find . -name '*.py')
       
    39 
       
    40     python --version
    39 
    41 
    40     # remove compiled Python files
    42     # remove compiled Python files
    41     find . -name '*.pyc' -exec rm -f {} \;
    43     find . -name '*.pyc' -exec rm -f {} \;
    42 
    44 
    43     for i in $py_files; do
    45     for i in $py_files; do
    46         if [ $? -ne 0 ]; then
    48         if [ $? -ne 0 ]; then
    47             echo "Syntax error in $i"
    49             echo "Syntax error in $i"
    48             set_exit_error
    50             set_exit_error
    49         fi
    51         fi
    50     done
    52     done
       
    53     echo "DONE"
       
    54     echo ""
    51 }
    55 }
    52 
    56 
    53 # pep8 was renamed to pycodestyle
    57 # pep8 was renamed to pycodestyle
    54 # detect existed version
    58 # detect existed version
    55 pep8_detect()
    59 pep8_detect()
    58     test -n $pep8 && (which pycodestyle > /dev/null) && pep8="pycodestyle"
    62     test -n $pep8 && (which pycodestyle > /dev/null) && pep8="pycodestyle"
    59     if [ -z $pep8 ]; then
    63     if [ -z $pep8 ]; then
    60         echo "pep8/pycodestyle is not found"
    64         echo "pep8/pycodestyle is not found"
    61         set_exit_error
    65         set_exit_error
    62     fi
    66     fi
       
    67     echo -n "pep8 version: "
       
    68     $pep8 --version
    63 }
    69 }
    64 
    70 
    65 pep8_checks_default()
    71 pep8_checks_default()
    66 {
    72 {
    67     echo "Check basic code-style problems for PEP-8"
    73     echo "Check basic code-style problems for PEP-8"
    89     # $pep8 --ignore $ignore --exclude build ./
    95     # $pep8 --ignore $ignore --exclude build ./
    90     $pep8 --max-line-length 300 --exclude build ./
    96     $pep8 --max-line-length 300 --exclude build ./
    91     if [ $? -ne 0 ]; then
    97     if [ $? -ne 0 ]; then
    92         set_exit_error
    98         set_exit_error
    93     fi
    99     fi
       
   100 
       
   101     echo "DONE"
       
   102     echo ""
    94 }
   103 }
    95 
   104 
    96 
   105 
    97 pep8_checks_selected()
   106 pep8_checks_selected()
    98 {
   107 {
   157 
   166 
   158     $pep8 --select $user_select --exclude=build .
   167     $pep8 --select $user_select --exclude=build .
   159     if [ $? -ne 0 ]; then
   168     if [ $? -ne 0 ]; then
   160         set_exit_error
   169         set_exit_error
   161     fi
   170     fi
       
   171 
       
   172     echo "DONE"
       
   173     echo ""
   162 }
   174 }
   163 
   175 
   164 flake8_checks()
   176 flake8_checks()
   165 {
   177 {
   166     echo "Check for problems using flake8 ..."
   178     echo "Check for problems using flake8 ..."
   170         echo "flake8 is not found"
   182         echo "flake8 is not found"
   171         set_exit_error
   183         set_exit_error
   172         return
   184         return
   173     fi
   185     fi
   174 
   186 
       
   187     echo -n "flake8 version: "
       
   188     flake8 --version
       
   189 
   175     flake8 --max-line-length=300  --exclude=build --builtins="_" ./
   190     flake8 --max-line-length=300  --exclude=build --builtins="_" ./
   176     if [ $? -ne 0 ]; then
   191     if [ $? -ne 0 ]; then
   177         set_exit_error
   192         set_exit_error
   178     fi
   193     fi
       
   194 
       
   195     echo "DONE"
       
   196     echo ""
   179 }
   197 }
   180 
   198 
   181 pylint_checks()
   199 pylint_checks()
   182 {
   200 {
   183     echo "Check for problems using pylint ..."
   201     echo "Check for problems using pylint ..."
   186     if [ $? -ne 0 ]; then
   204     if [ $? -ne 0 ]; then
   187         echo "pylint is not found"
   205         echo "pylint is not found"
   188         set_exit_error
   206         set_exit_error
   189         return
   207         return
   190     fi
   208     fi
       
   209     pylint --version
   191 
   210 
   192     export PYTHONPATH="$PWD/../CanFestival-3/objdictgen":$PYTHONPATH
   211     export PYTHONPATH="$PWD/../CanFestival-3/objdictgen":$PYTHONPATH
   193 
   212 
   194     disable=
   213     disable=
   195     # These warnings most likely will not be fixed
   214     # These warnings most likely will not be fixed
   289 
   308 
   290     find ./ -name '*.py' | grep -v '/build/' | xargs pylint $options 
   309     find ./ -name '*.py' | grep -v '/build/' | xargs pylint $options 
   291     if [ $? -ne 0 ]; then
   310     if [ $? -ne 0 ]; then
   292         set_exit_error
   311         set_exit_error
   293     fi
   312     fi
       
   313 
       
   314     echo "DONE"
       
   315     echo ""
   294 }
   316 }
   295 
   317 
   296 main()
   318 main()
   297 {
   319 {
   298     compile_checks
   320     compile_checks