-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.lisp
101 lines (87 loc) · 2.64 KB
/
api.lisp
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
94
95
96
97
98
99
100
101
(in-package #:proctor)
(defun run (test)
(~> test
get-test-result
print-test-result))
(defun failure-data (test)
(~> test
get-test-result
extract-failure-data))
(defmacro runq (test)
`(run ',test))
(defvar *debug-test* nil)
(defun debug-test (test)
(let ((*debug-test* t))
(run (find-test test))))
(defmacro def-test (test-name (&key suite) &body body)
(let ((file (test-result-file test-name))
(suite (or suite (test-name (current-suite)))))
`(progn
(save-test ',test-name
(lambda ()
,@body)
:in ',suite)
(overlord:file-target ,test-name (:path ,file)
;; Include the body literally so changes are detected.
',body
(depend-on-suite-parents ',suite)
(depend-on-suite-deps ',suite)
(run-test-to-file ',test-name ,file))
',test-name)))
(defmacro test (name &body body)
(destructuring-bind (name . opts)
(ensure-list name)
`(def-test ,name ,opts
,@body)))
(defmacro def-suite (name &body body)
(nest
(multiple-value-bind (opts dependencies)
(parse-leading-keywords body))
(destructuring-bind (&key in description) opts)
(let ((file (test-result-file name))
(all-deps
(append
(suite-parent-deps name)
dependencies))))
`(progn
(save-suite ',name
:in ',in
:description ',description
:deps-fn (lambda ()
,@all-deps))
;; The file that holds the suite results.
(overlord:file-target ,name (:path ,file)
(run-suite-to-file ',name ,file))
;; The file that holds the suite's parent chain.
(overlord:file-target ,(symbolicate name '.parents)
(:path ,(suite-parents-file name))
(maybe-save-parents-file ',name))
;; A configuration that holds the dependencies.
(overlord:defconfig ,(suite-deps-config name)
',all-deps)
',name)))
(defmacro in-suite (name)
`(eval-always
(setf (current-suite) ',name)))
(defmacro is (test &rest reason-args)
`(is*
(test-form ,test
,@reason-args)))
(defmacro is-true (test &rest reason-args)
`(is (true ,test) ,@reason-args))
(defmacro is-false (test &rest reason-args)
`(is (not ,test) ,@reason-args))
(defmacro signals (condition-spec &body body)
(destructuring-bind (condition-name . args)
(ensure-list condition-spec)
`(signals*
',condition-name
(test-form
(progn
,@body))
,@args)))
(defmacro finishes (&body body)
`(finishes*
(test-form
(progn
,@body))))