[SCM] Samba Shared Repository - branch master updated

Jelmer Vernooij jelmer at samba.org
Mon Mar 29 17:09:55 MDT 2010


The branch, master has been updated
       via  0cdc021... selftest: Remove diff-subunit - it's included in subunit and not necessary for normal operation.
       via  c108a2e... format-subunit: Improve formatting, simplify code.
       via  ef3fb75... selftest: Replace perl subunit formatter with python subunit formatter, so we can leverage the work happening in python-subunit.
       via  0c78368... selftest: Convert format-subunit to Python.
      from  e14a6fb... Fix bug 7307 - man net usershare mistake

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 0cdc021ba4cc0f400e6fbce173e0d17dee69ee64
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Mar 30 01:00:16 2010 +0200

    selftest: Remove diff-subunit - it's included in subunit and not necessary for normal operation.

commit c108a2e74e98e35c72d74a37d1b147396403925e
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Mar 30 00:59:04 2010 +0200

    format-subunit: Improve formatting, simplify code.

commit ef3fb75261d1ce0d10da3e0c636c895aeb8b8441
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Mar 30 00:30:52 2010 +0200

    selftest: Replace perl subunit formatter with python subunit formatter,
    so we can leverage the work happening in python-subunit.

commit 0c78368a3108ad7437a20fac7e6da42ecf6f348a
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Mon Mar 29 22:25:25 2010 +0200

    selftest: Convert format-subunit to Python.

-----------------------------------------------------------------------

Summary of changes:
 selftest/Subunit/Diff.pm   |   80 -------------
 selftest/diff-subunit.pl   |   21 ----
 selftest/format-subunit    |  267 ++++++++++++++++++++++++++++++++------------
 selftest/output/plain.pm   |  246 ----------------------------------------
 selftest/subunithelper.py  |  169 ++++++++++++++++++++++++++++
 source3/Makefile.in        |    2 +-
 source4/selftest/config.mk |    2 +-
 7 files changed, 364 insertions(+), 423 deletions(-)
 delete mode 100644 selftest/Subunit/Diff.pm
 delete mode 100755 selftest/diff-subunit.pl
 delete mode 100644 selftest/output/plain.pm
 create mode 100644 selftest/subunithelper.py


Changeset truncated at 500 lines:

diff --git a/selftest/Subunit/Diff.pm b/selftest/Subunit/Diff.pm
deleted file mode 100644
index de251b3..0000000
--- a/selftest/Subunit/Diff.pm
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/perl
-# Diff two subunit streams
-# Copyright (C) Jelmer Vernooij <jelmer at samba.org>
-# Published under the GNU GPL, v3 or later
-
-package Subunit::Diff;
-
-use strict;
-
-use Subunit qw(parse_results);
-
-sub control_msg() { }
-sub report_time($$) { }
-
-sub output_msg($$)
-{
-	my ($self, $msg) = @_;
-
-	# No output for now, perhaps later diff this as well ?
-}
-
-sub start_test($$)
-{
-	my ($self, $testname) = @_;
-}
-
-sub end_test($$$$$)
-{
-	my ($self, $testname, $result, $unexpected, $reason) = @_;
-
-	$self->{$testname} = $result;
-}
-
-sub skip_testsuite($;$) { } 
-sub start_testsuite($;$) { }
-sub end_testsuite($$;$) { }
-sub testsuite_count($$) { }
-
-sub new {
-	my ($class) = @_;
-
-	my $self = { 
-	};
-	bless($self, $class);
-}
-
-sub from_file($)
-{
-	my ($path) = @_;
-	my $statistics = {
-		TESTS_UNEXPECTED_OK => 0,
-		TESTS_EXPECTED_OK => 0,
-		TESTS_UNEXPECTED_FAIL => 0,
-		TESTS_EXPECTED_FAIL => 0,
-		TESTS_ERROR => 0,
-		TESTS_SKIP => 0,
-	};
-
-	my $ret = new Subunit::Diff();
-	open(IN, $path) or return;
-	parse_results($ret, $statistics, *IN);
-	close(IN);
-	return $ret;
-}
-
-sub diff($$)
-{
-	my ($old, $new) = @_;
-	my $ret = {};
-
-	foreach my $testname (keys %$old) {
-		if ($new->{$testname} ne $old->{$testname}) {
-			$ret->{$testname} = [$old->{$testname}, $new->{$testname}];
-		}
-	}
-
-	return $ret;
-}
-
-1;
diff --git a/selftest/diff-subunit.pl b/selftest/diff-subunit.pl
deleted file mode 100755
index fc80c37..0000000
--- a/selftest/diff-subunit.pl
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/perl
-# Diff two subunit streams
-# Copyright (C) Jelmer Vernooij <jelmer at samba.org>
-# Published under the GNU GPL, v3 or later
-
-use Getopt::Long;
-use strict;
-use FindBin qw($RealBin $Script);
-use lib "$RealBin";
-use Subunit::Diff;
-
-my $old = Subunit::Diff::from_file($ARGV[0]);
-my $new = Subunit::Diff::from_file($ARGV[1]);
-
-my $ret = Subunit::Diff::diff($old, $new);
-
-foreach my $e (sort(keys %$ret)) {
-	printf "%s: %s -> %s\n", $e, $ret->{$e}[0], $ret->{$e}[1];
-}
-
-0;
diff --git a/selftest/format-subunit b/selftest/format-subunit
index 2224b71..71fa018 100755
--- a/selftest/format-subunit
+++ b/selftest/format-subunit
@@ -1,77 +1,196 @@
-#!/usr/bin/perl
+#!/usr/bin/env python
+# vim: expandtab
 # Pretty-format subunit output
-# Copyright (C) Jelmer Vernooij <jelmer at samba.org>
+# Copyright (C) 2008-2010 Jelmer Vernooij <jelmer at samba.org>
 # Published under the GNU GPL, v3 or later
 
-=pod
-
-=head1 NAME
-
-format-subunit [--immediate] < instream > outstream
-
-=head1 SYNOPSIS
-
-Format the output of a subunit stream.
-
-=head1 OPTIONS
-
-=over 4
-
-=item I<--immediate>
-
-Show errors as soon as they happen rather than at the end of the test run.
-
-=head1 LICENSE
-
-GNU General Public License, version 3 or later.
-
-=head1 AUTHOR
-
-Jelmer Vernooij <jelmer at samba.org>
-		
-=cut
-
-use Getopt::Long;
-use strict;
-use FindBin qw($RealBin $Script);
-use lib "$RealBin";
-use Subunit qw(parse_results);
-
-my $opt_help = undef;
-my $opt_verbose = 0;
-my $opt_immediate = 0;
-my $opt_prefix = ".";
-
-my $result = GetOptions (
-		'help|h|?' => \$opt_help,
-		'verbose' => \$opt_verbose,
-		'immediate' => \$opt_immediate,
-		'prefix:s' => \$opt_prefix,
-	    );
-
-exit(1) if (not $result);
-
-my $msg_ops;
-
-# we want unbuffered output
-$| = 1;
-
-my $statistics = {
-	SUITES_FAIL => 0,
-
-	TESTS_UNEXPECTED_OK => 0,
-	TESTS_EXPECTED_OK => 0,
-	TESTS_UNEXPECTED_FAIL => 0,
-	TESTS_EXPECTED_FAIL => 0,
-	TESTS_ERROR => 0,
-	TESTS_SKIP => 0,
-};
-
-require output::plain;
-$msg_ops = new output::plain("$opt_prefix/summary", $opt_verbose, $opt_immediate, $statistics, undef);
-
-my $expected_ret = parse_results($msg_ops, $statistics, *STDIN);
-
-$msg_ops->summary();
-
-exit($expected_ret);
+import optparse
+import os
+import sys
+
+import subunithelper
+
+class PlainFormatter(object):
+
+    def __init__(self, summaryfile, verbose, immediate, statistics,
+            totaltests=None):
+        self.verbose = verbose
+        self.immediate = immediate
+        self.statistics = statistics
+        self.start_time = None
+        self.test_output = {}
+        self.suitesfailed = []
+        self.suites_ok = 0
+        self.skips = {}
+        self.summaryfile = summaryfile
+        self.index = 0
+        self.name = None
+        self.totalsuites = totaltests
+
+    def testsuite_count(self, count):
+        self.totalsuites = count
+
+    def report_time(self, time):
+        if self.start_time is None:
+            self.start_time = time
+        self.last_time = time
+
+    def start_testsuite(self, name):
+        self.index += 1
+        self.name = name
+        testsuite_start_time = self.last_time
+
+        duration = testsuite_start_time - self.start_time
+
+        if not self.verbose:
+            self.test_output[name] = "" 
+
+        out = "[%d" % self.index
+        if self.totalsuites is not None:
+            out += "/%d" % self.totalsuites
+        out += " in %ds" % duration
+        if self.suitesfailed:
+            out += ", %d errors" % (len(self.suitesfailed),)
+        out += "] %s" % name 
+        if self.immediate:
+            sys.stdout.write(out + "\n")
+        else:
+            sys.stdout.write(out + ": ")
+
+    def output_msg(self, output):
+        if self.verbose:
+            sys.stdout.write(output)
+        elif self.name is not None:
+            self.test_output[self.name] += output
+        else:
+            sys.stdout.write(output)
+
+    def control_msg(self, output):
+        #$self->output_msg($output)
+        pass
+
+    def end_testsuite(self, name, result, reason):
+        out = ""
+        unexpected = 0
+
+        if not name in self.test_output:
+            print "no output for name[%s]" % name
+
+        if result in ("success", "xfail"):
+            self.suites_ok+=1
+        else:
+            self.output_msg("ERROR: Testsuite[%s]\nREASON: %s\n" % (name, reason))
+            self.suitesfailed.append(name)
+            if self.immediate and not self.verbose:
+                out += self.test_output[name]
+            unexpected = 1
+
+        if not self.immediate:
+            if not unexpected:
+                out += " ok\n"
+            else:
+                out += " " + result.upper() + "\n"
+
+        sys.stdout.write(out)
+
+    def start_test(self, testname):
+        pass
+
+    def end_test(self, testname, result, unexpected, reason):
+        if not unexpected:
+            self.test_output[self.name] = ""
+            if not self.immediate:
+                sys.stdout.write({
+                    'failure': 'f',
+                    'xfail': 'X',
+                    'skip': 's',
+                    'success': '.'}.get(result, "?(%s)" % result))
+            return
+
+        reason = reason.strip()
+
+        self.test_output[self.name] += "UNEXPECTED(%s): %s\nREASON: %s\n" % (result, testname, reason)
+
+        if self.immediate and not self.verbose:
+            print self.test_output[self.name]
+            self.test_output[self.name] = ""
+
+        if not self.immediate:
+            sys.stdout.write({
+               'error': 'E',
+               'failure': 'F',
+               'success': 'S'}.get(result, "?"))
+
+    def summary(self):
+        f = open(self.summaryfile, 'w+')
+
+        if self.suitesfailed:
+            f.write("= Failed tests =\n")
+
+            for suite in self.suitesfailed:
+                f.write("== %s ==\n" % suite)
+                f.write(self.test_output[suite]+"\n\n")
+
+            f.write("\n")
+
+        if not self.immediate and not self.verbose:
+            for suite in self.suitesfailed:
+                print "=" * 78
+                print "FAIL: %s" % suite
+                print self.test_output[suite]
+                print ""
+
+        f.write("= Skipped tests =\n")
+        for reason in self.skips.keys():
+            f.write(reason + "\n")
+            for name in self.skips[reason]:
+                f.write("\t%s\n" % name)
+            f.write("\n")
+        f.close()
+
+        print "\nA summary with detailed information can be found in:"
+        print "  %s" % self.summaryfile
+
+        if not self.suitesfailed:
+            ok = (self.statistics['TESTS_EXPECTED_OK'] +
+                  self.statistics['TESTS_EXPECTED_FAIL'])
+            print "\nALL OK (%d tests in %d testsuites)" % (ok, self.suites_ok)
+        else:
+            print "\nFAILED (%d failures and %d errors in %d testsuites)" % (
+                self.statistics['TESTS_UNEXPECTED_FAIL'],
+                self.statistics['TESTS_ERROR'],
+                len(self.suitesfailed))
+
+    def skip_testsuite(self, name, reason="UNKNOWN"):
+        self.skips.setdefault(reason, []).append(name)
+        if self.totalsuites:
+            self.totalsuites-=1
+
+parser = optparse.OptionParser("format-subunit [options]")
+parser.add_option("--verbose", action="store_true",
+    help="Be verbose")
+parser.add_option("--immediate", action="store_true", 
+    help="Show failures immediately, don't wait until test run has finished")
+parser.add_option("--prefix", type="string", default=".",
+    help="Prefix to write summary to")
+
+opts, args = parser.parse_args()
+
+statistics = {
+    'SUITES_FAIL': 0,
+    'TESTS_UNEXPECTED_OK': 0,
+    'TESTS_EXPECTED_OK': 0,
+    'TESTS_UNEXPECTED_FAIL': 0,
+    'TESTS_EXPECTED_FAIL': 0,
+    'TESTS_ERROR': 0,
+    'TESTS_SKIP': 0,
+}
+
+msg_ops = PlainFormatter(os.path.join(opts.prefix, "summary"), opts.verbose,
+    opts.immediate, statistics)
+
+expected_ret = subunithelper.parse_results(msg_ops, statistics, sys.stdin)
+
+msg_ops.summary()
+
+sys.exit(expected_ret)
diff --git a/selftest/output/plain.pm b/selftest/output/plain.pm
deleted file mode 100644
index eae1e7a..0000000
--- a/selftest/output/plain.pm
+++ /dev/null
@@ -1,246 +0,0 @@
-#!/usr/bin/perl
-# Plain text output for selftest
-# Copyright (C) 2008-2009 Jelmer Vernooij <jelmer at samba.org>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-package output::plain;
-use Exporter;
- at ISA = qw(Exporter);
-
-use FindBin qw($RealBin);
-use lib "$RealBin/..";
-
-use strict;
-
-sub new($$$$$$$) {
-	my ($class, $summaryfile, $verbose, $immediate, $statistics, $totaltests) = @_;
-	my $self = { 
-		verbose => $verbose, 
-		immediate => $immediate, 
-		statistics => $statistics,
-		start_time => undef,
-		test_output => {},
-		suitesfailed => [],
-		suites_ok => 0,
-		skips => {},
-		summaryfile => $summaryfile,
-		index => 0,
-		totalsuites => $totaltests,
-	};
-	bless($self, $class);
-}
-
-sub testsuite_count($$)
-{
-	my ($self, $count) = @_;
-	$self->{totalsuites} = $count;
-}
-
-sub report_time($$)
-{
-	my ($self, $time) = @_;
-	unless ($self->{start_time}) {
-		$self->{start_time} = $time;
-	}
-	$self->{last_time} = $time;
-}
-
-sub output_msg($$);
-
-sub start_testsuite($$)
-{
-	my ($self, $name) = @_;
-
-	$self->{index}++;
-	$self->{NAME} = $name;
-	$self->{START_TIME} = $self->{last_time};
-
-	my $duration = $self->{START_TIME} - $self->{start_time};
-
-	$self->{test_output}->{$name} = "" unless($self->{verbose});
-
-	my $out = "";
-	$out .= "[$self->{index}";
-	if ($self->{totalsuites}) {
-		$out .= "/$self->{totalsuites}";
-	}
-	$out.= " in ".$duration."s";
-	$out .= sprintf(", %d errors", ($#{$self->{suitesfailed}}+1)) if ($#{$self->{suitesfailed}} > -1);
-	$out .= "] $name"; 
-	if ($self->{immediate}) {
-		print "$out\n";
-	} else {
-		print "$out: ";
-	}
-}
-
-sub output_msg($$)
-{
-	my ($self, $output) = @_;
-
-	if ($self->{verbose}) {
-		require FileHandle;
-		print $output;
-		STDOUT->flush();
-	} elsif (defined($self->{NAME})) {
-		$self->{test_output}->{$self->{NAME}} .= $output;
-	} else {
-		print $output;
-	}
-}
-
-sub control_msg($$)
-{
-	my ($self, $output) = @_;
-


-- 
Samba Shared Repository


More information about the samba-cvs mailing list