     (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))))
-
-(defun dotspacemacs/test-dotfile ()
-  "Test settings in dotfile for correctness."
+             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))
-      (save-excursion
-        (switch-to-buffer-other-window "*dotfile-test-results*")
+      (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))
-        (dotspacemacs//test-dotspacemacs/layers)
-        (dotspacemacs//test-dotspacemacs/init)
-        (goto-char (point-min))))))
+        (prog1
+            (and (dotspacemacs//test-dotspacemacs/layers)
+                 (dotspacemacs//test-dotspacemacs/init))
+          (goto-char (point-min)))))))
 
 (provide 'core-dotspacemacs)

If ARG is non nil then `dotspacemacs/config' is skipped."
  (interactive "P")
  (when (file-exists-p dotspacemacs-filepath)
    (with-current-buffer (find-file-noselect dotspacemacs-filepath)
      (let ((dotspacemacs-loading-progress-bar nil))
        (setq spacemacs-loading-string "")
        (save-buffer)
        (load-file buffer-file-name)
        (dotspacemacs|call-func dotspacemacs/init "Calling dotfile init...")
        (configuration-layer/sync)
        (if arg
            (message "Done (`dotspacemacs/config' function has been skipped).")
          (dotspacemacs|call-func dotspacemacs/config
                                  "Calling dotfile config...")
          (message "Done."))
        (when (configuration-layer/package-usedp 'powerline)
          (spacemacs//restore-powerline (current-buffer)))))))

(defmacro dotspacemacs|symbol-value (symbol)
  "Return the value of SYMBOL corresponding to a dotspacemacs variable.

(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"))
