|
7 | 7 | (defmacro* ert-deftest (name () &body docstring-keys-and-body) |
8 | 8 | (message "Skipping tests, ERT is not available")))) |
9 | 9 |
|
| 10 | +(defun el-get-plist-equal (plist1 plist2) |
| 11 | + (let ((keys (el-get-plist-keys plist1))) |
| 12 | + (and (equal (sort keys #'string<) |
| 13 | + (sort (el-get-plist-keys plist2) #'string<)) |
| 14 | + (loop for key in keys |
| 15 | + unless (equal (plist-get plist1 key) |
| 16 | + (plist-get plist2 key)) |
| 17 | + return nil |
| 18 | + finally return t)))) |
| 19 | + |
10 | 20 | (defvar el-get-test-output-buffer nil) |
11 | 21 | (when noninteractive |
12 | 22 | (defadvice message (around el-get-test-catch-output activate) |
@@ -125,3 +135,105 @@ Following variables are bound to temporal values: |
125 | 135 | (should-not (featurep pkg)) |
126 | 136 | (el-get 'sync (mapcar 'el-get-source-name el-get-sources)) |
127 | 137 | (should (featurep pkg))))) |
| 138 | + |
| 139 | +(defun el-get-test-compute-new-status-equal (status1 status2) |
| 140 | + "Check equality for `el-get-compute-new-status' results." |
| 141 | + (and (el-get-plist-equal (nth 0 status1) (nth 0 status2)) |
| 142 | + (equal (nth 1 status1) (nth 1 status2)) |
| 143 | + (el-get-plist-equal (nth 2 status1) (nth 2 status2)) |
| 144 | + (el-get-plist-equal (nth 3 status1) (nth 3 status2)))) |
| 145 | + |
| 146 | +(ert-deftest el-get-test-compute-new-status () |
| 147 | + "Test `el-get-compute-new-status'." |
| 148 | + (let* ((old '(:name a |
| 149 | + :type git |
| 150 | + :load-path "load-old" |
| 151 | + :depends (depends old) |
| 152 | + :build (("build" "old")) |
| 153 | + :build/gnu-linux (("build/gnu-linux" "old")) |
| 154 | + :url "http://example.com/url/old")) |
| 155 | + (new '(:name a |
| 156 | + :type git |
| 157 | + :load-path "load-new" |
| 158 | + :depends (depends new) |
| 159 | + :build (("build" "new")) |
| 160 | + :build/gnu-linux (("build/gnu-linux" "new")) |
| 161 | + :url "http://example.com/url/new")) |
| 162 | + (expected '((:name a |
| 163 | + :type git |
| 164 | + :load-path "load-new" |
| 165 | + :depends (depends old) |
| 166 | + :build (("build" "old")) |
| 167 | + :build/gnu-linux (("build/gnu-linux" "old")) |
| 168 | + :url "http://example.com/url/old") |
| 169 | + (reinstall) |
| 170 | + (:depends (depends new) |
| 171 | + :build (("build new")) |
| 172 | + :build/gnu-linux (("build/gnu-linux" "new")) |
| 173 | + :url "http://example.com/url/new") |
| 174 | + (:depends (depends old) |
| 175 | + :build (("build old")) |
| 176 | + :build/gnu-linux (("build/gnu-linux" "old")) |
| 177 | + :url "http://example.com/url/old"))) |
| 178 | + (update-expected '((:name a |
| 179 | + :type git |
| 180 | + :load-path "load-new" |
| 181 | + :depends (depends new) |
| 182 | + :build (("build" "new")) |
| 183 | + :build/gnu-linux (("build/gnu-linux" "new")) |
| 184 | + :url "http://example.com/url/old") |
| 185 | + (reinstall) |
| 186 | + (:url "http://example.com/url/new") |
| 187 | + (:url "http://example.com/url/old")))) |
| 188 | + (should (el-get-test-compute-new-status-equal |
| 189 | + (el-get-compute-new-status 'init old new) |
| 190 | + expected)) |
| 191 | + (should (el-get-test-compute-new-status-equal |
| 192 | + (el-get-compute-new-status 'update old new) |
| 193 | + update-expected)) |
| 194 | + (should (el-get-test-compute-new-status-equal |
| 195 | + (el-get-compute-new-status 'reinstall old new) |
| 196 | + (list new nil nil nil))))) |
| 197 | + |
| 198 | +(ert-deftest el-get-test-compute-new-status-2 () |
| 199 | + "Test `el-get-compute-new-status'." |
| 200 | + (let* ((old '(:name a |
| 201 | + :type git |
| 202 | + :load-path "load-old" |
| 203 | + :depends (depends old) |
| 204 | + :build (("build" "old")) |
| 205 | + :build/gnu-linux (("build/gnu-linux" "old")) |
| 206 | + :url "http://example.com/url/old")) |
| 207 | + (new '(:name a |
| 208 | + :type git |
| 209 | + :load-path "load-new" |
| 210 | + :depends (depends new) |
| 211 | + :build (("build" "new")) |
| 212 | + :build/gnu-linux (("build/gnu-linux" "new")) |
| 213 | + :url "http://example.com/url/old")) |
| 214 | + (init-result (el-get-compute-new-status 'init old new)) |
| 215 | + (init-expected '((:name a |
| 216 | + :type git |
| 217 | + :load-path "load-new" |
| 218 | + :depends (depends old) |
| 219 | + :build (("build" "old")) |
| 220 | + :build/gnu-linux (("build/gnu-linux" "old")) |
| 221 | + :url "http://example.com/url/old") |
| 222 | + (update reinstall) |
| 223 | + (:depends (depends new) |
| 224 | + :build (("build new")) |
| 225 | + :build/gnu-linux (("build/gnu-linux" "new"))) |
| 226 | + (:depends (depends old) |
| 227 | + :build (("build old")) |
| 228 | + :build/gnu-linux (("build/gnu-linux" "old"))))) |
| 229 | + (update-result (el-get-compute-new-status 'update old new)) |
| 230 | + (update-expected '((:name a |
| 231 | + :type git |
| 232 | + :load-path "load-new" |
| 233 | + :depends (depends new) |
| 234 | + :build (("build" "new")) |
| 235 | + :build/gnu-linux (("build/gnu-linux" "new")) |
| 236 | + :url "http://example.com/url/old") |
| 237 | + nil nil nil))) |
| 238 | + (should (el-get-test-compute-new-status-equal init-result init-expected)) |
| 239 | + (should (el-get-test-compute-new-status-equal update-result update-expected)))) |
0 commit comments