[pacman-dev] CVS update of pacman-lib/pactest (6 files)

Aaron Griffin aaron at archlinux.org
Mon Feb 26 03:19:03 EST 2007


    Date: Monday, February 26, 2007 @ 03:19:03
  Author: aaron
    Path: /home/cvs-pacman/pacman-lib/pactest

Modified: pmdb.py (1.2 -> 1.3) pmenv.py (1.5 -> 1.6) pmfile.py (1.2 -> 1.3)
          pmrule.py (1.2 -> 1.3) pmtest.py (1.4 -> 1.5) util.py (1.2 -> 1.3)

* 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)


-----------+
 pmdb.py   |    4 ++--
 pmenv.py  |   40 +++++++++++++++++++++++++---------------
 pmfile.py |    7 +++----
 pmrule.py |    4 ++--
 pmtest.py |    9 ++++++---
 util.py   |    8 --------
 6 files changed, 38 insertions(+), 34 deletions(-)


Index: pacman-lib/pactest/pmdb.py
diff -u pacman-lib/pactest/pmdb.py:1.2 pacman-lib/pactest/pmdb.py:1.3
--- pacman-lib/pactest/pmdb.py:1.2	Wed Feb 21 01:33:13 2007
+++ pacman-lib/pactest/pmdb.py	Mon Feb 26 03:19:02 2007
@@ -344,8 +344,8 @@
         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" \
Index: pacman-lib/pactest/pmenv.py
diff -u pacman-lib/pactest/pmenv.py:1.5 pacman-lib/pactest/pmenv.py:1.6
--- pacman-lib/pactest/pmenv.py:1.5	Fri Feb 23 01:50:42 2007
+++ pacman-lib/pactest/pmenv.py	Mon Feb 26 03:19:02 2007
@@ -19,6 +19,7 @@
 
 
 import os
+import os.path
 import time
 
 import pmtest
@@ -59,7 +60,7 @@
 
         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 @@
         """
         """
         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")
Index: pacman-lib/pactest/pmfile.py
diff -u pacman-lib/pactest/pmfile.py:1.2 pacman-lib/pactest/pmfile.py:1.3
--- pacman-lib/pactest/pmfile.py:1.2	Wed Feb 21 01:33:13 2007
+++ pacman-lib/pactest/pmfile.py	Mon Feb 26 03:19:02 2007
@@ -48,10 +48,9 @@
         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]):
Index: pacman-lib/pactest/pmrule.py
diff -u pacman-lib/pactest/pmrule.py:1.2 pacman-lib/pactest/pmrule.py:1.3
--- pacman-lib/pactest/pmrule.py:1.2	Wed Feb 21 01:33:13 2007
+++ pacman-lib/pactest/pmrule.py	Mon Feb 26 03:19:02 2007
@@ -63,8 +63,8 @@
             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":
Index: pacman-lib/pactest/pmtest.py
diff -u pacman-lib/pactest/pmtest.py:1.4 pacman-lib/pactest/pmtest.py:1.5
--- pacman-lib/pactest/pmtest.py:1.4	Thu Feb 22 23:54:49 2007
+++ pacman-lib/pactest/pmtest.py	Mon Feb 26 03:19:03 2007
@@ -19,6 +19,7 @@
 
 
 import os
+import os.path
 import shutil
 import time
 
@@ -35,11 +36,13 @@
 
     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 @@
         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 @@
             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
Index: pacman-lib/pactest/util.py
diff -u pacman-lib/pactest/util.py:1.2 pacman-lib/pactest/util.py:1.3
--- pacman-lib/pactest/util.py:1.2	Wed Feb 21 01:33:13 2007
+++ pacman-lib/pactest/util.py	Mon Feb 26 03:19:03 2007
@@ -43,10 +43,7 @@
 SYNCREPO    = "var/pub"
 LOGFILE     = "var/log/pactest.log"
 
-
 verbose = 0
-debug = 1
-
 
 def err(msg):
     print "error: " + msg
@@ -56,11 +53,6 @@
     if verbose:
         print msg
 
-def dbg(msg):
-    if debug:
-        print msg
-
-
 #
 # Methods to generate files
 #




More information about the pacman-dev mailing list