forked from Trevoke/org-gtd.el
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEldev
More file actions
112 lines (89 loc) · 3.91 KB
/
Eldev
File metadata and controls
112 lines (89 loc) · 3.91 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
; -*- mode: emacs-lisp; lexical-binding: t; -*-
;; Autodetermined by `eldev init'.
(eldev-use-package-archive 'gnu-elpa)
(eldev-use-package-archive 'melpa)
(eldev-use-plugin 'autoloads)
(eldev-use-plugin 'maintainer)
(eldev-use-plugin 'undercover)
;; Test framework dependencies
(eldev-add-extra-dependencies 'test 'with-simulated-input)
(eldev-add-extra-dependencies 'test 'dash)
;;; E-Unit Integration
;;
;; Fetch e-unit from git repository (works in CI and development)
;; When e-unit is on MELPA, replace with: (eldev-add-extra-dependencies 'test 'e-unit)
;; :setup disables info file processing (avoids install-info requirement)
(eldev-use-vc-repository 'e-unit :git "https://codeberg.org/Trevoke/e-unit.el.git"
:rev "0.15.0"
:setup '(setq eldev-info-sources nil))
(eldev-add-extra-dependencies 'test 'e-unit)
;; Mock filesystem for testing
;; :setup disables info file processing (avoids install-info requirement)
(eldev-use-vc-repository 'mock-fs :git "https://codeberg.org/Trevoke/mock-fs.el.git"
:setup '(setq eldev-info-sources nil))
(eldev-add-extra-dependencies 'test 'mock-fs)
;;; Custom test command for e-unit
;;
;; Use `eldev gtd-etest` (or `eldev etest`) to run e-unit tests from test/ directory
;; Variables for etest options
(defvar org-gtd-etest-reporter 'console
"Reporter to use for e-unit tests.")
(defvar org-gtd-etest-verbose nil
"Whether to show verbose output.")
(defvar org-gtd-etest-stop-on-failure nil
"Whether to stop on first failure.")
(eldev-defcommand org-gtd-etest (&rest _parameters)
"Run e-unit tests.
E-unit tests are in the test/ directory with subdirectories:
- test/unit/ Unit tests
- test/integration/ Integration tests
- test/acceptance/ Acceptance tests
E-unit now searches recursively, so we just point it at the root test directory."
:aliases (etest)
:category testing
;; Suppress version upgrade warnings (must be set before org-gtd loads)
(setq org-gtd-update-ack "4.0.0")
(eldev-load-project-dependencies 'test)
(require 'e-unit)
(let ((root-dir "test"))
;; Configure e-unit
(e-unit-configure :verbose org-gtd-etest-verbose
:stop-on-failure org-gtd-etest-stop-on-failure)
;; Set reporter
(e-unit-set-reporter org-gtd-etest-reporter)
;; Check if test directory exists
(if (not (file-directory-p root-dir))
(message "No test directory found (%s). Create it and add *-test.el files to run e-unit tests." root-dir)
;; Run all tests recursively from root directory
(let ((results (e-unit-run-directory root-dir)))
(if (null results)
(message "No e-unit tests executed")
(let* ((total (length results))
(passed (length (cl-remove-if-not
(lambda (r) (eq (plist-get r :status) 'pass))
results)))
(failed (length (cl-remove-if-not
(lambda (r) (memq (plist-get r :status) '(fail error)))
results))))
;; Update Eldev counters - this sets the exit code
(setq eldev-test-num-passed passed)
(setq eldev-test-num-failed failed)))))))
;; Define options for etest command
;; Note: command name is gtd-etest (eldev strips "org-" prefix)
(eldev-defoption org-gtd-etest-set-reporter (type)
"Select reporter: console, dot, compilation"
:options (-r --reporter)
:for-command gtd-etest
:value TYPE
:default-value 'console
(setf org-gtd-etest-reporter (intern type)))
(eldev-defoption org-gtd-etest-set-verbose ()
"Show all test names"
:options (-v --verbose)
:for-command gtd-etest
(setf org-gtd-etest-verbose t))
(eldev-defoption org-gtd-etest-set-stop ()
"Stop on first failure"
:options (-s --stop)
:for-command gtd-etest
(setf org-gtd-etest-stop-on-failure t))