* admin/gitmerge.el (gitmerge-missing):
[emacs.git] / test / Makefile.in
blobdafa0f0aa1966cf48ba913f242517910bd123fde
1 ### @configure_input@
3 # Copyright (C) 2010-2017 Free Software Foundation, Inc.
5 # This file is part of GNU Emacs.
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.
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.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
20 ### Commentary:
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
29 ### Code:
31 SHELL = @SHELL@
33 srcdir = @srcdir@
34 VPATH = $(srcdir)
36 FIND_DELETE = @FIND_DELETE@
37 MKDIR_P = @MKDIR_P@
38 CC = @CC@
39 CFLAGS = @CFLAGS@
40 PROFILING_CFLAGS = @PROFILING_CFLAGS@
41 WARN_CFLAGS = @WARN_CFLAGS@
42 WERROR_CFLAGS = @WERROR_CFLAGS@
43 CPPFLAGS = @CPPFLAGS@
44 SO = @MODULES_SUFFIX@
46 SEPCHAR = @SEPCHAR@
49 # 'make' verbosity.
50 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
52 AM_V_CCLD = $(am__v_CCLD_@AM_V@)
53 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
54 am__v_CCLD_0 = @echo " CCLD " $@;
55 am__v_CCLD_1 =
57 AM_V_ELC = $(am__v_ELC_@AM_V@)
58 am__v_ELC_ = $(am__v_ELC_@AM_DEFAULT_V@)
59 am__v_ELC_0 = @echo " ELC " $@;
60 am__v_ELC_1 =
62 AM_V_GEN = $(am__v_GEN_@AM_V@)
63 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
64 am__v_GEN_0 = @echo " GEN " $@;
65 am__v_GEN_1 =
67 AM_V_at = $(am__v_at_@AM_V@)
68 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
69 am__v_at_0 = @
70 am__v_at_1 =
73 # We never change directory before running Emacs, so a relative file
74 # name is fine, and makes life easier. If we need to change
75 # directory, we can use emacs --chdir.
76 EMACS = ../src/emacs
78 EMACS_EXTRAOPT=
80 # Command line flags for Emacs.
81 # Apparently MSYS bash would convert "-L :" to "-L ;" anyway,
82 # but we might as well be explicit.
83 EMACSOPT = -batch --no-site-file --no-site-lisp -L "$(SEPCHAR)$(srcdir)" $(EMACS_EXTRAOPT)
85 # Prevent any settings in the user environment causing problems.
86 unexport EMACSDATA EMACSDOC EMACSPATH GREP_OPTIONS
88 ## To run tests under a debugger, set this to eg: "gdb --args".
89 GDB =
91 # The locale to run tests under. Tests should work if this is set to
92 # any supported locale. Use the C locale by default, as it should be
93 # supported everywhere.
94 TEST_LOCALE = C
96 # Whether to run tests from .el files in preference to .elc, we do
97 # this by default since it gives nicer stacktraces.
98 TEST_LOAD_EL ?= yes
100 # Maximum length of lines in ert backtraces; nil for no limit.
101 # (if empty, use the default ert-batch-backtrace-right-margin).
102 TEST_BACKTRACE_LINE_LENGTH =
104 ifeq (${TEST_BACKTRACE_LINE_LENGTH},)
105 ert_opts =
106 else
107 ert_opts = --eval '(setq ert-batch-backtrace-right-margin ${TEST_BACKTRACE_LINE_LENGTH})'
108 endif
110 ifeq (@HAVE_MODULES@, yes)
111 MODULES_EMACSOPT := --module-assertions
112 else
113 MODULES_EMACSOPT :=
114 endif
116 # The actual Emacs command run in the targets below.
117 # Prevent any setting of EMACSLOADPATH in user environment causing problems.
118 emacs = EMACSLOADPATH= LC_ALL=$(TEST_LOCALE) \
119 EMACS_TEST_DIRECTORY=$(abspath $(srcdir)) \
120 $(GDB) "$(EMACS)" $(MODULES_EMACSOPT) $(EMACSOPT)
122 test_module_dir := $(srcdir)/data/emacs-module
124 .PHONY: all check
126 all: check
128 SELECTOR_DEFAULT = (quote (not (tag :expensive-test)))
129 SELECTOR_EXPENSIVE = nil
130 ifdef SELECTOR
131 SELECTOR_ACTUAL=$(SELECTOR)
132 else ifndef MAKECMDGOALS
133 SELECTOR_ACTUAL=$(SELECTOR_DEFAULT)
134 else ifeq ($(MAKECMDGOALS),all)
135 SELECTOR_ACTUAL=$(SELECTOR_DEFAULT)
136 else ifeq ($(MAKECMDGOALS),check)
137 SELECTOR_ACTUAL=$(SELECTOR_DEFAULT)
138 else ifeq ($(MAKECMDGOALS),check-maybe)
139 SELECTOR_ACTUAL=$(SELECTOR_DEFAULT)
140 else
141 SELECTOR_ACTUAL=$(SELECTOR_EXPENSIVE)
142 endif
144 ## Byte-compile all test files to test for errors.
145 %.elc: %.el
146 $(AM_V_ELC)$(emacs) -f batch-byte-compile $<
148 ## Save logs, and show logs for failed tests.
149 WRITE_LOG = > $@ 2>&1 || { STAT=$$?; cat $@; exit $$STAT; }
150 ifdef EMACS_HYDRA_CI
151 ## On Hydra, always show logs for certain problematic tests.
152 lisp/emacs-lisp/eieio-tests/eieio-tests.log \
153 lisp/net/tramp-tests.log \
154 : WRITE_LOG = 2>&1 | tee $@
155 endif
157 ifeq ($(TEST_LOAD_EL), yes)
158 testloadfile = $*.el
159 else
160 testloadfile = $*
161 endif
163 %.log: %.elc
164 $(AM_V_at)${MKDIR_P} $(dir $@)
165 $(AM_V_GEN)HOME=/nonexistent $(emacs) \
166 -l ert ${ert_opts} -l $(testloadfile) \
167 --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG}
169 ifeq (@HAVE_MODULES@, yes)
170 maybe_exclude_module_tests :=
171 else
172 maybe_exclude_module_tests := -name emacs-module-tests.el -prune -o
173 endif
175 ELFILES := $(sort $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \
176 -path "${srcdir}/data" -prune -o \
177 -name "*resources" -prune -o \
178 ${maybe_exclude_module_tests} \
179 -name "*.el" ! -name ".*" -print))
180 ## .log files may be in a different directory for out of source builds
181 LOGFILES := $(patsubst %.el,%.log, \
182 $(patsubst $(srcdir)/%,%,$(ELFILES)))
183 TESTS := $(LOGFILES:.log=)
185 ## If we have to interrupt a hanging test, preserve the log so we can
186 ## see what the problem was.
187 .PRECIOUS: %.log
189 ## Stop make deleting these as intermediate files.
190 .SECONDARY: ${ELFILES:.el=.elc} $(test_module_dir)/*.o
192 .PHONY: ${TESTS}
194 define test_template
195 ## A test FOO-tests depends on the source file with the similar
196 ## name, unless FOO itself contains the string '-tests/'.
197 ## The similar name is FOO.c if FOO begins with '{lib-,}src/', FOO.el
198 ## otherwise. Although this heuristic does not identify all the
199 ## dependencies, it is better than nothing.
200 ifeq (,$(patsubst %-tests,,$(1))$(findstring -tests/,$(1)))
201 $(1).log: $(patsubst %-tests,$(srcdir)/../%,$(1))$(if \
202 $(patsubst src/%,,$(patsubst lib-src/%,,$(1))),.el,.c)
203 endif
205 ## Short aliases that always re-run the tests, with no logging.
206 ## Define both with and without the directory name for ease of use.
207 .PHONY: $(1) $(notdir $(1))
208 $(1):
209 @test ! -f $(1).log || mv $(1).log $(1).log~
210 @$(MAKE) $(1).log WRITE_LOG=
211 $(notdir $(1)): $(1)
212 endef
214 $(foreach test,${TESTS},$(eval $(call test_template,${test})))
216 ifeq (@HAVE_MODULES@, yes)
217 # -fPIC is a no-op on Windows, but causes a compiler warning
218 ifeq ($(SO),.dll)
219 FPIC_CFLAGS =
220 else
221 FPIC_CFLAGS = -fPIC
222 endif
224 MODULE_CFLAGS = -I$(srcdir)/../src $(FPIC_CFLAGS) $(PROFILING_CFLAGS) \
225 $(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAGS)
227 test_module = $(test_module_dir)/mod-test${SO}
228 src/emacs-module-tests.log: $(test_module)
229 $(test_module): $(test_module:${SO}=.c) $(srcdir)/../src/emacs-module.h
230 $(AM_V_CCLD)$(CC) -shared $(CPPFLAGS) $(MODULE_CFLAGS) $(LDFLAGS) \
231 -o $@ $<
232 endif
234 ## Check that there is no 'automated' subdirectory, which would
235 ## indicate an incomplete merge from an older version of Emacs where
236 ## the tests were arranged differently.
237 .PHONY: check-no-automated-subdir
238 check-no-automated-subdir:
239 ${AM_V_at}test ! -d $(srcdir)/automated
241 ## Rerun all default tests.
242 check: mostlyclean check-no-automated-subdir
243 @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}"
245 ## Rerun all default and expensive tests.
246 .PHONY: check-expensive
247 check-expensive: mostlyclean check-no-automated-subdir
248 @${MAKE} check-doit SELECTOR="${SELECTOR_EXPENSIVE}"
250 ## Re-run all tests which are outdated. A test is outdated if its
251 ## logfile is out-of-date with either the test file, or the source
252 ## files that the tests depend on. See test_template.
253 .PHONY: check-maybe
254 check-maybe: check-no-automated-subdir
255 @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}"
257 ## Run the tests.
258 .PHONY: check-doit
259 ## We can't put LOGFILES as prerequisites, because that would stop the
260 ## summarizing step from running when there is an error.
261 check-doit:
262 -@${MAKE} -k ${LOGFILES}
263 @$(emacs) -l ert -f ert-summarize-tests-batch-and-exit ${LOGFILES}
265 .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
267 mostlyclean:
268 -@for f in ${LOGFILES}; do test ! -f $$f || mv $$f $$f~; done
269 rm -f *.tmp
271 clean:
272 find . '(' -name '*.log' -o -name '*.log~' ')' $(FIND_DELETE)
273 rm -f $(test_module_dir)/*.o $(test_module_dir)/*.so \
274 $(test_module_dir)/*.dll
276 bootstrap-clean: clean
277 find $(srcdir) -name '*.elc' $(FIND_DELETE)
279 distclean: clean
280 rm -f Makefile
282 maintainer-clean: distclean bootstrap-clean