doomemacs/core/test/core-projects.el

48 lines
1.7 KiB
EmacsLisp
Raw Normal View History

2018-01-01 00:44:51 +08:00
;; -*- no-byte-compile: t; -*-
;;; ../core/test/core-projects.el
(require 'projectile)
2018-01-01 00:44:51 +08:00
;;
;; `doom-project-p'
2018-01-01 00:44:51 +08:00
(def-test! project-p
:minor-mode projectile-mode
2018-01-30 07:38:40 +08:00
(let ((buffer-file-name (expand-file-name "init.el" doom-emacs-dir))
(default-directory doom-emacs-dir))
2018-01-01 00:44:51 +08:00
(should (doom-project-p)))
2018-01-30 07:38:40 +08:00
(let ((buffer-file-name (expand-file-name "test" "~"))
(default-directory (expand-file-name "~")))
2018-01-01 00:44:51 +08:00
(should-not (doom-project-p))))
2018-01-30 07:38:40 +08:00
;; `doom-project-root'
2018-01-01 00:44:51 +08:00
(def-test! project-root
:minor-mode projectile-mode
2018-01-01 00:44:51 +08:00
;; Should resolve to project root
2018-01-30 07:38:40 +08:00
(let ((buffer-file-name (expand-file-name "core.el" doom-core-dir))
(default-directory doom-core-dir))
2018-01-01 00:44:51 +08:00
(should (equal (doom-project-root) doom-emacs-dir)))
;; Should resolve to `default-directory' if not a project
2018-01-30 07:38:40 +08:00
(let ((buffer-file-name (expand-file-name "test" "~"))
(default-directory (expand-file-name "~")))
2018-01-01 00:44:51 +08:00
(should (equal (doom-project-root) default-directory))))
;; `doom-project-expand'
2018-01-01 00:44:51 +08:00
(def-test! project-expand
:minor-mode projectile-mode
2018-01-01 00:44:51 +08:00
(let ((default-directory doom-core-dir))
(should (equal (doom-project-expand "init.el")
(expand-file-name "init.el" (doom-project-root))))))
;; `doom-project-has!'
2018-01-01 00:44:51 +08:00
(def-test! project-has!
:minor-mode projectile-mode
2018-01-01 00:44:51 +08:00
(let ((default-directory doom-core-dir))
;; Resolve from project root
(should (doom-project-has! "init.el"))
;; Chained file checks
(should (doom-project-has! (and "init.el" "LICENSE")))
(should (doom-project-has! (or "init.el" "does-not-exist")))
(should (doom-project-has! (and "init.el" (or "LICENSE" "does-not-exist"))))
;; Should resolve relative paths from `default-directory'
(should (doom-project-has! (and "./core.el" "../init.el")))))