>From 2c2dfd66718d464288c91824ecff8564ee6f3d91 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 16 Dec 2017 20:06:11 -0500 Subject: [PATCH v2 2/3] ; test/Makefile.in: Add TEST_INTERACTIVE option (Bug#31744). * test/README: Note the new option. --- test/Makefile.in | 33 +++++++++++++++++++++++++++------ test/README | 6 ++++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/test/Makefile.in b/test/Makefile.in index e6b3f77523..451513a747 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -81,7 +81,7 @@ EMACS_EXTRAOPT= # Command line flags for Emacs. # Apparently MSYS bash would convert "-L :" to "-L ;" anyway, # but we might as well be explicit. -EMACSOPT = -batch --no-site-file --no-site-lisp -L "$(SEPCHAR)$(srcdir)" $(EMACS_EXTRAOPT) +EMACSOPT = --no-init-file --no-site-file --no-site-lisp -L "$(SEPCHAR)$(srcdir)" $(EMACS_EXTRAOPT) # Prevent any settings in the user environment causing problems. unexport EMACSDATA EMACSDOC EMACSPATH GREP_OPTIONS @@ -94,6 +94,15 @@ GDB = # 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 ${SELECTOR_ACTUAL})" +else +TEST_RUN_ERT = --batch --eval "(ert-run-tests-batch-and-exit ${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 @@ -120,6 +129,11 @@ emacs = EMACS_TEST_DIRECTORY=$(abspath $(srcdir)) \ $(GDB) "$(EMACS)" $(MODULES_EMACSOPT) $(EMACSOPT) +# 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 := $(srcdir)/data/emacs-module .PHONY: all check @@ -128,7 +142,7 @@ all: SELECTOR_DEFAULT = (quote (not (or (tag :expensive-test) (tag :unstable)))) SELECTOR_EXPENSIVE = (quote (not (tag :unstable))) -SELECTOR_ALL = nil +SELECTOR_ALL = t ifdef SELECTOR SELECTOR_ACTUAL=$(SELECTOR) else ifndef MAKECMDGOALS @@ -145,7 +159,7 @@ SELECTOR_ACTUAL= ## Byte-compile all test files to test for errors. %.elc: %.el - $(AM_V_ELC)$(emacs) -f batch-byte-compile $< + $(AM_V_ELC)$(emacs) --batch -f batch-byte-compile $< ## Save logs, and show logs for failed tests. WRITE_LOG = > $@ 2>&1 || { STAT=$$?; cat $@; exit $$STAT; } @@ -158,9 +172,9 @@ testloadfile = %.log: %.elc $(AM_V_at)${MKDIR_P} $(dir $@) - $(AM_V_GEN)HOME=/nonexistent $(emacs) \ + $(AM_V_GEN)HOME=$(TEST_HOME) $(emacs) \ -l ert ${ert_opts} -l $(testloadfile) \ - --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG} + $(TEST_RUN_ERT) ifeq (@HAVE_MODULES@, yes) maybe_exclude_module_tests := @@ -260,8 +274,15 @@ .PHONY: ## 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 -f ert-summarize-tests-batch-and-exit ${LOGFILES} + @$(emacs) --batch -l ert -f ert-summarize-tests-batch-and-exit ${LOGFILES} +endif .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean diff --git a/test/README b/test/README index 1cd9db3bb8..c1dde2e0d0 100644 --- a/test/README +++ b/test/README @@ -50,6 +50,12 @@ nicer backtraces. To run the compiled version of a test use make TEST_LOAD_EL=no ... +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 ... + (Also, see etc/compilation.txt for compilation mode font lock tests.) -- 2.11.0