File: run_tests

package info (click to toggle)
mrtrix3 3.0~rc3+git135-g2b8e7d0c2-3
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 34,248 kB
  • sloc: cpp: 117,101; python: 6,472; sh: 638; makefile: 226; xml: 39; ansic: 20
file content (119 lines) | stat: -rwxr-xr-x 1,957 bytes parent folder | download | duplicates (2)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash

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

cat > $LOGFILE <<EOD
-------------------------------------------
  Testing MRtrix3 installation
-------------------------------------------

EOD

echo -n "Debian build: Using available test data..." >> $LOGFILE

if [ $? != 0 ]; then
  echo ERROR!
  exit 1
else
  echo OK
fi



echo -n "building testing commands... "
cat >> $LOGFILE <<EOD

-------------------------------------------

## building test commands... 

EOD
(
  cd testing
  ../build 
) >> $LOGFILE 2>&1
if [ $? != 0 ]; then 
  echo ERROR!
  exit 1
else
  echo OK
fi


# generate list of tests to run:
if [ $# == 0 ]; then
  for n in testing/tests/*; do
    tests="$tests $(basename $n)"
  done
else
  tests="$@"
fi

a_script_has_failed=false

cat >> $LOGFILE <<EOD

PATH is set to $PATH 
EOD


for script in $tests; do

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

## running "${script}"...

EOD

  echo -n 'running "'${script}'"... '
  rm -rf testing/data/tmp*
  ((ntests=0))
  ((success=0))
  while IFS='' read -r cmd || [[ -n "$cmd" ]]; do
    cmd="${cmd%\#*}"
    [[ -n "$cmd" ]] || continue
    echo -n '# command: '$cmd >> $LOGFILE 
    (
      export PATH="$(pwd)/testing/bin:$(pwd)/bin:$PATH"; 
      cd testing/data/
      eval $cmd
    ) > .__tmp.log 2>&1 

    if [[ $? -ne 0 ]]; then 
      echo " [ ERROR ]" >> $LOGFILE
    else 
      echo " [ ok ]" >> $LOGFILE
      ((success++)); 
    fi
    cat .__tmp.log >> $LOGFILE
    echo "" >> $LOGFILE
    ((ntests++))
  done < testing/tests/$script

  echo -n $success of $ntests passed
  if [[ $success -lt $ntests ]]; then
    echo "    <-------- ERROR"
    a_script_has_failed=true 
    cat >> $LOGFILE <<EOD

## ERROR: $(($ntests-$success)) tests failed for "${script}"

EOD
  else
    echo ""
    cat >> $LOGFILE <<EOD
## $ntests tests completed OK for "${script}"

EOD
  fi

done

if [ ${a_script_has_failed} = true ]; 
then
  exit 1
fi