summaryrefslogtreecommitdiff
path: root/source4/script/subunit-summary
blob: aec50ed02a6a05a4d4403f8e820db0c7c0bc51ca (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
67
68
69
70
#!/usr/bin/perl
# Simple subunit parser
# (C) 2006 Jelmer Vernooij <jelmer@samba.org>

use strict;
use Getopt::Long;

my $numtests = 0;
my $numfails = 0;
my $numskips = 0;
my $numsuccess = 0;

my $opt_help = 0;
my $opt_progress = 0;

my $result = GetOptions (
	    'help|h|?' => \$opt_help, 
		'progress' => \$opt_progress
	    );

if (not $result) {
	exit(1);
}

if ($opt_help) {
	print "subunit output summarizer\n";
	print "Copyright (C) 2006 Jelmer Vernooij <jelmer\@samba.org>\n";
	print "\n";
	print "Usage: subunit-summary [OPTION]\n";
	print " --help			Print this help message\n";
	print "\n";
	exit(0);
}

while(<STDIN>) {
	next unless (/^(.+): (.+?)( \[)?$/);
	if ($1 eq "test") {
		$numtests++;
	} elsif ($1 eq "error") {
		print "E" if ($opt_progress);
	} elsif ($1 eq "failure") {
		$numfails++;
		print "F" if ($opt_progress);
	} elsif ($1 eq "success") {
		$numsuccess++;
		print "." if ($opt_progress);
	} elsif ($1 eq "skip") {
		$numskips++;
		print "I" if ($opt_progress);
	} elsif ($1 eq "testsuite") {
		if ($opt_progress) {
			if ($numtests) { print "\n"; }
			print "$2: ";
		}
	}
}

print "\n" if ($opt_progress);

if ($numtests == 0) {
    print "No tests run\n";
    exit(0);
}

printf("%d%%: %d tests, %d succeeded, %d failed, %d skipped\n", 
       ($numsuccess / $numtests * 100),
	   $numtests,
	   $numsuccess,
	   $numfails,
	   $numskips);