]> code.delx.au - gnu-emacs/blob - test/Makefile.in
Merge from origin/emacs-25
[gnu-emacs] / test / Makefile.in
1 ### @configure_input@
2
3 # Copyright (C) 2010-2016 Free Software Foundation, Inc.
4
5 # This file is part of GNU Emacs.
6
7 # GNU Emacs is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11
12 # GNU Emacs is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19
20 ### Commentary:
21
22 ## Some targets:
23 ## check: re-run all tests, writing to .log files.
24 ## check-maybe: run all tests whose .log file needs updating
25 ## filename.log: run tests from filename.el(c) if .log file needs updating
26 ## filename: re-run tests from filename.el(c), with no logging
27
28 ### Code:
29
30 SHELL = @SHELL@
31
32 srcdir = @srcdir@
33 VPATH = $(srcdir)
34
35 SEPCHAR = @SEPCHAR@
36
37 # We never change directory before running Emacs, so a relative file
38 # name is fine, and makes life easier. If we need to change
39 # directory, we can use emacs --chdir.
40 EMACS = ../src/emacs
41
42 EMACS_EXTRAOPT=
43
44 # Command line flags for Emacs.
45 # Apparently MSYS bash would convert "-L :" to "-L ;" anyway,
46 # but we might as well be explicit.
47 EMACSOPT = -batch --no-site-file --no-site-lisp -L "$(SEPCHAR)$(srcdir)" $(EMACS_EXTRAOPT)
48
49 # Prevent any settings in the user environment causing problems.
50 unexport EMACSDATA EMACSDOC EMACSPATH GREP_OPTIONS
51
52 ## To run tests under a debugger, set this to eg: "gdb --args".
53 GDB =
54
55 # The locale to run tests under. Tests should work if this is set to
56 # any supported locale. Use the C locale by default, as it should be
57 # supported everywhere.
58 TEST_LOCALE = C
59
60 # The actual Emacs command run in the targets below.
61 # Prevent any setting of EMACSLOADPATH in user environment causing problems.
62 emacs = EMACSLOADPATH= LC_ALL=$(TEST_LOCALE) EMACS_TEST_DIRECTORY=$(srcdir) \
63 $(GDB) "$(EMACS)" $(EMACSOPT)
64
65 .PHONY: all check
66
67 all: check
68
69 %.elc: %.el
70 @echo Compiling $<
71 @$(emacs) -f batch-byte-compile $<
72
73 ## Ignore any test errors so we can continue to test other files.
74 ## But compilation errors are always fatal.
75 WRITE_LOG = > $@ 2>&1 || { stat=ERROR; cat $@; }; echo $$stat: $@
76
77 ## I'd prefer to use -emacs -f ert-run-tests-batch-and-exit rather
78 ## than || true, since the former makes problems more obvious.
79 ## I'd also prefer to @-hide the grep part and not the
80 ## ert-run-tests-batch-and-exit part.
81 ##
82 ## We need to use $loadfile because:
83 ## i) -L :$srcdir -l basename does not work, because we have files whose
84 ## basename duplicates a file in lisp/ (eg eshell.el).
85 ## ii) Although -l basename will automatically load .el or .elc,
86 ## -l ./basename treats basename as a literal file (it would be nice
87 ## to change this; bug#17848 - if that gets done, this can be simplified).
88 ##
89 ## Beware: it approximates 'no-byte-compile', so watch out for false-positives!
90 SELECTOR_DEFAULT = (quote (not (tag :expensive-test)))
91 SELECTOR_EXPENSIVE = nil
92 ifdef SELECTOR
93 SELECTOR_ACTUAL=$(SELECTOR)
94 else ifeq ($(MAKECMDGOALS),check)
95 SELECTOR_ACTUAL=$(SELECTOR_DEFAULT)
96 else ifeq ($(MAKECMDGOALS),check-maybe)
97 SELECTOR_ACTUAL=$(SELECTOR_DEFAULT)
98 else
99 SELECTOR_ACTUAL=$(SELECTOR_EXPENSIVE)
100 endif
101
102
103 %.log: %.el
104 @if grep '^;.*no-byte-compile: t' $< > /dev/null; then \
105 loadfile=$<; \
106 else \
107 loadfile=$<c; \
108 ${MAKE} $$loadfile; \
109 fi; \
110 echo Testing $$loadfile; \
111 stat=OK ; \
112 mkdir --parents $(dir $@) ; \
113 $(emacs) -l ert -l $$loadfile \
114 --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG}
115
116 ELFILES = $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \
117 -path "*resources" -prune -o -name "*el" -print)
118 ## .elc files may be in a different directory for out of source builds
119 ELCFILES = $(patsubst %.el,%.elc, \
120 $(patsubst $(srcdir)%,.%,$(ELFILES)))
121 LOGFILES = $(patsubst %.elc,%.log,${ELCFILES})
122 LOGSAVEFILES = $(patsubst %.elc,%.log~,${ELCFILES})
123 TESTS = $(subst ${srcdir}/,,$(LOGFILES:.log=))
124
125 ## If we have to interrupt a hanging test, preserve the log so we can
126 ## see what the problem was.
127 .PRECIOUS: %.log
128
129 .PHONY: ${TESTS}
130
131 ## The short aliases that always re-run the tests, with no logging.
132 ## Define an alias both with and without the directory name for ease
133 ## of use.
134 define test_template
135 $(1):
136 @test ! -f ./$(1).log || mv ./$(1).log ./$(1).log~
137 @${MAKE} ./$(1).log WRITE_LOG=
138
139 $(notdir $(1)): $(1)
140 endef
141
142 $(foreach test,${TESTS},$(eval $(call test_template,${test})))
143
144 ## Include dependencies between test files and the files they test.
145 ## We do this without the file and eval directly, but then we would
146 ## have to run Emacs for every make invocation, and it might not be
147 ## available during clean.
148 -include make-test-deps.mk
149 ## Rerun all default tests.
150 check: mostlyclean
151 @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}"
152
153 ## Rerun all default and expensive tests.
154 .PHONY: check-expensive
155 check-expensive: mostlyclean
156 @${MAKE} check-doit SELECTOR="${SELECTOR_EXPENSIVE}"
157
158 ## Only re-run default tests whose .log is older than the test.
159 .PHONY: check-maybe
160 check-maybe:
161 @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}"
162
163 ## Run the tests.
164 .PHONY: check-doit
165 check-doit: ${LOGFILES}
166 $(emacs) -l ert -f ert-summarize-tests-batch-and-exit $^
167
168 .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
169
170 mostlyclean:
171 -@for f in ${LOGFILES}; do test ! -f $$f || mv $$f $$f~; done
172
173 clean:
174 -rm -f ${LOGFILES} ${LOGSAVEFILES}
175 -rm make-test-deps.mk
176
177 bootstrap-clean: clean
178 -rm -f ${ELCFILES}
179
180 distclean: clean
181 rm -f Makefile
182
183 maintainer-clean: distclean bootstrap-clean
184
185 make-test-deps.mk: $(ELFILES) make-test-deps.emacs-lisp
186 $(EMACS) --batch -l $(srcdir)/make-test-deps.emacs-lisp \
187 --eval "(make-test-deps \"$(srcdir)\")" \
188 2> $@
189 # Makefile ends here.