blob: d749253949d5abb79c73cfa0a4132e1cbc9ba186 (
plain)
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
|
;;;;;;; Warning
;;
;; This file contains the project's legacy tests using the ERT framework.
;; We're in the process of moving those tests to Buttercup.
;; Don't add anything new here!
(require 'projectile)
(require 'dash)
(require 'ert)
(require 'noflet)
(defmacro projectile-test-with-sandbox (&rest body)
"Evaluate BODY in an empty temporary directory."
(declare (indent 0) (debug (&rest form)))
`(let ((sandbox
(--if-let (bound-and-true-p projectile-test-path)
(file-name-as-directory (expand-file-name "sandbox" it))
(expand-file-name
(convert-standard-filename "test/sandbox/")
(file-name-directory (locate-library "projectile.el" t))))))
(when (file-directory-p sandbox)
(delete-directory sandbox t))
(make-directory sandbox t)
(let ((default-directory sandbox))
,@body)))
(defmacro projectile-test-with-files (files &rest body)
(declare (indent 1) (debug (sexp &rest form)))
`(progn ,@(mapcar (lambda (file)
(if (string-suffix-p "/" file)
`(make-directory ,file t)
`(with-temp-file ,file)))
files)
,@body))
(defun projectile-test-should-root-in (root directory)
(let ((projectile-project-root-cache (make-hash-table :test 'equal)))
(should (equal (file-truename (file-name-as-directory root))
(let ((default-directory
(expand-file-name
(file-name-as-directory directory))))
(file-truename (projectile-project-root)))))))
(defun projectile-test-tmp-file-path ()
"Return a filename suitable to save data to in the
test temp directory"
(concat projectile-test-path
"/tmp/temporary-file-" (format "%d" (random))
".eld"))
;; Local Variables:
;; indent-tabs-mode: nil
;; End:
;;; projectile-test.el ends here
|