-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest-helper.el
40 lines (29 loc) · 1.06 KB
/
test-helper.el
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
;;; test-helper --- Test helper for ${package-name}
;;; Commentary:
;; test helper inspired from https://github.com/tonini/overseer.el/blob/master/test/test-helper.el
;;; Code:
(require 'f)
(defvar cpt-path
(f-parent (f-this-file)))
(defvar ${package-name}-test-path
(f-dirname (f-this-file)))
(defvar ${package-name}-root-path
(f-parent ${package-name}-test-path))
(defvar ${package-name}-sandbox-path
(f-expand "sandbox" ${package-name}-test-path))
(when (f-exists? ${package-name}-sandbox-path)
(error "Something is already in %s. Check and destroy it yourself" ${package-name}-sandbox-path))
(defmacro within-sandbox (&rest body)
"Evaluate BODY in an empty sandbox directory."
`(let ((default-directory ${package-name}-sandbox-path))
(when (f-exists? ${package-name}-sandbox-path)
(f-delete default-directory :force))
(f-mkdir ${package-name}-sandbox-path)
,@body
(f-delete default-directory :force)))
(require 'ert)
(require 'el-mock)
(eval-when-compile
(require 'cl))
(require '${package-name})
;;; test-helper.el ends here