summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2007-02-26 08:19:02 +0000
committerAaron Griffin <aaron@archlinux.org>2007-02-26 08:19:02 +0000
commit25223d679078dc756bbd8aea46f713259a4365ee (patch)
treef9775e7ac9e2f259d8dc4b2f86434264498276ba
parent4a75e42f124929d5e4d0d2e3f35869747227ba5f (diff)
* corrected (IMO) --debug usage with pactest. --debug is now passed straight
through to pacman, whereas --verbose affects the pactest output - this cleans up the standard test output significantly * sorted tests a bit better, sectioning off failed tests AFTER successful tests, to make it easier to see what failed at a glance * added a 'testname' member to pmtest, which strips path info (cleaner output)
-rwxr-xr-xpactest/pmdb.py4
-rwxr-xr-xpactest/pmenv.py40
-rwxr-xr-xpactest/pmfile.py7
-rwxr-xr-xpactest/pmrule.py4
-rwxr-xr-xpactest/pmtest.py9
-rwxr-xr-xpactest/util.py8
6 files changed, 38 insertions, 34 deletions
diff --git a/pactest/pmdb.py b/pactest/pmdb.py
index 1d5f7459..29d35ba1 100755
--- a/pactest/pmdb.py
+++ b/pactest/pmdb.py
@@ -344,8 +344,8 @@ class pmdb:
if not oldpkg:
return 0
- #dbg("oldpkg.checksum : %s" % oldpkg.checksum)
- #dbg("oldpkg.mtime : %s" % oldpkg.mtime)
+ vprint("\toldpkg.checksum : %s" % oldpkg.checksum)
+ vprint("\toldpkg.mtime : %s" % oldpkg.mtime)
for key in pkg.mtime.keys():
if key == "install" \
diff --git a/pactest/pmenv.py b/pactest/pmenv.py
index 9ea39676..9dfcf84f 100755
--- a/pactest/pmenv.py
+++ b/pactest/pmenv.py
@@ -19,6 +19,7 @@
import os
+import os.path
import time
import pmtest
@@ -59,7 +60,7 @@ class pmenv:
for t in self.testcases:
print "=========="*8
- print "Running '%s'" % t.name.replace(".py", "")
+ print "Running '%s'" % t.testname
t.load()
print t.description
@@ -88,33 +89,42 @@ class pmenv:
"""
"""
passed = 0
- print "=========="*8
- print "Results"
- print "----------"*8
+ tpassed = []
+ tfailed = []
for test in self.testcases:
+ fail = test.result["fail"]
+ if fail == 0:
+ passed += 1
+ tpassed.append(test)
+ else:
+ tfailed.append(test)
+
+ def _printtest(t):
success = test.result["success"]
fail = test.result["fail"]
rules = len(test.rules)
if fail == 0:
print "[PASSED]",
- passed += 1
else:
print "[FAILED]",
- print test.name.replace(".py", "").ljust(33),
- print "Rules:",
- print "OK = %2u FAIL = %2u SKIP = %2u" % \
- (success, fail, rules - (success + fail))
+ print "%s Rules:OK = %2u FAIL = %2u SKIP = %2u" \
+ % (test.testname.ljust(32), success, fail, rules - (success + fail))
+
+ print "=========="*8
+ print "Results"
print "----------"*8
+ for test in tpassed: _printtest(test)
+ print "----------"*8
+ for test in tfailed: _printtest(test)
+ print "----------"*8
+
total = len(self.testcases)
failed = total - passed
print "TOTAL = %3u" % total
if total:
- print "PASSED = %3u (%6.2f%%)" % \
- (passed, float(passed) * 100 / total)
- print "FAILED = %3u (%6.2f%%)" % \
- (failed, float(failed) * 100 / total)
- print
-
+ print "PASSED = %3u (%6.2f%%)" % (passed, float(passed) * 100 / total)
+ print "FAILED = %3u (%6.2f%%)" % (failed, float(failed) * 100 / total)
+ print ""
if __name__ == "__main__":
env = pmenv("/tmp")
diff --git a/pactest/pmfile.py b/pactest/pmfile.py
index 597c0992..71a0cd7c 100755
--- a/pactest/pmfile.py
+++ b/pactest/pmfile.py
@@ -48,10 +48,9 @@ class pmfile:
checksum = getmd5sum(filename)
mtime = getmtime(filename)
- if debug:
- print "ismodified(%s)" % self.name
- print "old: %s / %s" % (self.checksum, self.mtime)
- print "new: %s / %s" % (checksum, mtime)
+ vprint("\tismodified(%s)" % self.name)
+ vprint("\t\told: %s / %s" % (self.checksum, self.mtime))
+ vprint("\t\tnew: %s / %s" % (checksum, mtime))
if not self.checksum == checksum \
or not (self.mtime[1], self.mtime[2]) == (mtime[1], mtime[2]):
diff --git a/pactest/pmrule.py b/pactest/pmrule.py
index 43310bfd..78811957 100755
--- a/pactest/pmrule.py
+++ b/pactest/pmrule.py
@@ -63,8 +63,8 @@ class pmrule:
if not newpkg:
success = 0
else:
- #dbg("newpkg.checksum : %s" % newpkg.checksum)
- #dbg("newpkg.mtime : %s" % newpkg.mtime)
+ vprint("\tnewpkg.checksum : %s" % newpkg.checksum)
+ vprint("\tnewpkg.mtime : %s" % newpkg.mtime)
if case == "EXIST":
success = 1
elif case == "MODIFIED":
diff --git a/pactest/pmtest.py b/pactest/pmtest.py
index 629a5754..0b21ba40 100755
--- a/pactest/pmtest.py
+++ b/pactest/pmtest.py
@@ -19,6 +19,7 @@
import os
+import os.path
import shutil
import time
@@ -35,11 +36,13 @@ class pmtest:
def __init__(self, name, root):
self.name = name
+ self.testname = os.path.basename(name).replace('.py', '')
self.root = root
def __str__(self):
return "name = %s\n" \
- "root = %s" % (self.name, self.root)
+ "testname = %s\n" \
+ "root = %s" % (self.name, self.testname, self.root)
def addpkg2db(self, treename, pkg):
"""
@@ -197,7 +200,7 @@ class pmtest:
cmd.append("%s" % self.args)
if not pacman["gdb"] and not pacman["valgrind"] and not pacman["nolog"]:
cmd.append(">%s 2>&1" % os.path.join(self.root, LOGFILE))
- dbg(" ".join(cmd))
+ vprint("\trunning: %s" % " ".join(cmd))
# Change to the tmp dir before running pacman, so that local package
# archives are made available more easily.
@@ -214,7 +217,7 @@ class pmtest:
self.retcode = 0
else:
self.retcode /= 256
- dbg("retcode = %s" % self.retcode)
+ vprint("\tretcode = %s" % self.retcode)
os.chdir(curdir)
# Check if pacman failed because of bad permissions
diff --git a/pactest/util.py b/pactest/util.py
index 94c5f5cf..a633e869 100755
--- a/pactest/util.py
+++ b/pactest/util.py
@@ -43,10 +43,7 @@ TMPDIR = "tmp"
SYNCREPO = "var/pub"
LOGFILE = "var/log/pactest.log"
-
verbose = 0
-debug = 1
-
def err(msg):
print "error: " + msg
@@ -56,11 +53,6 @@ def vprint(msg):
if verbose:
print msg
-def dbg(msg):
- if debug:
- print msg
-
-
#
# Methods to generate files
#