core: compute list of dotspacemacs variables for init tests

This commit is contained in:
syl20bnr 2015-08-31 23:16:14 -04:00
parent 1231a05cec
commit 18611cfbd2
2 changed files with 50 additions and 51 deletions

View File

@ -232,6 +232,19 @@ If ARG is non nil then `dotspacemacs/config' is skipped."
(spacemacs-buffer/warning "Some tests failed, check `%s' buffer"
dotspacemacs-test-results-buffer)))))
(defun dotspacemacs/get-variable-string-list ()
"Return a list of all the dotspacemacs variables as strings."
(all-completions "" obarray
(lambda (x)
(and (boundp x)
(not (keywordp x))
(string-prefix-p "dotspacemacs"
(symbol-name x))))))
(defun dotspacemacs/get-variable-list ()
"Return a list of all dotspacemacs variable symbols."
(mapcar 'intern (dotspacemacs/get-variable-string-list)))
(defmacro dotspacemacs|symbol-value (symbol)
"Return the value of SYMBOL corresponding to a dotspacemacs variable.
If SYMBOL value is `display-graphic-p' then return the result of
@ -349,56 +362,48 @@ If MSG is not nil then display a message in `*Messages'."
dotspacemacs-filepath passed-tests total-tests))
(equal passed-tests total-tests)))
(defmacro dotspacemacs||let-init-test (&rest body)
"Macro to protect dotspacemacs variables"
`(let ((fpath dotspacemacs-filepath)
,@(dotspacemacs/get-variable-list)
(passed-tests 0) (total-tests 0))
(setq dotspacemacs-filepath fpath)
(load dotspacemacs-filepath)
,@body))
(defun dotspacemacs//test-dotspacemacs/init ()
"Tests for `dotspacemacs/init'"
(insert
(format (concat "\n* Testing settings in dotspacemacs/init "
"[[file:%s::dotspacemacs/init][Show in File]]\n")
dotspacemacs-filepath))
;; protect global values of these variables
(let (dotspacemacs-editing-style dotspacemacs-verbose-loading
dotspacemacs-startup-banner dotspacemacs-startup-lists
dotspacemacs-themes dotspacemacs-colorize-cursor-according-to-state
dotspacemacs-default-font dotspacemacs-leader-key
dotspacemacs-emacs-leader-key dotspacemacs-major-mode-leader-key
dotspacemacs-major-mode-emacs-leader-key dotspacemacs-command-key
dotspacemacs-auto-save-file-location dotspacemacs-use-ido
dotspacemacs-enable-paste-micro-state dotspacemacs-guide-key-delay
dotspacemacs-loading-progress-bar dotspacemacs-fullscreen-at-startup
dotspacemacs-fullscreen-use-non-native dotspacemacs-maximized-at-startup
dotspacemacs-active-transparency dotspacemacs-inactive-transparency
dotspacemacs-mode-line-unicode-symbols dotspacemacs-smooth-scrolling
dotspacemacs-smartparens-strict-mode dotspacemacs-highlight-delimiters
dotspacemacs-persistent-server dotspacemacs-search-tools
dotspacemacs-default-package-repository
(passed-tests 0) (total-tests 0))
(load dotspacemacs-filepath)
(dotspacemacs/init)
(spacemacs//test-var
(lambda (x) (member x '(vim emacs)))
'dotspacemacs-editing-style "is \'vim or \'emacs")
(spacemacs//test-var
(lambda (x) (member x '(original cache nil)))
'dotspacemacs-auto-save-file-location (concat "is one of \'original, "
"\'cache or nil"))
(spacemacs//test-var
(lambda (x) (member x '(all current nil)))
'dotspacemacs-highlight-delimiters "is one of \'all, \'current or nil")
(spacemacs//test-list
(lambda (x) (member x '(recents bookmarks projects)))
'dotspacemacs-startup-lists (concat "includes only \'recents, "
"\'bookmarks or \'projects"))
(spacemacs//test-var 'stringp 'dotspacemacs-leader-key "is a string")
(spacemacs//test-var 'stringp 'dotspacemacs-emacs-leader-key "is a string")
(spacemacs//test-var
'stringp 'dotspacemacs-major-mode-leader-key "is a string")
(spacemacs//test-var 'stringp 'dotspacemacs-command-key "is a string")
(insert (format
(concat "** RESULTS: "
"[[file:%s::dotspacemacs/init][dotspacemacs/init]] "
"passed %s out of %s tests\n")
dotspacemacs-filepath passed-tests total-tests))
(equal passed-tests total-tests)))
(dotspacemacs||let-init-test
(dotspacemacs/init)
(spacemacs//test-var
(lambda (x) (member x '(vim emacs)))
'dotspacemacs-editing-style "is \'vim or \'emacs")
(spacemacs//test-var
(lambda (x) (member x '(original cache nil)))
'dotspacemacs-auto-save-file-location (concat "is one of \'original, "
"\'cache or nil"))
(spacemacs//test-var
(lambda (x) (member x '(all current nil)))
'dotspacemacs-highlight-delimiters "is one of \'all, \'current or nil")
(spacemacs//test-list
(lambda (x) (member x '(recents bookmarks projects)))
'dotspacemacs-startup-lists (concat "includes only \'recents, "
"\'bookmarks or \'projects"))
(spacemacs//test-var 'stringp 'dotspacemacs-leader-key "is a string")
(spacemacs//test-var 'stringp 'dotspacemacs-emacs-leader-key "is a string")
(spacemacs//test-var
'stringp 'dotspacemacs-major-mode-leader-key "is a string")
(spacemacs//test-var 'stringp 'dotspacemacs-command-key "is a string")
(insert (format
(concat "** RESULTS: "
"[[file:%s::dotspacemacs/init][dotspacemacs/init]] "
"passed %s out of %s tests\n")
dotspacemacs-filepath passed-tests total-tests))
(equal passed-tests total-tests)))
(defun dotspacemacs/test-dotfile (&optional hide-buffer)
"Test settings in dotfile for correctness.

View File

@ -181,13 +181,7 @@
(defun helm-spacemacs//dotspacemacs-candidates ()
"Return the sorted candidates for all the dospacemacs variables."
(sort (all-completions "" obarray
(lambda (x)
(and (boundp x)
(not (keywordp x))
(string-prefix-p "dotspacemacs"
(symbol-name x)))))
'string<))
(sort (dotspacemacs/get-variable-string-list) 'string<))
(defun helm-spacemacs//layer-action-open-file (file candidate)
"Open FILE of the passed CANDIDATE."