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

Aaron Griffin aaron at archlinux.org
Mon Mar 5 13:06:12 EST 2007


    Date: Monday, March 5, 2007 @ 13:06:12
  Author: aaron
    Path: /home/cvs-pacman/pacman-lib/pactest

Modified: pactest.py (1.8 -> 1.9) pmdb.py (1.5 -> 1.6) pmpkg.py (1.4 -> 1.5)
          pmrule.py (1.5 -> 1.6) pmtest.py (1.5 -> 1.6) util.py (1.4 -> 1.5)

* Fixed an issue with globbing the --test argument
* Added a custom 'mkdir' function which makes parents and doesn't fail on
  existence
* Added output for 'SKIP' messages (it did not indicate WHY it was skipped)
* Added the ability to generate DB packages in the sync dir (not the cache dir)
  for testing downloading.  (self.cachepkgs = False)
* Added pmtest.path for the full path to the package file


------------+
 pactest.py |    3 ++-
 pmdb.py    |    5 ++---
 pmpkg.py   |    8 ++++++--
 pmrule.py  |    4 ++++
 pmtest.py  |   19 ++++++++++---------
 util.py    |   10 ++++++++++
 6 files changed, 34 insertions(+), 15 deletions(-)


Index: pacman-lib/pactest/pactest.py
diff -u pacman-lib/pactest/pactest.py:1.8 pacman-lib/pactest/pactest.py:1.9
--- pacman-lib/pactest/pactest.py:1.8	Fri Feb 23 00:12:58 2007
+++ pacman-lib/pactest/pactest.py	Mon Mar  5 13:06:12 2007
@@ -36,7 +36,8 @@
     globlist = []
 
     # maintain the idx so we can modify rargs
-    while not parser.rargs[idx].startswith('-'):
+    while idx < len(parser.rargs) and \
+            not parser.rargs[idx].startswith('-'):
         globlist += glob.glob(parser.rargs[idx])
         idx += 1
 
Index: pacman-lib/pactest/pmdb.py
diff -u pacman-lib/pactest/pmdb.py:1.5 pacman-lib/pactest/pmdb.py:1.6
--- pacman-lib/pactest/pmdb.py:1.5	Wed Feb 28 11:37:24 2007
+++ pacman-lib/pactest/pmdb.py	Mon Mar  5 13:06:12 2007
@@ -219,8 +219,7 @@
         """
 
         path = os.path.join(self.dbdir, self.treename, pkg.fullname())
-        if not os.path.isdir(path):
-            os.makedirs(path);
+        mkdir(path)
 
         # desc
         # for local db entries: name, version, desc, groups, url, license,
@@ -332,7 +331,7 @@
             mkdescfile(pkg.fullname(), pkg)
 
         # Generate database archive
-        os.makedirs(path, 0755)
+        mkdir(path)
         archive = os.path.join(path, "%s%s" % (self.treename, PM_EXT_DB))
         os.system("tar zcf %s *" % archive)
 
Index: pacman-lib/pactest/pmpkg.py
diff -u pacman-lib/pactest/pmpkg.py:1.4 pacman-lib/pactest/pmpkg.py:1.5
--- pacman-lib/pactest/pmpkg.py:1.4	Tue Feb 27 11:25:01 2007
+++ pacman-lib/pactest/pmpkg.py	Mon Mar  5 13:06:12 2007
@@ -33,6 +33,7 @@
     """
 
     def __init__(self, name, version = "1.0-1"):
+        self.path = "" #the path of the generated package
         # desc
         self.name = name
         self.version = version
@@ -116,7 +117,7 @@
         A package archive is generated in the location 'path', based on the data
         from the object.
         """
-        archive = os.path.join(path, self.filename())
+        self.path = os.path.join(path, self.filename())
 
         curdir = os.getcwd()
         tmpdir = tempfile.mkdtemp()
@@ -172,8 +173,11 @@
             os.system("touch .FILELIST")
             targets += " .FILELIST"
 
+        #safely create the dir
+        mkdir(os.path.dirname(self.path))
+
         # Generate package archive
-        os.system("tar zcf %s %s" % (archive, targets))
+        os.system("tar zcf %s %s" % (self.path, targets))
 
         os.chdir(curdir)
         shutil.rmtree(tmpdir)
Index: pacman-lib/pactest/pmrule.py
diff -u pacman-lib/pactest/pmrule.py:1.5 pacman-lib/pactest/pmrule.py:1.6
--- pacman-lib/pactest/pmrule.py:1.5	Wed Feb 28 11:37:24 2007
+++ pacman-lib/pactest/pmrule.py	Mon Mar  5 13:06:12 2007
@@ -57,6 +57,7 @@
                 if not grep(os.path.join(root, LOGFILE), key):
                     success = 0
             else:
+                print "PACMAN rule '%s' not found" % case
                 success = -1
         elif kind == "PKG":
             newpkg = localdb.db_read(key)
@@ -100,6 +101,7 @@
                     if not found:
                         success = 0
                 else:
+                    print "PKG rule '%s' not found" % case
                     success = -1
         elif kind == "FILE":
             filename = os.path.join(root, key)
@@ -122,8 +124,10 @@
                     if not os.path.isfile("%s%s" % (filename, PM_PACSAVE)):
                         success = 0
                 else:
+                    print "FILE rule '%s' not found" % case
                     success = -1
         else:
+            print "Rule kind '%s' not found" % kind
             success = -1
 
         if self.false and success != -1:
Index: pacman-lib/pactest/pmtest.py
diff -u pacman-lib/pactest/pmtest.py:1.5 pacman-lib/pactest/pmtest.py:1.6
--- pacman-lib/pactest/pmtest.py:1.5	Mon Feb 26 03:19:03 2007
+++ pacman-lib/pactest/pmtest.py	Mon Mar  5 13:06:12 2007
@@ -38,6 +38,7 @@
         self.name = name
         self.testname = os.path.basename(name).replace('.py', '')
         self.root = root
+        self.cachepkgs = True
 
     def __str__(self):
         return "name = %s\n" \
@@ -130,14 +131,15 @@
             vprint("\t%s" % os.path.join(TMPDIR, pkg.filename()))
             pkg.makepkg(tmpdir)
         for key, value in self.db.iteritems():
-            if key == "local":
-                continue
+            if key == "local": continue
             for pkg in value.pkgs:
-                archive = pkg.filename()
-                vprint("\t%s" % os.path.join(PM_CACHEDIR, archive))
-                pkg.makepkg(cachedir)
-                pkg.md5sum = getmd5sum(os.path.join(cachedir, archive))
-                pkg.csize = os.stat(os.path.join(cachedir, archive))[stat.ST_SIZE]
+                vprint("\t%s" % os.path.join(PM_CACHEDIR, pkg.filename()))
+                if self.cachepkgs:
+                    pkg.makepkg(cachedir)
+                else:
+                    pkg.makepkg(os.path.join(syncdir, value.treename))
+                pkg.md5sum = getmd5sum(pkg.path)
+                pkg.csize = os.stat(pkg.path)[stat.ST_SIZE]
 
         # Populating databases
         vprint("    Populating databases")
@@ -151,8 +153,7 @@
         # Creating sync database archives
         vprint("    Creating sync database archives")
         for key, value in self.db.iteritems():
-            if key == "local":
-                continue
+            if key == "local": continue
             archive = value.treename + PM_EXT_DB
             vprint("\t" + os.path.join(SYNCREPO, archive))
             value.gensync(os.path.join(syncdir, value.treename))
Index: pacman-lib/pactest/util.py
diff -u pacman-lib/pactest/util.py:1.4 pacman-lib/pactest/util.py:1.5
--- pacman-lib/pactest/util.py:1.4	Wed Feb 28 11:37:24 2007
+++ pacman-lib/pactest/util.py	Mon Mar  5 13:06:12 2007
@@ -247,6 +247,16 @@
     fd.close()
     return found
 
+def mkdir(dir):
+    if os.path.isdir(dir):
+        return
+    elif os.path.isfile(dir):
+        raise OSError("'%s' already exists and is not a directory" % dir)
+    else:
+        parent, thisdir = os.path.split(dir)
+        if parent: mkdir(parent) #recurse to make all parents
+        print "making dir %s" % thisdir
+        if thisdir: os.mkdir(dir)
 
 if __name__ == "__main__":
     pass




More information about the pacman-dev mailing list