[pacman-dev] [PATCH 1/5] pmrule.py: add FILE_CONTENTS rule

Andrew Gregory andrew.gregory.8 at gmail.com
Thu Nov 12 00:19:57 UTC 2015


Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
---

To be used in NeedsTargets test.

 test/pacman/README    | 1 +
 test/pacman/pmrule.py | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/test/pacman/README b/test/pacman/README
index 6c601b2..a5fdeaa 100644
--- a/test/pacman/README
+++ b/test/pacman/README
@@ -303,6 +303,7 @@ its DEPENDS field.
 
 	. FILE rules
 
+  FILE_CONTENTS=path/to/file|contents
   FILE_EXIST=path/to/file
   FILE_EMPTY=path/to/file
   FILE_MODIFIED=path/to/file
diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py
index 3bcac86..f8991fd 100644
--- a/test/pacman/pmrule.py
+++ b/test/pacman/pmrule.py
@@ -120,6 +120,12 @@ def check(self, test):
                 if not (os.path.isfile(filename)
                         and os.path.getsize(filename) == 0):
                     success = 0
+            elif case == "CONTENTS":
+                try:
+                    with open(filename, 'r') as f:
+                        success = f.read() == value
+                except:
+                    success = 0
             elif case == "MODIFIED":
                 for f in test.files:
                     if f.name == key:
-- 
2.6.2


More information about the pacman-dev mailing list