summaryrefslogtreecommitdiff
path: root/selftest/filter-subunit
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-03-30 12:46:26 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-03-31 02:20:07 +0200
commit08161e093d38f0d7b54841f5572a024f228408fa (patch)
tree5f1daa746bda4a40cdeb55e41800f3dd1e7547c1 /selftest/filter-subunit
parentae5381d34c75918f7fa49654585d277bbfe66f49 (diff)
downloadsamba-08161e093d38f0d7b54841f5572a024f228408fa.tar.gz
samba-08161e093d38f0d7b54841f5572a024f228408fa.tar.bz2
samba-08161e093d38f0d7b54841f5572a024f228408fa.zip
selftest: Convert filter-subunit to Python so the subunit Python module
can be used later.
Diffstat (limited to 'selftest/filter-subunit')
-rwxr-xr-xselftest/filter-subunit44
1 files changed, 44 insertions, 0 deletions
diff --git a/selftest/filter-subunit b/selftest/filter-subunit
new file mode 100755
index 0000000000..e0774f211e
--- /dev/null
+++ b/selftest/filter-subunit
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+# Filter a subunit stream
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU GPL, v3 or later
+
+import optparse
+import subunithelper
+import sys
+import signal
+
+parser = optparse.OptionParser("filter-subunit [options] < instream > outstream")
+parser.add_option("--expected-failures", type="string",
+ help="File containing list of regexes matching tests to consider known "
+ "failures")
+parser.add_option("--strip-passed-output", action="store_true",
+ help="Whether to strip output from tests that passed")
+
+parser.add_option("--prefix", type="string",
+ help="Add prefix to all test names")
+
+opts, args = parser.parse_args()
+
+if opts.expected_failures:
+ expected_failures = list(subunithelper.read_test_regexes(opts.expected_failures))
+else:
+ expected_failures = []
+
+statistics = {
+ 'TESTS_UNEXPECTED_OK': 0,
+ 'TESTS_EXPECTED_OK': 0,
+ 'TESTS_UNEXPECTED_FAIL': 0,
+ 'TESTS_EXPECTED_FAIL': 0,
+ 'TESTS_ERROR': 0,
+ 'TESTS_SKIP': 0,
+}
+
+def handle_sigint(sig, stack):
+ sys.exit(0)
+signal.signal(signal.SIGINT, handle_sigint)
+
+msg_ops = subunithelper.FilterOps(opts.prefix, expected_failures,
+ opts.strip_passed_output)
+
+sys.exit(subunithelper.parse_results(msg_ops, statistics, sys.stdin))