From 743e041dbc22ed16a6f996b0caff6523ffecf136 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Tue, 19 Jan 2021 10:30:07 -0800 Subject: 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 Signed-off-by: Allan McRae --- test/pacman/pmrule.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py index 59293266..aef73cdb 100644 --- a/test/pacman/pmrule.py +++ b/test/pacman/pmrule.py @@ -181,6 +181,16 @@ def check(self, test): if not pkg or not os.path.isfile( os.path.join(cachedir, pkg.filename())): 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: tap.diag("Rule kind '%s' not found" % kind) success = -1 -- cgit v1.2.3-54-g00ecf