aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/package.lisp1
-rw-r--r--src/property/file.lisp11
2 files changed, 12 insertions, 0 deletions
diff --git a/src/package.lisp b/src/package.lisp
index 31288d2..5e6554c 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -320,6 +320,7 @@
#:exists-with-content
#:contains-lines
#:lacks-lines
+ #:lacks-lines-matching
#:has-mode
#:has-ownership
#:does-not-exist
diff --git a/src/property/file.lisp b/src/property/file.lisp
index bdda926..9c4ad7d 100644
--- a/src/property/file.lisp
+++ b/src/property/file.lisp
@@ -78,6 +78,17 @@ replacing the contents of existing files, prefer FILE:HAS-CONTENT."
path
(curry #'remove-if (lambda (l) (member l lines :test #'string=))))))
+(defprop lacks-lines-matching :posix (path &rest patterns)
+ "If there is a file a PATH, ensure it does not contain any lines matching
+any of the regular expressions PATTERNS."
+ (:apply
+ (let ((scanners (mapcar #'re:create-scanner patterns)))
+ (map-file-lines
+ path (lambda (lines)
+ (loop for line in lines
+ unless (loop for s in scanners thereis (re:scan s line))
+ collect line))))))
+
(defprop has-mode :posix (path mode)
"Ensure that a file has a particular numeric mode."
(:desc (format nil "~A has mode ~O" path mode))