 (defconst dotspacemacs-template-directory
   (expand-file-name (concat spacemacs-core-directory "templates/"))
   "Templates directory.")
+
+(defconst dotspacemacs-test-results-buffer "*dotfile-test-results*"
+  "Name of the buffer to display dotfile test results.")
 
 (defconst dotspacemacs-directory
   (let* ((env (getenv "SPACEMACSDIR"))

     'dotspacemacs-configuration-layers  "can be found" "layer")
    (insert (format
             "** RESULTS: [[file:%s::dotspacemacs/layers][dotspacemacs/layers]] passed %s out of %s tests\n"
             dotspacemacs-filepath passed-tests total-tests))))

(defun dotspacemacs//test-dotspacemacs/init ()
  "Tests for `dotspacemacs/init'"

    (spacemacs//test-var 'stringp 'dotspacemacs-command-key "is a string")
    (insert (format
             "** 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.
 Return non-nil if all the tests passed."
  (interactive)
  (let ((min-version "0.0"))
    ;; dotspacemacs-version not implemented yet
    ;; (if (version< dotspacemacs-version min-version)
    (if nil
        (error (format "error: dotspacemacs/test-dotfile requires dotspacemacs-version %s" min-version))
      (with-current-buffer (get-buffer-create dotspacemacs-test-results-buffer)
        (unless hide-buffer
          (switch-to-buffer-other-window dotspacemacs-test-results-buffer))
        (erase-buffer)
        (org-mode)
        (insert (format "* Running tests on [[file:%s][%s]] (v%s)\n"
                        dotspacemacs-filepath dotspacemacs-filepath "0.0"))
        ;; dotspacemacs-version not implemented yet
        ;; (insert (format "* Running tests on %s (v%s)\n" dotspacemacs-filepath dotspacemacs-version))
        (prog1
            (and (dotspacemacs//test-dotspacemacs/layers)
                 (dotspacemacs//test-dotspacemacs/init))
          (goto-char (point-min)))))))

(provide 'core-dotspacemacs)
