aboutsummaryrefslogtreecommitdiffstats
path: root/script/spec-all-pairs
blob: 31cb7a36b939bcff9c31d18f5a190ad917d7b1d8 (plain)
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
#!/bin/bash

# Try all ordered pairs of spec files,
# to winkle out order-dependent failures.

test_pair () {
    rake db:test:prepare > /dev/null 2>&1
    if script/spec "$1" "$2" > /dev/null 2>&1
    then
        echo "OK: $1 $2"
        return 0
    else
        echo "FAILED: $1 $2"
        return 1
    fi
}

all_pairs() {
    specs=spec/*/*.rb

    for spec1 in $specs
    do
        all_okay=true
        for spec2 in $specs
        do
            if ! test_pair "$spec1" "$spec2"
            then
              all_okay=false
            fi
        done
    done

    $all_okay
    return $?
}

pairs_from_stdin() {
    all_okay=true
    while read line
    do
        case "$line" in
        \*\ FAILED:\ *|\
        spec/*.rb\ spec/$.rb)
          line=${line#\* FAILED: }
          if ! test_pair $line
          then
              all_okay=false
          fi
        ;;
        *)
          echo "No match: $line"
        ;;
        esac
    done
    
    $all_okay
    return $?
}

if [ "$1" = "-" ]
then
    pairs_from_stdin
else
    all_pairs
fi
exit $?