diff options
author | Rafael H. Schloming <rhs@apache.org> | 2009-08-11 15:40:19 +0000 |
---|---|---|
committer | Rafael H. Schloming <rhs@apache.org> | 2009-08-11 15:40:19 +0000 |
commit | e419dd6f187b5d135701f17f4b4382ece95068e5 (patch) | |
tree | 7c895aa61cbb9b926f3a0c6cecbc17e4e1989944 /qpid/python/qpid-python-test | |
parent | f92d8f621534d0ae704101f8a38110fedbff39af (diff) | |
download | qpid-python-e419dd6f187b5d135701f17f4b4382ece95068e5.tar.gz |
- removed old and redundent tests
- removed old test harness in favor of qpid-python-test
- modified qpid-python-test to support "skipped" tests, these are
tests that failed due to an anticipated environmental reason such
as the broker is not running or it is the wrong version
- modified the qpid-python-test harness to exit with appropriate
error codes based on the test results
- modified the python clients to report version mismatches rather
than framing errors
- made qpid_config provide variables for 0-8, 0-9, and 0-10 versions
of the spec
- modified the 0-10 client to directly codegen classes
- added new 0-10 framing layer based on push parsing rather than pull
parsing
- added numerous framing tests
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@803168 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python/qpid-python-test')
-rwxr-xr-x | qpid/python/qpid-python-test | 76 |
1 files changed, 57 insertions, 19 deletions
diff --git a/qpid/python/qpid-python-test b/qpid/python/qpid-python-test index 3bf0e6ccce..b9e69c782e 100755 --- a/qpid/python/qpid-python-test +++ b/qpid/python/qpid-python-test @@ -25,6 +25,7 @@ from fnmatch import fnmatchcase as match from getopt import GetoptError from logging import getLogger, StreamHandler, Formatter, Filter, \ WARN, DEBUG, ERROR +from qpid.harness import Skipped from qpid.util import URL levels = { @@ -101,7 +102,7 @@ for a in args: includes.append(a.strip()) if not includes: - includes.append("*") + includes.extend(["qpid.tests.*", "tests.*", "tests_0-10.*"]) def is_ignored(path): for p in excludes: @@ -142,6 +143,7 @@ def vt100_attrs(*attrs): vt100_reset = vt100_attrs(0) KEYWORDS = {"pass": (32,), + "skip": (33,), "fail": (31,), "start": (34,), "total": (34,), @@ -165,9 +167,6 @@ def indent(text): lines = text.split("\n") return " %s" % "\n ".join(lines) -from qpid.testlib import testrunner -testrunner.setBroker(str(config.broker)) - class Interceptor: def __init__(self): @@ -264,16 +263,27 @@ root.setLevel(WARN) log = getLogger("qpid.test") +PASS = "pass" +SKIP = "skip" +FAIL = "fail" + class Runner: def __init__(self): self.exceptions = [] + self.skip = False def passed(self): return not self.exceptions + def skipped(self): + return self.skip + def failed(self): - return self.exceptions + return self.exceptions and not self.skip + + def halt(self): + return self.exceptions or self.skip def run(self, name, phase): try: @@ -281,18 +291,28 @@ class Runner: except KeyboardInterrupt: raise except: - self.exceptions.append((name, sys.exc_info())) + exi = sys.exc_info() + if issubclass(exi[0], Skipped): + self.skip = True + self.exceptions.append((name, exi)) def status(self): if self.passed(): - return "pass" + return PASS + elif self.skipped(): + return SKIP + elif self.failed(): + return FAIL else: - return "fail" + return None def print_exceptions(self): for name, info in self.exceptions: - print "Error during %s:" % name - print indent("".join(traceback.format_exception(*info))).rstrip() + if issubclass(info[0], Skipped): + print indent("".join(traceback.format_exception_only(*info[:2]))).rstrip() + else: + print "Error during %s:" % name + print indent("".join(traceback.format_exception(*info))).rstrip() ST_WIDTH = 8 @@ -329,11 +349,11 @@ def run_test(name, test, config): sys.stdout.write("\n") sys.stdout.write(output) print " %s" % colorize_word(runner.status()) - if runner.failed(): + if runner.failed() or runner.skipped(): runner.print_exceptions() root.setLevel(level) filter.patterns = patterns - return runner.passed() + return runner.status() class FunctionTest: @@ -373,13 +393,13 @@ class MethodTest: if hasattr(inst, "configure"): runner.run("configure", lambda: inst.configure(config)) - if runner.failed(): return runner + if runner.halt(): return runner if hasattr(inst, "setUp"): runner.run("setup", inst.setUp) - if runner.failed(): return runner + if runner.halt(): return runner elif hasattr(inst, "setup"): runner.run("setup", inst.setup) - if runner.failed(): return runner + if runner.halt(): return runner runner.run("test", test) @@ -473,7 +493,7 @@ class Harness: objects.append(child) self.scanned.append(obj) -modules = "qpid.tests", "tests", "tests_0-10" +modules = "qpid.tests", "tests", "tests_0-8", "tests_0-9", "tests_0-10" h = Harness() for name in modules: m = __import__(name, None, None, ["dummy"]) @@ -485,13 +505,17 @@ total = len(filtered) + len(ignored) passed = 0 failed = 0 +skipped = 0 for t in filtered: if list_only: print t.name() else: - if t.run(): + st = t.run() + if st == PASS: passed += 1 - else: + elif st == SKIP: + skipped += 1 + elif st == FAIL: failed += 1 if opts.hoe: break @@ -499,6 +523,10 @@ for t in filtered: run = passed + failed if not list_only: + if passed: + _pass = "pass" + else: + _pass = "fail" if failed: outcome = "fail" else: @@ -507,12 +535,22 @@ if not list_only: ign = "ignored" else: ign = "pass" + if skipped: + skip = "skip" + else: + skip = "pass" print colorize("Totals:", 1), \ colorize_word("total", "%s tests" % total) + ",", \ - colorize_word("pass", "%s passed" % passed) + ",", \ + colorize_word(_pass, "%s passed" % passed) + ",", \ + colorize_word(skip, "%s skipped" % skipped) + ",", \ colorize_word(ign, "%s ignored" % len(ignored)) + ",", \ colorize_word(outcome, "%s failed" % failed), if opts.hoe and failed > 0: print " -- (halted after %s)" % run else: print + +if failed or skipped: + sys.exit(1) +else: + sys.exit(0) |