fix all-tests
[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
8 targets="test-node test-app"
9
10 hash=$(git log -n 1 | head -1 | sed -e 's,commit ,,' -e 's,\(........\).*,\1,')
11
12 # compute output file name
13 output="all-tests.$hash"
14
15 # if there is any pending change, use another name
16 is_pristine=""
17 git diff HEAD | cmp --quiet - /dev/zero && is_pristine=true
18 [ -n "is_pristine" ] || output="$output-pending"
19
20 function all_tests () {
21     echo all-tests : begin at; date
22     begin=$(date +%s)
23     echo ========================================
24     echo status
25     echo ========================================
26     echo ===== Current hash $hash
27     echo ===== Current branch
28     git branch
29     echo ===== Uncommitted changes
30     git diff HEAD
31     echo ========================================
32     echo tests
33     echo ========================================
34     make all-tests
35     echo ========================================
36     end=$(date +%s)
37     echo all-tests : end at; date; echo total duration $(($end-$begin)) seconds
38 }
39
40 all_tests >& $output
41 retcod=$?
42
43 # analyze this output for success or not
44 success=$output.success
45 failure=$output.failed
46
47 if [ "$retcod" != 0 ]; then
48     touch $failure
49 elif grep -q '^FAIL' $output; then
50      touch $failure
51 else
52     touch $success
53 fi
54