pactest: allow checking for cache file existence
This will allow some tests to be added for cache cleaning. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
ed1aef7bc5
commit
2d5ec02d7c
2 changed files with 25 additions and 1 deletions
|
@ -146,6 +146,13 @@ class pmrule(object):
|
||||||
else:
|
else:
|
||||||
print "FILE rule '%s' not found" % case
|
print "FILE rule '%s' not found" % case
|
||||||
success = -1
|
success = -1
|
||||||
|
elif kind == "CACHE":
|
||||||
|
cachedir = os.path.join(test.root, util.PM_CACHEDIR)
|
||||||
|
if case == "EXISTS":
|
||||||
|
pkg = test.findpkg(key, value, allow_local=True)
|
||||||
|
if not pkg or not os.path.isfile(
|
||||||
|
os.path.join(cachedir, pkg.filename())):
|
||||||
|
success = 0
|
||||||
else:
|
else:
|
||||||
print "Rule kind '%s' not found" % kind
|
print "Rule kind '%s' not found" % kind
|
||||||
success = -1
|
success = -1
|
||||||
|
|
|
@ -55,6 +55,22 @@ class pmtest(object):
|
||||||
"""
|
"""
|
||||||
self.localpkgs.append(pkg)
|
self.localpkgs.append(pkg)
|
||||||
|
|
||||||
|
def findpkg(self, name, version, allow_local=False):
|
||||||
|
"""Find a package object matching the name and version specified in
|
||||||
|
either sync databases or the local package collection. The local database
|
||||||
|
is allowed to match if allow_local is True."""
|
||||||
|
for db in self.db.itervalues():
|
||||||
|
if db.treename == "local" and not allow_local:
|
||||||
|
continue
|
||||||
|
pkg = db.getpkg(name)
|
||||||
|
if pkg and pkg.version == version:
|
||||||
|
return pkg
|
||||||
|
for pkg in self.localpkgs:
|
||||||
|
if pkg.name == name and pkg.version == version:
|
||||||
|
return pkg
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
def addrule(self, rulename):
|
def addrule(self, rulename):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
|
@ -76,6 +92,7 @@ class pmtest(object):
|
||||||
"local": pmdb.pmdb("local", self.root)
|
"local": pmdb.pmdb("local", self.root)
|
||||||
}
|
}
|
||||||
self.localpkgs = []
|
self.localpkgs = []
|
||||||
|
self.createlocalpkgs = False
|
||||||
self.filesystem = []
|
self.filesystem = []
|
||||||
|
|
||||||
self.description = ""
|
self.description = ""
|
||||||
|
@ -131,7 +148,7 @@ class pmtest(object):
|
||||||
vprint("\t%s" % os.path.join(util.TMPDIR, pkg.filename()))
|
vprint("\t%s" % os.path.join(util.TMPDIR, pkg.filename()))
|
||||||
pkg.makepkg(tmpdir)
|
pkg.makepkg(tmpdir)
|
||||||
for key, value in self.db.iteritems():
|
for key, value in self.db.iteritems():
|
||||||
if key == "local":
|
if key == "local" and not self.createlocalpkgs:
|
||||||
continue
|
continue
|
||||||
for pkg in value.pkgs:
|
for pkg in value.pkgs:
|
||||||
vprint("\t%s" % os.path.join(util.PM_CACHEDIR, pkg.filename()))
|
vprint("\t%s" % os.path.join(util.PM_CACHEDIR, pkg.filename()))
|
||||||
|
|
Loading…
Add table
Reference in a new issue