s3-epmapper: Shutdown the embedded epmapper cleanly.
[idra/samba.git] / selftest / format-subunit
index 2224b71191cdc0871857db8824795799422391ba..b927e95ae483fd231966b76d4457291781df288b 100755 (executable)
@@ -1,77 +1,52 @@
-#!/usr/bin/perl
+#!/usr/bin/env python
+# vim: expandtab
 # Pretty-format subunit output
-# Copyright (C) Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2008-2010 Jelmer Vernooij <jelmer@samba.org>
 # Published under the GNU GPL, v3 or later
 
-=pod
+import optparse
+import os
+import signal
+import sys
 
-=head1 NAME
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../lib/subunit/python"))
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../lib/testtools"))
 
-format-subunit [--immediate] < instream > outstream
+import subunithelper
 
-=head1 SYNOPSIS
+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")
 
-Format the output of a subunit stream.
+opts, args = parser.parse_args()
 
-=head1 OPTIONS
+def handle_sigint(sig, stack):
+       sys.exit(0)
+signal.signal(signal.SIGINT, handle_sigint)
 
-=over 4
+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,
+}
 
-=item I<--immediate>
+msg_ops = subunithelper.PlainFormatter(opts.verbose, opts.immediate, statistics)
 
-Show errors as soon as they happen rather than at the end of the test run.
+expected_ret = subunithelper.parse_results(msg_ops, statistics, sys.stdin)
 
-=head1 LICENSE
+summaryfile = os.path.join(opts.prefix, "summary")
 
-GNU General Public License, version 3 or later.
+msg_ops.write_summary(summaryfile)
 
-=head1 AUTHOR
+print "\nA summary with detailed information can be found in:"
+print "  %s" % summaryfile
 
-Jelmer Vernooij <jelmer@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);
+sys.exit(expected_ret)