summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-29 11:23:55 -0600
committerDan McGee <dan@archlinux.org>2011-01-29 12:15:15 -0600
commitce089e1b975e99f6a35c159f51d0dbe7c0ddcca3 (patch)
treea99abfb338d7a6f65ae17acc3e804d193f3c0b0b /test
parentef86da97f54a90ee4ba3ba8ea7963135e7bae8ed (diff)
downloadpacman-ce089e1b975e99f6a35c159f51d0dbe7c0ddcca3.tar.xz
pactest: pass entire test to rule.check()
We were piecemeal passing fields from the test object in and it was getting out of hand, and future work would have added yet another argument. Instead, just pass the entire test object and entrust the rule to get what it needs. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'test')
-rwxr-xr-xtest/pacman/pmrule.py22
-rwxr-xr-xtest/pacman/pmtest.py2
2 files changed, 12 insertions, 12 deletions
diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py
index c6412aa4..62630457 100755
--- a/test/pacman/pmrule.py
+++ b/test/pacman/pmrule.py
@@ -34,17 +34,16 @@ class pmrule(object):
return self.rule
return self.rule[:37] + '...'
- def check(self, root, retcode, localdb, files):
+ def check(self, test):
"""
"""
-
success = 1
- [test, args] = self.rule.split("=")
- if test[0] == "!":
+ [testname, args] = self.rule.split("=")
+ if testname[0] == "!":
self.false = 1
- test = test.lstrip("!")
- [kind, case] = test.split("_")
+ testname = testname.lstrip("!")
+ [kind, case] = testname.split("_")
if "|" in args:
[key, value] = args.split("|", 1)
else:
@@ -52,19 +51,20 @@ class pmrule(object):
if kind == "PACMAN":
if case == "RETCODE":
- if retcode != int(key):
+ if test.retcode != int(key):
success = 0
elif case == "OUTPUT":
- logfile = os.path.join(root, util.LOGFILE)
+ logfile = os.path.join(test.root, util.LOGFILE)
if not os.access(logfile, os.F_OK):
print "LOGFILE not found, cannot validate 'OUTPUT' rule"
success = 0
- elif not util.grep(os.path.join(root, util.LOGFILE), key):
+ elif not util.grep(logfile, key):
success = 0
else:
print "PACMAN rule '%s' not found" % case
success = -1
elif kind == "PKG":
+ localdb = test.db["local"]
newpkg = localdb.db_read(key)
if not newpkg:
success = 0
@@ -107,12 +107,12 @@ class pmrule(object):
print "PKG rule '%s' not found" % case
success = -1
elif kind == "FILE":
- filename = os.path.join(root, key)
+ filename = os.path.join(test.root, key)
if case == "EXIST":
if not os.path.isfile(filename):
success = 0
elif case == "MODIFIED":
- for f in files:
+ for f in test.files:
if f.name == key:
if not f.ismodified():
success = 0
diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py
index 4f3b122f..958e2630 100755
--- a/test/pacman/pmtest.py
+++ b/test/pacman/pmtest.py
@@ -263,7 +263,7 @@ class pmtest(object):
print "==> Checking rules"
for i in self.rules:
- success = i.check(self.root, self.retcode, self.db["local"], self.files)
+ success = i.check(self)
if success == 1:
msg = " OK "
self.result["success"] += 1