File: testpyke

package info (click to toggle)
pyke 1.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,456 kB
  • sloc: python: 12,872; sh: 441; xml: 203; sql: 39; makefile: 39
file content (112 lines) | stat: -rwxr-xr-x 2,214 bytes parent folder | download | duplicates (3)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash

# testpyke [-x.y] [-3]
#
# Deletes all compiled_krb directories, then runs testall.py twice.
# 
# exit status > 0 if errors found.

TMP1=/tmp/testpyke1.$$
TMP2=/tmp/testpyke2.$$
TMP3=/tmp/testpyke3.$$

usage() {
    echo "usage: testpyke [-x.y] [-3] [suffix...]" >&2
    echo "       x.y is the Python version to use" >&2
    exit 2
}

options=(`getopt -uqan testpyke -o 3 -l 2.5,2.6,2.7,2.8,3.0,3.1,3.2,3.3 -- "$@"`)
[ $? -eq 0 ] || usage

#echo options "${options[@]}"
#echo num options ${#options[*]}

opt=
args1=
args2=
first=1
suffix=

i=0
while [ $i -lt ${#options[*]} ]
do
    case ${options[$i]} in
    -3)  opt="-3";;
    --)  ;;
    --*) suffix=_${options[$i]//[-.]};;
    py)  args1="$args1 py";;
    *)   args1="$args1 ${options[$i]}"
         args2="$args2 ${options[$i]}"
         ;;
    esac
    i=$(($i + 1))
done

if [ ! "$args1" ]
then
    args2="tst txt"
fi

CMD="testall${suffix}.py $opt"

#echo args "$args"
#echo suffix "$suffix"
#echo $CMD
#exit

echo Removing all compiled_krb directories.
echo

find . -name krb_compiler -prune -o -name compiled_krb -exec rm -rf "{}" +

echo Running all tests with no compiled_krb files:
echo

$CMD -s $TMP1 $args1
status1=$?

if [ "$args2" ]
then
    echo
    echo Running all tests with compiled_krb files:
    echo

    $CMD -s $TMP2 $args2
    status2=$?
else
    status2=0
fi

echo
results1=(`sed -n '1s/^Files: \([0-9]*\), Tests: \([0-9]*\), Errors: \(.*\)$/\1 \2 \3/p' $TMP1`)
echo "Compiling compiled_krb:" Files: ${results1[0]}, \
     Tests: ${results1[1]}, \
     Errors: ${results1[2]}

if [ "$args2" ]
then
    results2=(`sed -n '1s/^Files: \([0-9]*\), Tests: \([0-9]*\), Errors: \(.*\)$/\1 \2 \3/p' $TMP2`)
    echo "Reusing   compiled_krb:" Files: ${results2[0]}, \
         Tests: ${results2[1]}, \
         Errors: ${results2[2]}
    tail -q -n +3 $TMP1 $TMP2 | sort -u > $TMP3
    if [ -s $TMP3 ]
    then
        num_error_files=`wc -l $TMP3 | cut -f1 '-d '`
        echo
        echo "********** ERRORS ************* $num_error_files files had errors:"
        cat $TMP3
    fi
elif [ -s $TMP1 ]
then
    echo
    tail -q -n +2 $TMP1
fi

rm -f $TMP1 $TMP2 $TMP3

if [ $status1 -ne 0 -o $status2 -ne 0 ]
then
    exit 1
fi