Add short test aliases that always re-run the tests
[bpt/emacs.git] / test / automated / Makefile.in
CommitLineData
bbece175
GM
1### @configure_input@
2
ba318903 3# Copyright (C) 2010-2014 Free Software Foundation, Inc.
d221e780
CO
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
06a9b8f6
GM
20### Commentary:
21
22## Some targets:
23## check: re-run all tests
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)
27
28### Code:
29
50b13cde 30SHELL = @SHELL@
d221e780
CO
31
32srcdir = @srcdir@
d221e780 33VPATH = $(srcdir)
d221e780 34
0845be75 35SEPCHAR = @SEPCHAR@
2df10228 36
67fb4e6a
GM
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.
40EMACS = ../../src/emacs
d221e780
CO
41
42# Command line flags for Emacs.
2df10228
GM
43# Apparently MSYS bash would convert "-L :" to "-L ;" anyway,
44# but we might as well be explicit.
0845be75 45EMACSOPT = -batch --no-site-file --no-site-lisp -L "$(SEPCHAR)$(srcdir)"
d221e780 46
e088b01d 47# Prevent any settings in the user environment causing problems.
5a8816f3 48unexport EMACSDATA EMACSDOC EMACSPATH GREP_OPTIONS
e088b01d 49
d221e780 50# The actual Emacs command run in the targets below.
8b77446f 51# Prevent any setting of EMACSLOADPATH in user environment causing problems.
17e0445b 52emacs = EMACSLOADPATH= LC_ALL=C EMACS_TEST_DIRECTORY=$(srcdir) "$(EMACS)" $(EMACSOPT)
d221e780 53
67bb589e 54.PHONY: all check
d221e780 55
67bb589e 56all: check
d221e780 57
5a8816f3 58%.elc: %.el
d221e780 59 @echo Compiling $<
5a8816f3
GM
60 @$(emacs) -f batch-byte-compile $<
61
62## Ignore any test errors so we can continue to test other files.
63## (It would be nice if we could get an error when running an
64## individual test, but not when running check.)
65## But compilation errors are always fatal.
66##
67## I'd prefer to use -emacs -f ert-run-tests-batch-and-exit rather
68## than || true, since the former makes problems more obvious.
69## I'd also prefer to @-hide the grep part and not the
70## ert-run-tests-batch-and-exit part.
71##
72## We need to use $loadfile because:
73## i) -L :$srcdir -l basename does not work, because we have files whose
74## basename duplicates a file in lisp/ (eg eshell.el).
75## ii) Although -l basename will automatically load .el or .elc,
76## -l ./basename treats basename as a literal file (it would be nice
77## to change this).
78##
79## Beware: it approximates `no-byte-compile', so watch out for false-positives!
80%.log: ${srcdir}/%.el
81 @if grep '^;.*no-byte-compile: t' $< > /dev/null; then \
82 loadfile=$<; \
83 else \
84 loadfile=$<c; \
85 ${MAKE} $$loadfile; \
86 fi; \
87 echo Testing $$loadfile; \
88 stat=OK ; \
89 $(emacs) -l ert -l $$loadfile \
d9ca41e7
GM
90 -f ert-run-tests-batch-and-exit >& $@ || { \
91 stat=ERROR; \
92 cat $@; }; \
5a8816f3
GM
93 echo $$stat: $@
94
95ELFILES = $(wildcard ${srcdir}/*.el)
96LOGFILES = $(patsubst %.el,%.log,$(notdir ${ELFILES}))
06a9b8f6 97TESTS = ${LOGFILES:.log=}
5a8816f3
GM
98
99## If we have to interrupt a hanging test, preserve the log so we can
100## see what the problem was.
101.PRECIOUS: %.log
102
06a9b8f6
GM
103.PHONY: ${TESTS}
104
105## The short aliases that always re-run the tests.
106define test_template
107$(1):
108 @test ! -f $(1).log || mv $(1).log $(1).log~
109 @${MAKE} $(1).log
110endef
111
112$(foreach test,${TESTS},$(eval $(call test_template,${test})))
113
114
31eac1d1
GM
115## Re-run all the tests every time.
116check:
117 -@for f in *.log; do test ! -f $$f || mv $$f $$f~; done
118 @${MAKE} check-maybe
119
120## Only re-run tests whose .log is older than the test.
121.PHONY: check-maybe
122check-maybe: ${LOGFILES}
5a8816f3
GM
123 $(emacs) -l ert -f ert-summarize-tests-batch-and-exit $^
124
125.PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
126
127clean mostlyclean:
31eac1d1 128 -rm -f *.log *.log~
5a8816f3
GM
129
130bootstrap-clean: clean
131 -rm -f ${srcdir}/*.elc
132
133distclean: clean
1f43ed41 134 rm -f Makefile
d221e780
CO
135
136maintainer-clean: distclean bootstrap-clean
137
d221e780 138# Makefile ends here.