aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2014-06-25 22:47:10 -0700
committerGlenn Morris2014-06-25 22:47:10 -0700
commit5a8816f3f23439bbf46dd4b827134c7608666336 (patch)
treed1ec21e6e4db71948ab9f5836c115e86449f1fb3
parent704172e6d4ef5cf66c087b7eb8643a4309726ff7 (diff)
downloademacs-5a8816f3f23439bbf46dd4b827134c7608666336.tar.gz
emacs-5a8816f3f23439bbf46dd4b827134c7608666336.zip
Simplify and parallize test/automated Makefile
* Makefile.in (mostlyclean, clean): Maybe clean test/automated. * lisp/emacs-lisp/ert.el (ert-summarize-tests-batch-and-exit): New. * test/automated/Makefile.in: Simplify and parallelize. (XARGS_LIMIT, BYTE_COMPILE_EXTRA_FLAGS) (setwins, compile-targets, compile-main, compile-clean): Remove. (GREP_OPTIONS): Unexport. (.el.elc): Replace with pattern rule. (%.elc, %.log): New pattern rules. (ELFILES, LOGFILES): New variables. (check): Depend on LOGFILES. Call ert-summarize-tests-batch-and-exit. (clean, mostlyclean): New rules. (bootstrap-clean): Simplify. (bootstrap-clean, distclean): Depend on clean. * .bzrignore: Ignore test/automated/*.log. Fixes: debbugs:15991
-rw-r--r--ChangeLog4
-rw-r--r--Makefile.in7
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/emacs-lisp/ert.el59
-rw-r--r--test/ChangeLog14
-rw-r--r--test/automated/Makefile.in126
6 files changed, 141 insertions, 73 deletions
diff --git a/ChangeLog b/ChangeLog
index 32fde8b0c4c..397117eb077 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
12014-06-26 Glenn Morris <rgm@gnu.org>
2
3 * Makefile.in (mostlyclean, clean): Maybe clean test/automated.
4
12014-06-21 Paul Eggert <eggert@cs.ucla.edu> 52014-06-21 Paul Eggert <eggert@cs.ucla.edu>
2 6
3 * configure.ac: Warn about --enable-link-time-optimization's issues 7 * configure.ac: Warn about --enable-link-time-optimization's issues
diff --git a/Makefile.in b/Makefile.in
index 1a7acef0c5a..ce44aa5de84 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -798,7 +798,9 @@ mostlyclean_dirs = src oldXMenu lwlib lib lib-src nt doc/emacs doc/misc \
798$(foreach dir,$(mostlyclean_dirs),$(eval $(call submake_template,$(dir),mostlyclean))) 798$(foreach dir,$(mostlyclean_dirs),$(eval $(call submake_template,$(dir),mostlyclean)))
799 799
800mostlyclean: $(mostlyclean_dirs:=_mostlyclean) 800mostlyclean: $(mostlyclean_dirs:=_mostlyclean)
801 801 for dir in test/automated; do \
802 [ ! -d $$dir ] || $(MAKE) -C $$dir mostlyclean; \
803 done
802 804
803### `clean' 805### `clean'
804### Delete all files from the current directory that are normally 806### Delete all files from the current directory that are normally
@@ -813,6 +815,9 @@ clean_dirs = $(mostlyclean_dirs) nextstep
813$(foreach dir,$(clean_dirs),$(eval $(call submake_template,$(dir),clean))) 815$(foreach dir,$(clean_dirs),$(eval $(call submake_template,$(dir),clean)))
814 816
815clean: $(clean_dirs:=_clean) 817clean: $(clean_dirs:=_clean)
818 for dir in test/automated; do \
819 [ ! -d $$dir ] || $(MAKE) -C $$dir clean; \
820 done
816 -rm -f etc/emacs.tmpdesktop 821 -rm -f etc/emacs.tmpdesktop
817 822
818### `bootclean' 823### `bootclean'
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 658825d2ba8..9b4a91a9ea8 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12014-06-26 Glenn Morris <rgm@gnu.org>
2
3 * emacs-lisp/ert.el (ert-summarize-tests-batch-and-exit): New.
4
12014-06-25 Glenn Morris <rgm@gnu.org> 52014-06-25 Glenn Morris <rgm@gnu.org>
2 6
3 * Makefile.in ($(lisp)/progmodes/cc-defs.elc) 7 * Makefile.in ($(lisp)/progmodes/cc-defs.elc)
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 6ecb218091a..024110b93e0 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -1463,6 +1463,65 @@ the tests)."
1463 (kill-emacs 2)))) 1463 (kill-emacs 2))))
1464 1464
1465 1465
1466(defun ert-summarize-tests-batch-and-exit ()
1467 "Summarize the results of testing.
1468Expects to be called in batch mode, with logfiles as command-line arguments.
1469The logfiles should have the `ert-run-tests-batch' format. When finished,
1470this exits Emacs, with status as per `ert-run-tests-batch-and-exit'."
1471 (or noninteractive
1472 (user-error "This function is only for use in batch mode"))
1473 (let ((nlogs (length command-line-args-left))
1474 (ntests 0) (nrun 0) (nexpected 0) (nunexpected 0) (nskipped 0)
1475 nnotrun logfile notests badtests unexpected)
1476 (with-temp-buffer
1477 (while (setq logfile (pop command-line-args-left))
1478 (erase-buffer)
1479 (insert-file-contents logfile)
1480 (if (not (re-search-forward "^Running \\([0-9]+\\) tests" nil t))
1481 (push logfile notests)
1482 (setq ntests (+ ntests (string-to-number (match-string 1))))
1483 (if (not (re-search-forward "^\\(Aborted: \\)?\
1484Ran \\([0-9]+\\) tests, \\([0-9]+\\) results as expected\
1485\\(?:, \\([0-9]+\\) unexpected\\)?\
1486\\(?:, \\([0-9]+\\) skipped\\)?" nil t))
1487 (push logfile badtests)
1488 (if (match-string 1) (push logfile badtests))
1489 (setq nrun (+ nrun (string-to-number (match-string 2)))
1490 nexpected (+ nexpected (string-to-number (match-string 3))))
1491 (when (match-string 4)
1492 (push logfile unexpected)
1493 (setq nunexpected (+ nunexpected
1494 (string-to-number (match-string 4)))))
1495 (if (match-string 5)
1496 (setq nskipped (+ nskipped
1497 (string-to-number (match-string 5)))))))))
1498 (setq nnotrun (- ntests nrun))
1499 (message "\nSUMMARY OF TEST RESULTS")
1500 (message "-----------------------")
1501 (message "Files examined: %d" nlogs)
1502 (message "Ran %d tests%s, %d results as expected%s%s"
1503 nrun
1504 (if (zerop nnotrun) "" (format ", %d failed to run" nnotrun))
1505 nexpected
1506 (if (zerop nunexpected)
1507 ""
1508 (format ", %d unexpected" nunexpected))
1509 (if (zerop nskipped)
1510 ""
1511 (format ", %d skipped" nskipped)))
1512 (when notests
1513 (message "%d files did not contain any tests:" (length notests))
1514 (mapc (lambda (l) (message " %s" l)) notests))
1515 (when badtests
1516 (message "%d files did not finish:" (length badtests))
1517 (mapc (lambda (l) (message " %s" l)) badtests))
1518 (when unexpected
1519 (message "%d files contained unexpected results:" (length unexpected))
1520 (mapc (lambda (l) (message " %s" l)) unexpected))
1521 (kill-emacs (cond ((or notests badtests (not (zerop nnotrun))) 2)
1522 (unexpected 1)
1523 (t 0)))))
1524
1466;;; Utility functions for load/unload actions. 1525;;; Utility functions for load/unload actions.
1467 1526
1468(defun ert--activate-font-lock-keywords () 1527(defun ert--activate-font-lock-keywords ()
diff --git a/test/ChangeLog b/test/ChangeLog
index 3f982ac2809..e3c748c8deb 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,17 @@
12014-06-26 Glenn Morris <rgm@gnu.org>
2
3 * automated/Makefile.in: Simplify and parallelize. (Bug#15991)
4 (XARGS_LIMIT, BYTE_COMPILE_EXTRA_FLAGS)
5 (setwins, compile-targets, compile-main, compile-clean): Remove.
6 (GREP_OPTIONS): Unexport.
7 (.el.elc): Replace with pattern rule.
8 (%.elc, %.log): New pattern rules.
9 (ELFILES, LOGFILES): New variables.
10 (check): Depend on LOGFILES. Call ert-summarize-tests-batch-and-exit.
11 (clean, mostlyclean): New rules.
12 (bootstrap-clean): Simplify.
13 (bootstrap-clean, distclean): Depend on clean.
14
12014-06-25 Glenn Morris <rgm@gnu.org> 152014-06-25 Glenn Morris <rgm@gnu.org>
2 16
3 * automated/flymake-tests.el (flymake-tests--current-face): 17 * automated/flymake-tests.el (flymake-tests--current-face):
diff --git a/test/automated/Makefile.in b/test/automated/Makefile.in
index e0800f09eb0..053812919ad 100644
--- a/test/automated/Makefile.in
+++ b/test/automated/Makefile.in
@@ -24,10 +24,6 @@ VPATH = $(srcdir)
24 24
25SEPCHAR = @SEPCHAR@ 25SEPCHAR = @SEPCHAR@
26 26
27# Empty for all systems except MinGW, where xargs needs an explicit
28# limitation.
29XARGS_LIMIT = @XARGS_LIMIT@
30
31# We never change directory before running Emacs, so a relative file 27# We never change directory before running Emacs, so a relative file
32# name is fine, and makes life easier. If we need to change 28# name is fine, and makes life easier. If we need to change
33# directory, we can use emacs --chdir. 29# directory, we can use emacs --chdir.
@@ -38,87 +34,73 @@ EMACS = ../../src/emacs
38# but we might as well be explicit. 34# but we might as well be explicit.
39EMACSOPT = -batch --no-site-file --no-site-lisp -L "$(SEPCHAR)$(srcdir)" 35EMACSOPT = -batch --no-site-file --no-site-lisp -L "$(SEPCHAR)$(srcdir)"
40 36
41# Extra flags to pass to the byte compiler.
42BYTE_COMPILE_EXTRA_FLAGS =
43
44# Prevent any settings in the user environment causing problems. 37# Prevent any settings in the user environment causing problems.
45unexport EMACSDATA EMACSDOC EMACSPATH 38unexport EMACSDATA EMACSDOC EMACSPATH GREP_OPTIONS
46 39
47# The actual Emacs command run in the targets below. 40# The actual Emacs command run in the targets below.
48# Prevent any setting of EMACSLOADPATH in user environment causing problems. 41# Prevent any setting of EMACSLOADPATH in user environment causing problems.
49emacs = EMACSLOADPATH= LC_ALL=C EMACS_TEST_DIRECTORY=$(srcdir) "$(EMACS)" $(EMACSOPT) 42emacs = EMACSLOADPATH= LC_ALL=C EMACS_TEST_DIRECTORY=$(srcdir) "$(EMACS)" $(EMACSOPT)
50 43
51# Common command to find subdirectories
52setwins=for file in `find $(srcdir) -type d -print`; do \
53 case $$file in $(srcdir)*/data* | $(srcdir)*/flymake* ) ;; \
54 *) wins="$$wins$${wins:+ }$$file" ;; \
55 esac; \
56 done
57
58.PHONY: all check 44.PHONY: all check
59 45
60all: check 46all: check
61 47
62# The compilation stuff is copied from lisp/Makefile - see comments there. 48%.elc: %.el
63
64.SUFFIXES: .elc .el
65
66.el.elc:
67 @echo Compiling $< 49 @echo Compiling $<
68 @$(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $< 50 @$(emacs) -f batch-byte-compile $<
69 51
70 52## Ignore any test errors so we can continue to test other files.
71.PHONY: compile-targets compile-main compile-clean 53## (It would be nice if we could get an error when running an
72 54## individual test, but not when running check.)
73# TARGETS is set dynamically in the recursive call from `compile-main'. 55## But compilation errors are always fatal.
74compile-targets: $(TARGETS) 56##
75 57## I'd prefer to use -emacs -f ert-run-tests-batch-and-exit rather
76# Compile all the Elisp files that need it. Beware: it approximates 58## than || true, since the former makes problems more obvious.
77# `no-byte-compile', so watch out for false-positives! 59## I'd also prefer to @-hide the grep part and not the
78compile-main: compile-clean 60## ert-run-tests-batch-and-exit part.
79 @$(setwins); \ 61##
80 els=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \ 62## We need to use $loadfile because:
81 for el in $$els; do \ 63## i) -L :$srcdir -l basename does not work, because we have files whose
82 test -f $$el || continue; \ 64## basename duplicates a file in lisp/ (eg eshell.el).
83 test ! -f $${el}c && GREP_OPTIONS= grep '^;.*no-byte-compile: t' $$el > /dev/null && continue; \ 65## ii) Although -l basename will automatically load .el or .elc,
84 echo "$${el}c"; \ 66## -l ./basename treats basename as a literal file (it would be nice
85 done | xargs $(XARGS_LIMIT) echo | \ 67## to change this).
86 while read chunk; do \ 68##
87 $(MAKE) compile-targets EMACS="$(EMACS)" TARGETS="$$chunk"; \ 69## Beware: it approximates `no-byte-compile', so watch out for false-positives!
88 done 70%.log: ${srcdir}/%.el
89 71 @if grep '^;.*no-byte-compile: t' $< > /dev/null; then \
90# Erase left-over .elc files that do not have a corresponding .el file. 72 loadfile=$<; \
91compile-clean: 73 else \
92 @$(setwins); \ 74 loadfile=$<c; \
93 elcs=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.elc |g'`; \ 75 ${MAKE} $$loadfile; \
94 for el in $$(echo $$elcs | sed -e 's/\.elc/\.el/g'); do \ 76 fi; \
95 if test -f "$$el" -o \! -f "$${el}c"; then :; else \ 77 echo Testing $$loadfile; \
96 echo rm "$${el}c"; \ 78 stat=OK ; \
97 rm "$${el}c"; \ 79 $(emacs) -l ert -l $$loadfile \
98 fi \ 80 -f ert-run-tests-batch-and-exit >& $@ || stat=ERROR; \
99 done 81 echo $$stat: $@
100 82
101 83ELFILES = $(wildcard ${srcdir}/*.el)
102.PHONY: bootstrap-clean distclean maintainer-clean 84LOGFILES = $(patsubst %.el,%.log,$(notdir ${ELFILES}))
103 85
104bootstrap-clean: 86## If we have to interrupt a hanging test, preserve the log so we can
105 -cd $(srcdir) && rm -f *.elc */*.elc */*/*.elc */*/*/*.elc 87## see what the problem was.
106 88.PRECIOUS: %.log
107distclean: 89
90check: ${LOGFILES}
91 $(emacs) -l ert -f ert-summarize-tests-batch-and-exit $^
92
93.PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
94
95clean mostlyclean:
96 -rm -f *.log
97
98bootstrap-clean: clean
99 -rm -f ${srcdir}/*.elc
100
101distclean: clean
108 rm -f Makefile 102 rm -f Makefile
109 103
110maintainer-clean: distclean bootstrap-clean 104maintainer-clean: distclean bootstrap-clean
111 105
112
113check: compile-main
114 @$(setwins); \
115 pattern=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
116 for el in $$pattern; do \
117 test -f $$el || continue; \
118 args="$$args -l $$el"; \
119 els="$$els $$el"; \
120 done; \
121 echo Testing $$els; \
122 $(emacs) $$args -f ert-run-tests-batch-and-exit
123
124# Makefile ends here. 106# Makefile ends here.