forked from dimitri/el-get
-
Notifications
You must be signed in to change notification settings - Fork 0
/
el-get-issue-659.el
75 lines (71 loc) · 2.92 KB
/
el-get-issue-659.el
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
;; https://github.com/dimitri/el-get/issues/659
;;
;; Updatable properties in cached recipes
(require 'cl)
(require 'pp)
(el-get-register-method-alias :test :builtin)
(let* ((debug-on-error t)
(el-get-default-process-sync t)
(el-get-verbose t)
(el-get-auto-update-cached-recipes t)
(initial-source
`(:name a
:type test
:compile "."
:features a
:build (("sh" "-c"
,(format "echo %s > a.el"
(shell-quote-argument
(mapconcat
#'pp-to-string
'((provide 'a))
"\n")))))
:prepare (message "Preparing A")
:post-init (message "Post-init A")
:lazy nil))
(el-get-sources
(list initial-source))
(update-source
(append '(:features nil
:lazy t
:before (message "Before A")
:after (message "After A")
:load "a.el"
:library "a"
;; This should not cause an error because it matches the
;; cached value.
:prepare (message "Preparing A"))
initial-source))
(update-source-2
(append '(:lazy nil
:before (message "Before A2")
:after (progn (setq second-update-succeeded t)
(message "After A2")))
initial-source))
(invalid-update-source
(append '(:non-updatable-property value)
initial-source)))
;; Install A
(el-get 'sync 'a)
(require 'a)
(assert (featurep 'a) nil
"Package A should be installed and loaded")
(el-get-merge-properties-into-status update-source)
(assert (plist-get (el-get-read-package-status-recipe 'a) :lazy) nil
"New values should be merged into cached recipe")
(condition-case err
(progn
(el-get-merge-properties-into-status invalid-update-source)
(signal 'test-failure "Failed to raise error when trying to update non-updatable property."))
(error (message "Got error as expected. Error was:\n%S" err)))
;; Try the no-error option. Obviously, it shouldn't throw an error,
;; and it also shouldn't update anything.
(el-get-merge-properties-into-status invalid-update-source nil :noerror t)
(assert (null (plist-get (el-get-read-package-status-recipe 'a) :features)) nil
"Cached recipe should not be updated")
;; Verify that new properties were actually added.
(let ((el-get-sources (list update-source-2)))
(el-get-init 'a))
(assert (bound-and-true-p second-update-succeeded) nil
"el-get-init should auto-update the recipe")
)