tweaked Makefile to use either setup or twine to upload stuff onto pypi
[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 COMMAND=$(basename $0)
15
16 PYTHON=python
17 version=2
18 echo $COMMAND | grep -q 3 && { PYTHON=python3; version=3; }
19
20 hash=$(git log -n 1 | head -1 | sed -e 's,commit ,,' -e 's,\(........\).*,\1,')
21
22 # compute output file name
23 output="zz.$hash.py$version"
24
25 # if there is any pending change, use another name
26 is_pristine=""
27 changes=$(git diff HEAD | wc -l); changes=$(echo $changes)
28 [ "$changes" == 0 ] && is_pristine=true
29 [ -n "$is_pristine" ] || output="$output-pending"
30
31 function all_tests () {
32     echo all-tests : begin at; date
33     begin=$(date +%s)
34     echo ========================================
35     echo status
36     echo ========================================
37     echo ===== Current hash $hash
38     echo ===== Current branch
39     git branch
40     echo ===== Uncommitted changes
41     git diff HEAD
42     echo ========================================
43     echo tests
44     echo ========================================
45     make PYTHON=$PYTHON all-tests
46     make_retcod=$!
47     echo ========================================
48     end=$(date +%s)
49     echo all-tests : end at $((date)); echo total duration $(($end-$begin)) seconds
50     return $make_retcod
51 }
52
53 # WARNING
54 # the current code for analyzing the output is very basic
55 # this needs to be checked manually for some time
56
57 all_tests >& $output
58 retcod=$?
59
60 # analyze this output for success or not
61 success=$output.success
62 failure=$output.failed
63
64 if [ "$retcod" != 0 ]; then
65     touch $failure
66 elif grep -q '^FAIL' $output; then
67      touch $failure
68 else
69     touch $success
70 fi
71