Rewrite test function for db2d218

This commit is contained in:
Ryan C. Thompson 2012-02-22 14:05:14 -08:00
parent 99c06b66a0
commit 3b9428297c

View File

@ -2,54 +2,78 @@
;;
;; Lambda should be optional in :post-init and similar
(require 'cl)
(defun post-init-function ()
(message "Post-init pre-defined function"))
(let ((debug-on-error t)
;; (el-get-verbose t)
(el-get-sources
'(
;; These recipes should all be valid
(:name post-init-function
:type builtin
:post-init post-init-function)
(:name post-init-lambda
:type builtin
:post-init (lambda ()
(message "Post-init with lambda")))
(:name post-init-expr-list
:type builtin
:post-init ((message "Post-init list of expressions")
(message "Post-init list of expressions 2")))
(:name post-init-single-funcall
:type builtin
:post-init (message "Post-init single function call"))
(:name no-post-init
:type builtin)
;; This recipe should fail to install
(:name post-init-broken
:type builtin
:post-init "Broken post-init"
))))
(let* ((debug-on-error t)
;; (el-get-verbose t)
(real-recipes
'(
;; Some actual recipes that have :post-init properties
go-mode
eclim
theme-roller
))
(good-sources
(append
real-recipes
'(
;; These recipes should all be valid
(:name post-init-function
:type builtin
:post-init post-init-function)
(:name post-init-function-call
:type builtin
:post-init (post-init-function))
(:name post-init-quoted-function-call
:type builtin
:post-init '(post-init-function))
(:name post-init-lambda
:type builtin
:post-init (lambda ()
(message "Post-init with lambda")))
(:name post-init-single-form
:type builtin
:post-init (message "Post-init single function call"))
(:name post-init-quoted-form
:type builtin
:post-init '(message "Post-init quoted function call"))
(:name post-init-expr-list
:type builtin
:post-init (progn
(message "Post-init list of expressions")
(message "Post-init list of expressions 2")))
(:name no-post-init
:type builtin))))
(broken-sources
'(
;; These recipes should fail to install
(:name post-init-broken
:type builtin
:post-init "Broken post-init"
)
(:name post-init-missing-function
:type builtin
:post-init this-function-does-not-exist
)))
(el-get-sources
(append good-sources broken-sources)))
(require 'el-get)
;; Should succeed
(el-get 'sync
'post-init-function
'post-init-lambda
'post-init-expr-list
'post-init-single-funcall
'no-post-init
;; Some actual recipes that use the list-of-expressions and
;; single-funcall forms
'go-mode
'eclim
'theme-roller)
(condition-case err
(progn
;; Should fail
(let ((debug-on-error nil))
(el-get 'sync 'post-init-broken))
(signal 'test-failure
'("The package\"post-init-broken\" should have caused an error, but it didn't.")))
(error (message "Installing \"post-init-broken\" failed as expected"))))
(message "Good recipes: %S" (mapcar 'el-get-source-name good-sources))
(apply 'el-get 'sync (mapcar 'el-get-source-name good-sources))
(loop for broken-pkg in (mapcar 'el-get-source-name broken-sources)
;; Each pacakge should fail to install
do (condition-case err
(progn
(let ((debug-on-error nil))
(el-get 'sync broken-pkg))
;; If installation succeeded, then throw a
;; non-standard error that will not be caught.
(signal 'test-failure
(list (format "The package \"%s\" should have caused an error, but it didn't." broken-pkg))))
;; This catches and suppresses the expected package
;; installation error.
(error (message "Installing \"%s\" failed as expected" broken-pkg)))))