summaryrefslogtreecommitdiff
path: root/guides/emacs/development.org
blob: eeb9ec5c190f797931425d2d80b9f0484094d48a (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
56
57
58
59
60
61
62
63
64
65
* Tests
** Running
Somehow I can never remember how to ask =make= how to run a specific
set of tests.

tl;dr, running =$testcases_regexp= from =test/$testfile.el=, to test
changes in =lisp/$sourcefile.el=:
#+begin_src sh
make -C test $testfile \
     TEST_LOAD_EL=yes \
     TEST_BACKTRACE_LINE_LENGTH=nil \
     SELECTOR="\"$testcases_regexp\"" \
     EMACS_EXTRAOPT="-l ../lisp/$sourcefile.el"
#+end_src

Relevant bits from test/Makefile:

#+begin_src makefile
## filename.log: run tests from filename.el(c) if .log file needs updating
## filename: re-run tests from filename.el(c), with no logging
#+end_src

#+begin_src makefile
# Whether to run tests from .el files in preference to .elc, we do
# this by default since it gives nicer stacktraces.
# If you just want a pass/fail, setting this to no is much faster.
export TEST_LOAD_EL ?= \
    $(if $(findstring $(MAKECMDGOALS), all check check-maybe),no,yes)
#+end_src

#+begin_src makefile
TEST_RUN_ERT = --batch --eval '(ert-run-tests-batch-and-exit (quote ${SELECTOR_ACTUAL}))' ${WRITE_LOG}
#+end_src

#+begin_src makefile
ifdef SELECTOR
SELECTOR_ACTUAL=$(SELECTOR)
#+end_src

Selector documentation from ~ert-select-tests~:
#+begin_quote
Valid SELECTORs:

nil  -- Selects the empty set.
t    -- Selects UNIVERSE.
:new -- Selects all tests that have not been run yet.
:failed, :passed       -- Select tests according to their most recent result.
:expected, :unexpected -- Select tests according to their most recent result.
a string -- A regular expression selecting all tests with matching names.
a test   -- (i.e., an object of the ert-test data-type) Selects that test.
a symbol -- Selects the test that the symbol names, signals an
    ‘ert-test-unbound’ error if none.
(member TESTS...) -- Selects the elements of TESTS, a list of tests
    or symbols naming tests.
(eql TEST) -- Selects TEST, a test or a symbol naming a test.
(and SELECTORS...) -- Selects the tests that match all SELECTORS.
(or SELECTORS...)  -- Selects the tests that match any of the SELECTORS.
(not SELECTOR)     -- Selects all tests that do not match SELECTOR.
(tag TAG) -- Selects all tests that have TAG on their tags list.
    A tag is an arbitrary label you can apply when you define a test.
(satisfies PREDICATE) -- Selects all tests that satisfy PREDICATE.
    PREDICATE is a function that takes an ert-test object as argument,
    and returns non-nil if it is selected.
#+end_quote