add CACHE_FEXISTS and CACHE_FCONTENTS test rules

The existing CACHE_EXISTS rule takes a package, which is not suitable
for -U tests that need to be able to check for specific files.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Andrew Gregory 2021-01-19 10:30:07 -08:00 committed by Allan McRae
parent 1fdf8c0076
commit 743e041dbc

View file

@ -181,6 +181,16 @@ class pmrule(object):
if not pkg or not os.path.isfile( if not pkg or not os.path.isfile(
os.path.join(cachedir, pkg.filename())): os.path.join(cachedir, pkg.filename())):
success = 0 success = 0
elif case == "FEXISTS":
if not os.path.isfile(os.path.join(cachedir, key)):
success = 0
elif case == "FCONTENTS":
filename = os.path.join(cachedir, key)
try:
with open(filename, 'r') as f:
success = f.read() == value
except:
success = 0
else: else:
tap.diag("Rule kind '%s' not found" % kind) tap.diag("Rule kind '%s' not found" % kind)
success = -1 success = -1