mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 08:18:51 -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:
parent
4a75e42f12
commit
25223d6790
@ -344,8 +344,8 @@ class pmdb:
|
|||||||
if not oldpkg:
|
if not oldpkg:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
#dbg("oldpkg.checksum : %s" % oldpkg.checksum)
|
vprint("\toldpkg.checksum : %s" % oldpkg.checksum)
|
||||||
#dbg("oldpkg.mtime : %s" % oldpkg.mtime)
|
vprint("\toldpkg.mtime : %s" % oldpkg.mtime)
|
||||||
|
|
||||||
for key in pkg.mtime.keys():
|
for key in pkg.mtime.keys():
|
||||||
if key == "install" \
|
if key == "install" \
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import os.path
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import pmtest
|
import pmtest
|
||||||
@ -59,7 +60,7 @@ class pmenv:
|
|||||||
|
|
||||||
for t in self.testcases:
|
for t in self.testcases:
|
||||||
print "=========="*8
|
print "=========="*8
|
||||||
print "Running '%s'" % t.name.replace(".py", "")
|
print "Running '%s'" % t.testname
|
||||||
|
|
||||||
t.load()
|
t.load()
|
||||||
print t.description
|
print t.description
|
||||||
@ -88,33 +89,42 @@ class pmenv:
|
|||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
passed = 0
|
passed = 0
|
||||||
print "=========="*8
|
tpassed = []
|
||||||
print "Results"
|
tfailed = []
|
||||||
print "----------"*8
|
|
||||||
for test in self.testcases:
|
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"]
|
success = test.result["success"]
|
||||||
fail = test.result["fail"]
|
fail = test.result["fail"]
|
||||||
rules = len(test.rules)
|
rules = len(test.rules)
|
||||||
if fail == 0:
|
if fail == 0:
|
||||||
print "[PASSED]",
|
print "[PASSED]",
|
||||||
passed += 1
|
|
||||||
else:
|
else:
|
||||||
print "[FAILED]",
|
print "[FAILED]",
|
||||||
print test.name.replace(".py", "").ljust(33),
|
print "%s Rules:OK = %2u FAIL = %2u SKIP = %2u" \
|
||||||
print "Rules:",
|
% (test.testname.ljust(32), success, fail, rules - (success + fail))
|
||||||
print "OK = %2u FAIL = %2u SKIP = %2u" % \
|
|
||||||
(success, fail, rules - (success + fail))
|
print "=========="*8
|
||||||
|
print "Results"
|
||||||
print "----------"*8
|
print "----------"*8
|
||||||
|
for test in tpassed: _printtest(test)
|
||||||
|
print "----------"*8
|
||||||
|
for test in tfailed: _printtest(test)
|
||||||
|
print "----------"*8
|
||||||
|
|
||||||
total = len(self.testcases)
|
total = len(self.testcases)
|
||||||
failed = total - passed
|
failed = total - passed
|
||||||
print "TOTAL = %3u" % total
|
print "TOTAL = %3u" % total
|
||||||
if total:
|
if total:
|
||||||
print "PASSED = %3u (%6.2f%%)" % \
|
print "PASSED = %3u (%6.2f%%)" % (passed, float(passed) * 100 / total)
|
||||||
(passed, float(passed) * 100 / total)
|
print "FAILED = %3u (%6.2f%%)" % (failed, float(failed) * 100 / total)
|
||||||
print "FAILED = %3u (%6.2f%%)" % \
|
print ""
|
||||||
(failed, float(failed) * 100 / total)
|
|
||||||
print
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
env = pmenv("/tmp")
|
env = pmenv("/tmp")
|
||||||
|
@ -48,10 +48,9 @@ class pmfile:
|
|||||||
checksum = getmd5sum(filename)
|
checksum = getmd5sum(filename)
|
||||||
mtime = getmtime(filename)
|
mtime = getmtime(filename)
|
||||||
|
|
||||||
if debug:
|
vprint("\tismodified(%s)" % self.name)
|
||||||
print "ismodified(%s)" % self.name
|
vprint("\t\told: %s / %s" % (self.checksum, self.mtime))
|
||||||
print "old: %s / %s" % (self.checksum, self.mtime)
|
vprint("\t\tnew: %s / %s" % (checksum, mtime))
|
||||||
print "new: %s / %s" % (checksum, mtime)
|
|
||||||
|
|
||||||
if not self.checksum == checksum \
|
if not self.checksum == checksum \
|
||||||
or not (self.mtime[1], self.mtime[2]) == (mtime[1], mtime[2]):
|
or not (self.mtime[1], self.mtime[2]) == (mtime[1], mtime[2]):
|
||||||
|
@ -63,8 +63,8 @@ class pmrule:
|
|||||||
if not newpkg:
|
if not newpkg:
|
||||||
success = 0
|
success = 0
|
||||||
else:
|
else:
|
||||||
#dbg("newpkg.checksum : %s" % newpkg.checksum)
|
vprint("\tnewpkg.checksum : %s" % newpkg.checksum)
|
||||||
#dbg("newpkg.mtime : %s" % newpkg.mtime)
|
vprint("\tnewpkg.mtime : %s" % newpkg.mtime)
|
||||||
if case == "EXIST":
|
if case == "EXIST":
|
||||||
success = 1
|
success = 1
|
||||||
elif case == "MODIFIED":
|
elif case == "MODIFIED":
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import os.path
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -35,11 +36,13 @@ class pmtest:
|
|||||||
|
|
||||||
def __init__(self, name, root):
|
def __init__(self, name, root):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
self.testname = os.path.basename(name).replace('.py', '')
|
||||||
self.root = root
|
self.root = root
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "name = %s\n" \
|
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):
|
def addpkg2db(self, treename, pkg):
|
||||||
"""
|
"""
|
||||||
@ -197,7 +200,7 @@ class pmtest:
|
|||||||
cmd.append("%s" % self.args)
|
cmd.append("%s" % self.args)
|
||||||
if not pacman["gdb"] and not pacman["valgrind"] and not pacman["nolog"]:
|
if not pacman["gdb"] and not pacman["valgrind"] and not pacman["nolog"]:
|
||||||
cmd.append(">%s 2>&1" % os.path.join(self.root, LOGFILE))
|
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
|
# Change to the tmp dir before running pacman, so that local package
|
||||||
# archives are made available more easily.
|
# archives are made available more easily.
|
||||||
@ -214,7 +217,7 @@ class pmtest:
|
|||||||
self.retcode = 0
|
self.retcode = 0
|
||||||
else:
|
else:
|
||||||
self.retcode /= 256
|
self.retcode /= 256
|
||||||
dbg("retcode = %s" % self.retcode)
|
vprint("\tretcode = %s" % self.retcode)
|
||||||
os.chdir(curdir)
|
os.chdir(curdir)
|
||||||
|
|
||||||
# Check if pacman failed because of bad permissions
|
# Check if pacman failed because of bad permissions
|
||||||
|
@ -43,10 +43,7 @@ TMPDIR = "tmp"
|
|||||||
SYNCREPO = "var/pub"
|
SYNCREPO = "var/pub"
|
||||||
LOGFILE = "var/log/pactest.log"
|
LOGFILE = "var/log/pactest.log"
|
||||||
|
|
||||||
|
|
||||||
verbose = 0
|
verbose = 0
|
||||||
debug = 1
|
|
||||||
|
|
||||||
|
|
||||||
def err(msg):
|
def err(msg):
|
||||||
print "error: " + msg
|
print "error: " + msg
|
||||||
@ -56,11 +53,6 @@ def vprint(msg):
|
|||||||
if verbose:
|
if verbose:
|
||||||
print msg
|
print msg
|
||||||
|
|
||||||
def dbg(msg):
|
|
||||||
if debug:
|
|
||||||
print msg
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Methods to generate files
|
# Methods to generate files
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user