tests: update git-commands test to use GitPython
[git-cola.git] / t / run_tests
blob99495a0840425a3e2181e3910272af4578793643
1 #!/bin/sh
3 cd $(dirname $0)
5 ERROR=''
6 UGIT=$(which ugit)
7 test -z "$UGIT" && ERROR=1
9 if [ $ERROR ]; then
10 echo "ugit must be in your path in order to call run_tests directly."
11 exit -1
13 BINDIR=$(dirname $UGIT)
14 PREFIX=$(dirname $BINDIR)
15 PYTHONPATH="$PREFIX"/share:"$PREFIX"/share/ugit:"$PYTHONPATH"
16 export PYTHONPATH
19 for unittest in t[0-9]*.py; do
20 echo
21 echo -n "$unittest "
22 ./$unittest
23 if [ $? -ne 0 ] && [ -z "$RUN_ALL" ]; then
24 echo "$unittest failed with exit code $?"
25 exit -1
27 done
29 ) 2>&1 | perl -e '
31 use Time::HiRes qw(gettimeofday);
33 my ($start_sec, $start_ms) = gettimeofday();
35 my $count = 0;
36 my @fail = ();
37 while(<>) {
38 print;
39 if ( /(\d+) tests/ ) {
40 $count += $1;
42 elsif ( /(.*) failed/ ) {
43 push @fail, $1;
47 my ($end_sec, $end_ms) = gettimeofday();
49 my $min = 0;
50 my $sec = $end_sec - $start_sec;
51 my $secfrac = ( $end_ms - $start_ms ) * 100;
53 while ( $secfrac < 0.0 ) {
54 $secfrac += 1000 * 100;
57 $secfrac = substr("$secfrac", 0, 2);
59 while ( $sec > 60 ) {
60 $sec -= 60;
61 $min++;
64 if ( @fail ) {
65 print "\n";
66 print "The following test FAILED:\n";
67 print "-"x70 ."\n\t";
68 print join("\n\t", @fail);
69 print "\n";
72 print "\n";
73 print `../scripts/gitversion.sh`;
74 print "-"x70 ."\n";
75 print "$count tests total\n";
76 print "$min min $sec.$secfrac sec total runtime\n\n";
78 exit 0