all-tests to properly add '-pending' when needed
[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 changes=$(git diff HEAD | wc -l); changes=$(echo $changes)
18 [ "$changes" == 0 ] && is_pristine=true
19 [ -n "$is_pristine" ] || output="$output-pending"
20
21 function all_tests () {
22     echo all-tests : begin at; date
23     begin=$(date +%s)
24     echo ========================================
25     echo status
26     echo ========================================
27     echo ===== Current hash $hash
28     echo ===== Current branch
29     git branch
30     echo ===== Uncommitted changes
31     git diff HEAD
32     echo ========================================
33     echo tests
34     echo ========================================
35     make all-tests
36     echo ========================================
37     end=$(date +%s)
38     echo all-tests : end at; date; echo total duration $(($end-$begin)) seconds
39 }
40
41 all_tests >& $output
42 retcod=$?
43
44 # analyze this output for success or not
45 success=$output.success
46 failure=$output.failed
47
48 if [ "$retcod" != 0 ]; then
49     touch $failure
50 elif grep -q '^FAIL' $output; then
51      touch $failure
52 else
53     touch $success
54 fi
55