Avoid leaving garbage on screen when using 'raise' display property
[emacs.git] / test / Makefile.in
blob5849e9c3ac990386194c52be22e2ec46c0d2201e
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 <http://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 MKDIR_P = @MKDIR_P@
38 SEPCHAR = @SEPCHAR@
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
45 EMACS_EXTRAOPT=
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)
52 # Prevent any settings in the user environment causing problems.
53 unexport EMACSDATA EMACSDOC EMACSPATH GREP_OPTIONS
55 ## To run tests under a debugger, set this to eg: "gdb --args".
56 GDB =
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
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)
68 .PHONY: all check
70 all: check
72 %.elc: %.el
73 @echo Compiling $<
74 @$(emacs) -f batch-byte-compile $<
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: $@
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.
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).
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
109 ## Byte-compile all test files to test for errors (unless explicitly
110 ## told not to), but then evaluate the un-byte-compiled files, because
111 ## they give cleaner stacktraces.
113 ## Beware: it approximates 'no-byte-compile', so watch out for false-positives!
114 %.log: %.el
115 elc=$<c; \
116 if ! grep '^;.*no-byte-compile: t' $< > /dev/null; then \
117 ${MAKE} $$elc; \
118 fi; \
119 loadfile=$<; \
120 echo Testing $$loadfile; \
121 stat=OK ; \
122 ${MKDIR_P} $(dir $@) ; \
123 $(emacs) -l ert -l $$loadfile \
124 --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG}
126 ELFILES = $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \
127 -path "*resources" -prune -o -name "*el" -print)
128 ## .elc files may be in a different directory for out of source builds
129 ELCFILES = $(patsubst %.el,%.elc, \
130 $(patsubst $(srcdir)%,.%,$(ELFILES)))
131 LOGFILES = $(patsubst %.elc,%.log,${ELCFILES})
132 LOGSAVEFILES = $(patsubst %.elc,%.log~,${ELCFILES})
133 TESTS = $(subst ${srcdir}/,,$(LOGFILES:.log=))
135 ## If we have to interrupt a hanging test, preserve the log so we can
136 ## see what the problem was.
137 .PRECIOUS: %.log
139 .PHONY: ${TESTS}
141 ## The short aliases that always re-run the tests, with no logging.
142 ## Define an alias both with and without the directory name for ease
143 ## of use.
144 define test_template
145 $(1):
146 @test ! -f ./$(1).log || mv ./$(1).log ./$(1).log~
147 @${MAKE} ./$(1).log WRITE_LOG=
149 $(notdir $(1)): $(1)
150 endef
152 $(foreach test,${TESTS},$(eval $(call test_template,${test})))
154 ## Check that there is no 'automated' subdirectory, which would
155 ## indicate an incomplete merge from an older version of Emacs where
156 ## the tests were arranged differently.
157 .PHONY: check-no-automated-subdir
158 check-no-automated-subdir:
159 test ! -d $(srcdir)/automated
161 ## Include dependencies between test files and the files they test.
162 ## We could do this without the file and eval directly, but then we
163 ## would have to run Emacs for every make invocation, and it might not
164 ## be available during clean.
165 -include make-test-deps.mk
166 ## Rerun all default tests.
167 check: mostlyclean check-no-automated-subdir
168 @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}"
170 ## Rerun all default and expensive tests.
171 .PHONY: check-expensive
172 check-expensive: mostlyclean check-no-automated-subdir
173 @${MAKE} check-doit SELECTOR="${SELECTOR_EXPENSIVE}"
175 ## Re-run all tests which are outdated. A test is outdated if its
176 ## logfile is out-of-date with either the test file, or the source
177 ## files that the tests depend on. The source file dependencies are
178 ## determined by a heuristic and does not identify the full dependency
179 ## graph. See make-test-deps.emacs-lisp for details.
180 .PHONY: check-maybe
181 check-maybe: check-no-automated-subdir
182 @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}"
184 ## Run the tests.
185 .PHONY: check-doit
186 check-doit: ${LOGFILES}
187 $(emacs) -l ert -f ert-summarize-tests-batch-and-exit $^
189 .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
191 mostlyclean:
192 -@for f in ${LOGFILES}; do test ! -f $$f || mv $$f $$f~; done
193 rm -f *.tmp
195 clean:
196 -rm -f ${LOGFILES} ${LOGSAVEFILES}
197 -rm make-test-deps.mk
199 bootstrap-clean: clean
200 -rm -f ${ELCFILES}
202 distclean: clean
203 rm -f Makefile
205 maintainer-clean: distclean bootstrap-clean
207 make-test-deps.mk: $(ELFILES) make-test-deps.emacs-lisp
208 $(EMACS) --batch -l $(srcdir)/make-test-deps.emacs-lisp \
209 --eval "(make-test-deps \"$(srcdir)\")" \
210 2> $@.tmp
211 # Hack to elide any CANNOT_DUMP=yes chatter.
212 sed '/\.log: /!d' $@.tmp >$@
213 rm -f $@.tmp