1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-23 00:08:50 -05:00

* 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)
This commit is contained in:
Aaron Griffin 2007-02-26 08:19:02 +00:00
parent 4a75e42f12
commit 25223d6790
6 changed files with 38 additions and 34 deletions

View File

@ -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" \

View File

@ -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")

View File

@ -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]):

View File

@ -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":

View File

@ -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

View File

@ -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
#