# supported everywhere.
TEST_LOCALE = C
+ # Set this to 'yes' to run the tests in an interactive instance.
+ TEST_INTERACTIVE ?= no
+
+ ifeq ($(TEST_INTERACTIVE),yes)
+ TEST_RUN_ERT = --eval '(ert (quote ${SELECTOR_ACTUAL}))'
+ else
+ TEST_RUN_ERT = --batch --eval '(ert-run-tests-batch-and-exit (quote ${SELECTOR_ACTUAL}))' ${WRITE_LOG}
+ endif
+
# Whether to run tests from .el files in preference to .elc, we do
# this by default since it gives nicer stacktraces.
-TEST_LOAD_EL ?= yes
+# If you just want a pass/fail, setting this to no is much faster.
+export TEST_LOAD_EL ?= \
+ $(if $(findstring $(MAKECMDGOALS), all check check-maybe),no,yes)
+
+# Additional settings for ert.
+ert_opts =
# Maximum length of lines in ert backtraces; nil for no limit.
# (if empty, use the default ert-batch-backtrace-right-margin).
EMACS_TEST_DIRECTORY=$(abspath $(srcdir)) \
$(GDB) "$(EMACS)" $(MODULES_EMACSOPT) $(EMACSOPT)
-test_module_dir := $(srcdir)/data/emacs-module
+ # Set HOME to a nonexistent directory to prevent tests from accessing
+ # it accidentally (e.g., popping up a gnupg dialog if ~/.authinfo.gpg
+ # exists, or writing to ~/.bzr.log when running bzr commands).
+ TEST_HOME = /nonexistent
+
+test_module_dir := data/emacs-module
.PHONY: all check
## We can't put LOGFILES as prerequisites, because that would stop the
## summarizing step from running when there is an error.
check-doit:
+ ifeq ($(TEST_INTERACTIVE), yes)
+ HOME=$(TEST_HOME) $(emacs) \
+ -l ert ${ert_opts} \
+ $(patsubst %,-l %,$(if $(findstring $(TEST_LOAD_EL),yes),$ELFILES,$(ELFILES:.el=))) \
+ $(TEST_RUN_ERT)
+ else
-@${MAKE} -k ${LOGFILES}
- @$(emacs) -l ert --eval \
- @$(emacs) --batch -l ert -f ert-summarize-tests-batch-and-exit ${LOGFILES}
++ @$(emacs) --batch -l ert --eval \
+ "(ert-summarize-tests-batch-and-exit ${SUMMARIZE_TESTS})" ${LOGFILES}
+ endif
.PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
If your test file contains the tests "test-foo", "test2-foo" and
"test-foo-remote", and you want to run only the former two tests, you
- could use a selector regexp: "make <filename> SELECTOR='\"foo$$\"'".
+ could use a selector regexp (note that the "$" needs to be doubled to
+ protect against "make" variable expansion):
+
+ make <filename> SELECTOR='"foo$$"'
Note that although the test files are always compiled (unless they set
-no-byte-compile), the source files will be run by default, to give
-nicer backtraces. To run the compiled version of a test use
+no-byte-compile), the source files will be run when expensive or
+unstable tests are involved, to give nicer backtraces. To run the
+compiled version of a test use
make TEST_LOAD_EL=no ...
+Some tests might take long time to run. In order to summarize the
+<nn> tests with the longest duration, call
+
+ make SUMMARIZE_TESTS=<nn> ...
+
+ The tests are run in batch mode by default; sometimes it's useful to
+ get precisely the same environment but run in interactive mode for
+ debugging. To do that, use
+
+ make TEST_INTERACTIVE=yes ...
+
\f
(Also, see etc/compilation.txt for compilation mode font lock tests.)