]> code.delx.au - gnu-emacs/blob - test/Makefile.in
Repair damage from emacs-25 merge
[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 which are outdated with their .log file
25 ## or the source files they are testing.
26 ## filename.log: run tests from filename.el(c) if .log file needs updating
27 ## filename: re-run tests from filename.el(c), with no logging
28
29 ### Code:
30
31 SHELL = @SHELL@
32
33 srcdir = @srcdir@
34 VPATH = $(srcdir)
35
36 MKDIR_P = @MKDIR_P@
37
38 SEPCHAR = @SEPCHAR@
39
40 # We never change directory before running Emacs, so a relative file
41 # name is fine, and makes life easier. If we need to change
42 # directory, we can use emacs --chdir.
43 EMACS = ../src/emacs
44
45 EMACS_EXTRAOPT=
46
47 # Command line flags for Emacs.
48 # Apparently MSYS bash would convert "-L :" to "-L ;" anyway,
49 # but we might as well be explicit.
50 EMACSOPT = -batch --no-site-file --no-site-lisp -L "$(SEPCHAR)$(srcdir)" $(EMACS_EXTRAOPT)
51
52 # Prevent any settings in the user environment causing problems.
53 unexport EMACSDATA EMACSDOC EMACSPATH GREP_OPTIONS
54
55 ## To run tests under a debugger, set this to eg: "gdb --args".
56 GDB =
57
58 # The locale to run tests under. Tests should work if this is set to
59 # any supported locale. Use the C locale by default, as it should be
60 # supported everywhere.
61 TEST_LOCALE = C
62
63 # The actual Emacs command run in the targets below.
64 # Prevent any setting of EMACSLOADPATH in user environment causing problems.
65 emacs = EMACSLOADPATH= LC_ALL=$(TEST_LOCALE) EMACS_TEST_DIRECTORY=$(srcdir) \
66 $(GDB) "$(EMACS)" $(EMACSOPT)
67
68 .PHONY: all check
69
70 all: check
71
72 %.elc: %.el
73 @echo Compiling $<
74 @$(emacs) -f batch-byte-compile $<
75
76 ## Ignore any test errors so we can continue to test other files.
77 ## But compilation errors are always fatal.
78 WRITE_LOG = > $@ 2>&1 || { stat=ERROR; cat $@; }; echo $$stat: $@
79
80 ## I'd prefer to use -emacs -f ert-run-tests-batch-and-exit rather
81 ## than || true, since the former makes problems more obvious.
82 ## I'd also prefer to @-hide the grep part and not the
83 ## ert-run-tests-batch-and-exit part.
84 ##
85 ## We need to use $loadfile because:
86 ## i) -L :$srcdir -l basename does not work, because we have files whose
87 ## basename duplicates a file in lisp/ (eg eshell.el).
88 ## ii) Although -l basename will automatically load .el or .elc,
89 ## -l ./basename treats basename as a literal file (it would be nice
90 ## to change this; bug#17848 - if that gets done, this can be simplified).
91 ##
92 ## Beware: it approximates 'no-byte-compile', so watch out for false-positives!
93 SELECTOR_DEFAULT = (quote (not (tag :expensive-test)))
94 SELECTOR_EXPENSIVE = nil
95 ifdef SELECTOR
96 SELECTOR_ACTUAL=$(SELECTOR)
97 else ifndef MAKECMDGOALS
98 SELECTOR_ACTUAL=$(SELECTOR_DEFAULT)
99 else ifeq ($(MAKECMDGOALS),all)
100 SELECTOR_ACTUAL=$(SELECTOR_DEFAULT)
101 else ifeq ($(MAKECMDGOALS),check)
102 SELECTOR_ACTUAL=$(SELECTOR_DEFAULT)
103 else ifeq ($(MAKECMDGOALS),check-maybe)
104 SELECTOR_ACTUAL=$(SELECTOR_DEFAULT)
105 else
106 SELECTOR_ACTUAL=$(SELECTOR_EXPENSIVE)
107 endif
108
109
110 %.log: %.el
111 @if grep '^;.*no-byte-compile: t' $< > /dev/null; then \
112 loadfile=$<; \
113 else \
114 loadfile=$<c; \
115 ${MAKE} $$loadfile; \
116 fi; \
117 echo Testing $$loadfile; \
118 stat=OK ; \
119 ${MKDIR_P} $(dir $@) ; \
120 $(emacs) -l ert -l $$loadfile \
121 --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG}
122
123 ELFILES = $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \
124 -path "*resources" -prune -o -name "*el" -print)
125 ## .elc files may be in a different directory for out of source builds
126 ELCFILES = $(patsubst %.el,%.elc, \
127 $(patsubst $(srcdir)%,.%,$(ELFILES)))
128 LOGFILES = $(patsubst %.elc,%.log,${ELCFILES})
129 LOGSAVEFILES = $(patsubst %.elc,%.log~,${ELCFILES})
130 TESTS = $(subst ${srcdir}/,,$(LOGFILES:.log=))
131
132 ## If we have to interrupt a hanging test, preserve the log so we can
133 ## see what the problem was.
134 .PRECIOUS: %.log
135
136 .PHONY: ${TESTS}
137
138 ## The short aliases that always re-run the tests, with no logging.
139 ## Define an alias both with and without the directory name for ease
140 ## of use.
141 define test_template
142 $(1):
143 @test ! -f ./$(1).log || mv ./$(1).log ./$(1).log~
144 @${MAKE} ./$(1).log WRITE_LOG=
145
146 $(notdir $(1)): $(1)
147 endef
148
149 $(foreach test,${TESTS},$(eval $(call test_template,${test})))
150
151 ## Check that there is no 'automated' subdirectory, which would
152 ## indicate an incomplete merge from an older version of Emacs where
153 ## the tests were arranged differently.
154 .PHONY: check-no-automated-subdir
155 check-no-automated-subdir:
156 test ! -d $(srcdir)/automated
157
158 ## Include dependencies between test files and the files they test.
159 ## We could do this without the file and eval directly, but then we
160 ## would have to run Emacs for every make invocation, and it might not
161 ## be available during clean.
162 -include make-test-deps.mk
163 ## Rerun all default tests.
164 check: mostlyclean check-no-automated-subdir
165 @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}"
166
167 ## Rerun all default and expensive tests.
168 .PHONY: check-expensive
169 check-expensive: mostlyclean check-no-automated-subdir
170 @${MAKE} check-doit SELECTOR="${SELECTOR_EXPENSIVE}"
171
172 ## Re-run all tests which are outdated. A test is outdated if its
173 ## logfile is out-of-date with either the test file, or the source
174 ## files that the tests depend on. The source file dependencies are
175 ## determined by a heuristic and does not identify the full dependency
176 ## graph. See make-test-deps.emacs-lisp for details.
177 .PHONY: check-maybe
178 check-maybe: check-no-automated-subdir
179 @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}"
180
181 ## Run the tests.
182 .PHONY: check-doit
183 check-doit: ${LOGFILES}
184 $(emacs) -l ert -f ert-summarize-tests-batch-and-exit $^
185
186 .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
187
188 mostlyclean:
189 -@for f in ${LOGFILES}; do test ! -f $$f || mv $$f $$f~; done
190
191 clean:
192 -rm -f ${LOGFILES} ${LOGSAVEFILES}
193 -rm make-test-deps.mk
194
195 bootstrap-clean: clean
196 -rm -f ${ELCFILES}
197
198 distclean: clean
199 rm -f Makefile
200
201 maintainer-clean: distclean bootstrap-clean
202
203 make-test-deps.mk: $(ELFILES) make-test-deps.emacs-lisp
204 $(EMACS) --batch -l $(srcdir)/make-test-deps.emacs-lisp \
205 --eval "(make-test-deps \"$(srcdir)\")" \
206 2> $@
207 # Makefile ends here.