-#! /usr/bin/python
+#! /usr/bin/python2
#
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-#
+# Copyright (c) 2006-2013 Pacman Developmet Team <pacman-dev@archlinux.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 2 of the License, or
import os
-import os.path
import pmtest
+import tap
-class pmenv:
+class pmenv(object):
"""Environment object
"""
def run(self):
"""
"""
-
+ tap.plan(len(self.testcases))
for t in self.testcases:
- print "=========="*8
- print "Running '%s'" % t.testname
+ tap.diag("Running '%s'" % t.testname)
t.load()
- print t.description
- print "----------"*8
-
- t.generate()
- # Hack for mtimes consistency
- for i in t.rules:
- if i.rule.find("FILE_MODIFIED") != -1:
- [test, arg] = i.rule.split("=")
- for f in t.files:
- if f.name == arg:
- f.resettimes()
-
+ t.generate(self.pacman)
t.run(self.pacman)
- t.check()
- print "==> Test result"
- if t.result["fail"] == 0:
- print "\tPASS"
- else:
- print "\tFAIL"
- print
-
- def results(self):
- """
- """
- tpassed = []
- tfailed = []
- texpectedfail = []
- tunexpectedpass = []
- for test in self.testcases:
- fail = test.result["fail"]
- if fail == 0 and not test.expectfailure:
- self.passed += 1
- tpassed.append(test)
- elif fail != 0 and test.expectfailure:
- self.expectedfail += 1
- texpectedfail.append(test)
- elif fail == 0: # and not test.expectfail
- self.unexpectedpass += 1
- tunexpectedpass.append(test)
- else:
- self.failed += 1
- tfailed.append(test)
-
- def _printtest(t):
- success = test.result["success"]
- fail = test.result["fail"]
- rules = len(test.rules)
- if fail == 0:
- result = "[PASS]"
- else:
- result = "[FAIL]"
- print result,
- print "%s Rules: OK = %2u FAIL = %2u SKIP = %2u" \
- % (test.testname.ljust(34), success, fail, \
- rules - (success + fail))
- if fail != 0:
- # print test description if test failed
- print " ", test.description
-
- print "=========="*8
- print "Results"
- print "----------"*8
- print " Passed:"
- for test in tpassed: _printtest(test)
- print "----------"*8
- print " Expected Failures:"
- for test in texpectedfail: _printtest(test)
- print "----------"*8
- print " Unexpected Passes:"
- for test in tunexpectedpass: _printtest(test)
- print "----------"*8
- print " Failed:"
- for test in tfailed: _printtest(test)
- print "----------"*8
-
- total = len(self.testcases)
- print "Total = %3u" % total
- if total:
- print "Pass = %3u (%6.2f%%)" % (self.passed, float(self.passed) * 100 / total)
- print "Expected Fail = %3u (%6.2f%%)" % (self.expectedfail, float(self.expectedfail) * 100 / total)
- print "Unexpected Pass = %3u (%6.2f%%)" % (self.unexpectedpass, float(self.unexpectedpass) * 100 / total)
- print "Fail = %3u (%6.2f%%)" % (self.failed, float(self.failed) * 100 / total)
- print ""
-
-if __name__ == "__main__":
- pass
+ tap.diag("==> Checking rules")
+ tap.todo = t.expectfailure
+ tap.subtest(lambda: t.check(), t.description)
# vim: set ts=4 sw=4 et: