Skip to content
This repository
tree: 3ecb99262d
Fetching contributors…

Cannot retrieve contributors at this time

file 93 lines (88 sloc) 3.964 kb
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
(eval-when-compile
  (require 'cl)
  (when (null (ignore-errors (require 'ert)))
    (defmacro* ert-deftest (name () &body docstring-keys-and-body)
      (message "Skipping tests, ERT is not available"))))

(defconst testing-destination-dir "/tmp/emacs.d.testing")

(ert-deftest el-get-installation-test ()
  (let ((el-get-default-process-sync 'wait)
         (user-emacs-directory testing-destination-dir)
         (el-get-dir (concat (file-name-as-directory user-emacs-directory)
                             "el-get"))
         (el-get-status-file
          (concat (file-name-as-directory el-get-dir) ".status.el")))
    (make-directory el-get-dir t)
    ;; Extract the instructions directly from the documentation
    (with-temp-buffer
      (insert-file-contents "../README.asciidoc")
      (goto-char (point-min))
      (search-forward-regexp "^-\\{9,\\}
\\(\\(?:.\\|
\\)+?\\)-\\{9,\\}")
      (let ((install-string (match-string 1)))
        (should install-string)
        (message "evaluating %s" install-string)
        (should (eval (read (match-string 1)))))))
  (should (featurep 'el-get))
  ;; (should (el-get-compiled))
  (should-not el-get-outdated-autoloads))

(ert-deftest el-get-recipe-dirs-test ()
  (require 'el-get)
  (let ((el-get-recipe-path
         `("/"
           ,(let ((f "/foo"))
              (while (file-exists-p f)
                (setq f (concat f f))) f))))
    (should (equal (el-get-recipe-dirs)
                   (loop for f in el-get-recipe-path
                         when (file-exists-p f)
                         collect f)))))

(ert-deftest el-get-trivial-install-test ()
  (require 'el-get)
  (let* ((pkg 'el-get-trivial-install-test)
         (pkg-name (symbol-name pkg))
         (pkg-file (concat pkg-name ".el"))
         (pkg-source (concat "/tmp/" pkg-file))
         (user-emacs-directory testing-destination-dir)
         (el-get-dir (concat (file-name-as-directory user-emacs-directory)
                             "el-get"))
         (el-get-status-file
          (concat (file-name-as-directory el-get-dir) ".status.el"))
         (pkg-destination-dir (mapconcat
                               'file-name-as-directory
                               (list user-emacs-directory "el-get" pkg-name)
                               ""))
         (pkg-destination (concat pkg-destination-dir pkg-file))
         (el-get-sources `((:name ,pkg
                                  :features (,pkg)
                                  :type http
                                  :url ,(concat "file://" pkg-source))))
(el-get-packages (mapcar 'el-get-source-name el-get-sources)))
    (make-directory el-get-dir t)
    (unwind-protect
        (progn
          (message "Checking %s is not loaded" pkg)
          (should-not (featurep pkg))
          (message "Creating %s package file in %s" pkg pkg-source)
          (with-temp-file pkg-source
            (insert (format "(defun %s-empty ())\n(provide '%s)\n" pkg pkg)))
          (message "Verifying package file %s" pkg-source)
          (should (file-exists-p pkg-source))
          ;; and it's not empty
          (should-not (zerop (nth 7 (file-attributes pkg-source))))
          (message "Installing %s" pkg)
          (should (progn
                    (el-get 'sync el-get-packages)
                    t))
          (message "Verifying installed package file %s" pkg-destination)
          (should (file-exists-p pkg-destination))
          (should-not (zerop (nth 7 (file-attributes pkg-destination))))
          (message "Verifying package %s was loaded" pkg)
          (should (featurep pkg))
          (message "Unloading and removing package %s" pkg)
          (el-get-remove (symbol-name pkg))
          (message "Verifying package %s was unloaded and removed" pkg)
          (should-not (file-exists-p pkg-destination)))
      (delete-file pkg-source))))

;(featurep 'el-get-trivial-install-test)
;(unload-feature 'el-get-trivial-install-test)
Something went wrong with that request. Please try again.