6.1.2
[nepi.git] / all-tests
1 #!/bin/bash
2 #
3 # helper script to run some predefined set of tests
4 # store results in a file that contains the git hash
5 # and also shows differences if any
6 #
7 # if this command is run as all-tests3, then we will just do
8 # make PYTHON=python3
9 #
10 # xxx - WARNING : most likely the python2 and python3 tests
11 # cannot safely be run together; need to check the nepi exp_ids
12 # used more closely
13
14 DIRNAME=$(dirname $0)
15 COMMAND=$(basename $0)
16
17 if echo $COMMAND | grep -q 6; then
18     $DIRNAME/all-tests2; $DIRNAME/all-tests3; exit
19 fi
20
21 PYTHON=python
22 version=2
23 echo $COMMAND | grep -q 3 && { PYTHON=python3; version=3; }
24
25 hash=$(git log -n 1 | head -1 | sed -e 's,commit ,,' -e 's,\(........\).*,\1,')
26
27 # compute output file name
28 output="zz.$hash.py$version"
29 latest="zz.latest.py$version"
30
31 # if there is any pending change, use another name
32 is_pristine=""
33 changes=$(git diff HEAD | wc -l); changes=$(echo $changes)
34 [ "$changes" == 0 ] && is_pristine=true
35 [ -n "$is_pristine" ] || output="$output-pending"
36
37 function all_tests () {
38     echo all-tests : begin at; date
39     begin=$(date +%s)
40     echo ========================================
41     echo status
42     echo ========================================
43     echo ===== Current hash $hash
44     echo ===== Current branch
45     git branch
46     echo ===== Uncommitted changes
47     git diff HEAD
48     echo ========================================
49     echo tests
50     echo ========================================
51     make PYTHON=$PYTHON all-tests
52     make_retcod=$!
53     echo ========================================
54     end=$(date +%s)
55     echo all-tests : end at $((date)); echo total duration $(($end-$begin)) seconds
56     return $make_retcod
57 }
58
59 # WARNING
60 # the current code for analyzing the output is very basic
61 # this needs to be checked manually for some time
62
63 # create a 'latest' symlink
64 ln -f -s $output $latest
65
66 all_tests >& $output
67 retcod=$?
68
69 # analyze this output for success or not
70 success=$output.success
71 failure=$output.failed
72
73 if [ "$retcod" != 0 ]; then
74     touch $failure
75 elif grep -q '^FAIL' $output; then
76      touch $failure
77 else
78     touch $success
79 fi
80