Merge from emacs-24; up to 117702
[emacs.git] / test / automated / Makefile.in
blobe0eaffa4c2c09284cb5c926956e761be5e8db55e
1 ### @configure_input@
3 # Copyright (C) 2010-2014 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 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
28 ### Code:
30 SHELL = @SHELL@
32 srcdir = @srcdir@
33 VPATH = $(srcdir)
35 SEPCHAR = @SEPCHAR@
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
42 # Command line flags for Emacs.
43 # Apparently MSYS bash would convert "-L :" to "-L ;" anyway,
44 # but we might as well be explicit.
45 EMACSOPT = -batch --no-site-file --no-site-lisp -L "$(SEPCHAR)$(srcdir)"
47 # Prevent any settings in the user environment causing problems.
48 unexport EMACSDATA EMACSDOC EMACSPATH GREP_OPTIONS
50 ## To run tests under a debugger, set this to eg: "gdb --args".
51 GDB =
53 # The actual Emacs command run in the targets below.
54 # Prevent any setting of EMACSLOADPATH in user environment causing problems.
55 emacs = EMACSLOADPATH= LC_ALL=C EMACS_TEST_DIRECTORY=$(srcdir) $(GDB) "$(EMACS)" $(EMACSOPT)
57 .PHONY: all check
59 all: check
61 %.elc: %.el
62 @echo Compiling $<
63 @$(emacs) -f batch-byte-compile $<
65 ## Ignore any test errors so we can continue to test other files.
66 ## But compilation errors are always fatal.
67 WRITE_LOG = >& $@ || { stat=ERROR; cat $@; }; echo $$stat: $@
69 ## I'd prefer to use -emacs -f ert-run-tests-batch-and-exit rather
70 ## than || true, since the former makes problems more obvious.
71 ## I'd also prefer to @-hide the grep part and not the
72 ## ert-run-tests-batch-and-exit part.
74 ## We need to use $loadfile because:
75 ## i) -L :$srcdir -l basename does not work, because we have files whose
76 ## basename duplicates a file in lisp/ (eg eshell.el).
77 ## ii) Although -l basename will automatically load .el or .elc,
78 ## -l ./basename treats basename as a literal file (it would be nice
79 ## to change this; bug#17848 - if that gets done, this can be simplified).
81 ## Beware: it approximates `no-byte-compile', so watch out for false-positives!
82 %.log: ${srcdir}/%.el
83 @if grep '^;.*no-byte-compile: t' $< > /dev/null; then \
84 loadfile=$<; \
85 else \
86 loadfile=$<c; \
87 ${MAKE} $$loadfile; \
88 fi; \
89 echo Testing $$loadfile; \
90 stat=OK ; \
91 $(emacs) -l ert -l $$loadfile \
92 -f ert-run-tests-batch-and-exit ${WRITE_LOG}
94 ELFILES = $(wildcard ${srcdir}/*.el)
95 LOGFILES = $(patsubst %.el,%.log,$(notdir ${ELFILES}))
96 TESTS = ${LOGFILES:.log=}
98 ## If we have to interrupt a hanging test, preserve the log so we can
99 ## see what the problem was.
100 .PRECIOUS: %.log
102 .PHONY: ${TESTS}
104 ## The short aliases that always re-run the tests, with no logging.
105 define test_template
106 $(1):
107 @test ! -f $(1).log || mv $(1).log $(1).log~
108 @${MAKE} $(1).log WRITE_LOG=
109 endef
111 $(foreach test,${TESTS},$(eval $(call test_template,${test})))
114 ## Re-run all the tests every time.
115 check:
116 -@for f in *.log; do test ! -f $$f || mv $$f $$f~; done
117 @${MAKE} check-maybe
119 ## Only re-run tests whose .log is older than the test.
120 .PHONY: check-maybe
121 check-maybe: ${LOGFILES}
122 $(emacs) -l ert -f ert-summarize-tests-batch-and-exit $^
124 .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
126 clean mostlyclean:
127 -rm -f *.log *.log~
129 bootstrap-clean: clean
130 -rm -f ${srcdir}/*.elc
132 distclean: clean
133 rm -f Makefile
135 maintainer-clean: distclean bootstrap-clean
137 # Makefile ends here.