r20509: Warn about the fact that no tests have been run rather than showing division by
[Samba/ekacnet.git] / source4 / script / subunit-summary
blobaec50ed02a6a05a4d4403f8e820db0c7c0bc51ca
1 #!/usr/bin/perl
2 # Simple subunit parser
3 # (C) 2006 Jelmer Vernooij <jelmer@samba.org>
5 use strict;
6 use Getopt::Long;
8 my $numtests = 0;
9 my $numfails = 0;
10 my $numskips = 0;
11 my $numsuccess = 0;
13 my $opt_help = 0;
14 my $opt_progress = 0;
16 my $result = GetOptions (
17 'help|h|?' => \$opt_help,
18 'progress' => \$opt_progress
21 if (not $result) {
22 exit(1);
25 if ($opt_help) {
26 print "subunit output summarizer\n";
27 print "Copyright (C) 2006 Jelmer Vernooij <jelmer\@samba.org>\n";
28 print "\n";
29 print "Usage: subunit-summary [OPTION]\n";
30 print " --help Print this help message\n";
31 print "\n";
32 exit(0);
35 while(<STDIN>) {
36 next unless (/^(.+): (.+?)( \[)?$/);
37 if ($1 eq "test") {
38 $numtests++;
39 } elsif ($1 eq "error") {
40 print "E" if ($opt_progress);
41 } elsif ($1 eq "failure") {
42 $numfails++;
43 print "F" if ($opt_progress);
44 } elsif ($1 eq "success") {
45 $numsuccess++;
46 print "." if ($opt_progress);
47 } elsif ($1 eq "skip") {
48 $numskips++;
49 print "I" if ($opt_progress);
50 } elsif ($1 eq "testsuite") {
51 if ($opt_progress) {
52 if ($numtests) { print "\n"; }
53 print "$2: ";
58 print "\n" if ($opt_progress);
60 if ($numtests == 0) {
61 print "No tests run\n";
62 exit(0);
65 printf("%d%%: %d tests, %d succeeded, %d failed, %d skipped\n",
66 ($numsuccess / $numtests * 100),
67 $numtests,
68 $numsuccess,
69 $numfails,
70 $numskips);