File: run_pylint

package info (click to toggle)
mrtrix3 3.0~rc3%2Bgit135-g2b8e7d0c2-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 34,548 kB
  • sloc: cpp: 117,101; python: 6,472; sh: 638; makefile: 231; xml: 39; ansic: 20
file content (97 lines) | stat: -rwxr-xr-x 1,854 bytes parent folder | download
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash

LOGFILE=pylint.log
echo logging to \""$LOGFILE"\"

# generate list of tests to run:
if [ $# == 0 ]; then
  for lib_path in lib/mrtrix3/*; do
    if [[ -d ${lib_path} && ! ( ${lib_path} == *"__pycache__"* ) ]]; then
      for src_file in ${lib_path}/*.py; do
        tests="$tests $src_file"
      done
    elif [[ ${lib_path} == *.py && ! ( ${lib_path} == *"_"* ) ]]; then
      tests="$tests $lib_path"
    fi
  done
  for bin_path in bin/*; do
    if head ${bin_path} -n1 | grep -q "#!/usr/bin/python3"; then
      tests="$tests $bin_path"
    fi
  done
else
  tests="$@"
fi

success=0
ntests=0

if [ -z $PYTHON ]; then
  forcepyversion=""
else
  echo "Using pylint for "${PYTHON}" (from PYTHON environment variable)"
  forcepyversion="$PYTHON -m "
fi



cat > $LOGFILE <<EOD
-------------------------------------------
  Version information
-------------------------------------------

EOD

eval ${forcepyversion} pylint --version >> $LOGFILE

cat >> $LOGFILE <<EOD

-------------------------------------------
  Testing MRtrix3 Python scripts
-------------------------------------------

EOD


export PYTHONPATH="$(pwd)/lib:$PYTHONPATH"
for file in $tests; do

  cat >> $LOGFILE <<EOD
-------------------------------------------

## testing "${file}"...
EOD

  echo -n 'testing "'${file}'"... '

  eval ${forcepyversion} pylint --rcfile=testing/pylint.rc ${file} > .__tmp.log 2>&1

  if [[ $? -ne 0 ]]; then
    echo 'ERROR'
    echo " [ ERROR ]" >> $LOGFILE
  else
    echo 'OK'
    echo " [ ok ]" >> $LOGFILE
    ((success++))
  fi

  cat .__tmp.log >> $LOGFILE
  echo "" >> $LOGFILE
  ((ntests++))

done

if [[ ${success} -lt ${ntests} ]]; then
  cat >> $LOGFILE <<EOD

## ERROR: $(($ntests-$success)) of $(($ntests)) tests failed (see \""$LOGFILE"\")

EOD
  exit 1
else
  cat >> $LOGFILE <<EOD

## $ntests tests completed OK

EOD
fi