Allow sorting resources in diff.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
diff --git a/core/defs.lisp b/core/defs.lisp
index b33c73e..b171b7c 100644
--- a/core/defs.lisp
+++ b/core/defs.lisp
@@ -149,6 +149,8 @@
`(let ((*parent-resource* ,(or resource '*adams*)))
,@body))
+(defgeneric resource-before-p (r1 r2))
+
;; Specifying resources
(defgeneric specified-property (resource property))
diff --git a/core/resource-container.lisp b/core/resource-container.lisp
index eff2679..ab65980 100644
--- a/core/resource-container.lisp
+++ b/core/resource-container.lisp
@@ -64,3 +64,8 @@
(defun clear-resources (&optional (resource-container *parent-resource*))
(clear-resources% resource-container))
+
+;; Sorting resources
+
+(defmethod resource-before-p ((r1 resource) (r2 resource))
+ nil)
diff --git a/core/spec.lisp b/core/spec.lisp
index 18cf9ce..ecffa16 100644
--- a/core/spec.lisp
+++ b/core/spec.lisp
@@ -123,10 +123,12 @@ Second value lists properties in line with spec. Format is
(defmethod resource-diff ((res resource-container))
(append (call-next-method res)
- (iter (for-resource r in res)
- (for d = (resource-diff r))
- (when d
- (collect (cons r d))))))
+ (sort (iter (for-resource r in res)
+ (for d = (resource-diff r))
+ (when d
+ (collect (cons r d))))
+ #'resource-before-p
+ :key #'first)))
(defmethod resource-diff ((host host))
(with-host host