From: Paul Eggert Date: Sat, 1 Apr 2017 19:15:03 +0000 (-0700) Subject: Simplify test dependency generation X-Git-Tag: emacs-26.0.90~522^2~4^2~2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ac2ca82eb19bbf7f1cac7ec3f6c020ebf2b15882;p=emacs.git Simplify test dependency generation Generate default dependencies by using GNU extensions to ‘make’ rather than via a hacky auxiliary program and script. * .gitignore: Remove test/make-test-deps.mk. * test/Makefile.in (ELFILES, LOGFILES, TESTS): Use :=, not =, to avoid multiple redundant invocations of ‘find’. (test_template): Infer dependency directly instead of via make-test-deps.mk. (check-doit): Prepend ‘@’ to avoid excessively long ‘make’ output. (clean): No need to clean make-test-deps.mk. (make-test-deps.mk): Remove rule. * test/make-test-deps.emacs-lisp: Remove. --- diff --git a/.gitignore b/.gitignore index ce1866d616b..aa9e1ff709e 100644 --- a/.gitignore +++ b/.gitignore @@ -141,7 +141,6 @@ src/*.map # Tests. test/indent/*.new -test/make-test-deps.mk test/manual/biditest.txt test/manual/etags/srclist test/manual/etags/regexfile diff --git a/test/Makefile.in b/test/Makefile.in index c0056b6f44d..d218b640057 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -124,12 +124,12 @@ endif $(emacs) -l ert -l $$loadfile \ --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG} -ELFILES = $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \ - -path "*resources" -prune -o -name "*el" -print) +ELFILES := $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \ + -name "*resources" -prune -o -name "*.el" -print) ## .log files may be in a different directory for out of source builds -LOGFILES = $(patsubst %.el,%.log, \ +LOGFILES := $(patsubst %.el,%.log, \ $(patsubst $(srcdir)%,.%,$(ELFILES))) -TESTS = $(subst ${srcdir}/,,$(LOGFILES:.log=)) +TESTS := $(subst ${srcdir}/,,$(LOGFILES:.log=)) ## If we have to interrupt a hanging test, preserve the log so we can ## see what the problem was. @@ -141,6 +141,11 @@ TESTS = $(subst ${srcdir}/,,$(LOGFILES:.log=)) ## Define an alias both with and without the directory name for ease ## of use. define test_template + ifeq (,$(patsubst $(srcdir)/src/%,,$(1))) + $(1): $(srcdir)/../src/$(1:.log=.c) + else + $(1): $(srcdir)/../lisp/$(1:.log=.el) + endif $(1): @test ! -f ./$(1).log || mv ./$(1).log ./$(1).log~ @${MAKE} ./$(1).log WRITE_LOG= @@ -157,11 +162,6 @@ $(foreach test,${TESTS},$(eval $(call test_template,${test}))) check-no-automated-subdir: test ! -d $(srcdir)/automated -## Include dependencies between test files and the files they test. -## We could do this without the file and eval directly, but then we -## would have to run Emacs for every make invocation, and it might not -## be available during clean. --include make-test-deps.mk ## Rerun all default tests. check: mostlyclean check-no-automated-subdir @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}" @@ -175,7 +175,7 @@ check-expensive: mostlyclean check-no-automated-subdir ## logfile is out-of-date with either the test file, or the source ## files that the tests depend on. The source file dependencies are ## determined by a heuristic and does not identify the full dependency -## graph. See make-test-deps.emacs-lisp for details. +## graph. See test_template for details. .PHONY: check-maybe check-maybe: check-no-automated-subdir @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}" @@ -183,7 +183,7 @@ check-maybe: check-no-automated-subdir ## Run the tests. .PHONY: check-doit check-doit: ${LOGFILES} - $(emacs) -l ert -f ert-summarize-tests-batch-and-exit $^ + @$(emacs) -l ert -f ert-summarize-tests-batch-and-exit $^ .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean @@ -193,7 +193,6 @@ mostlyclean: clean: find . '(' -name '*.log' -o -name '*.log~' ')' $(FIND_DELETE) - rm -f make-test-deps.mk bootstrap-clean: clean find $(srcdir) -name '*.elc' $(FIND_DELETE) @@ -202,11 +201,3 @@ distclean: clean rm -f Makefile maintainer-clean: distclean bootstrap-clean - -make-test-deps.mk: $(ELFILES) make-test-deps.emacs-lisp - $(EMACS) --batch -l $(srcdir)/make-test-deps.emacs-lisp \ - --eval "(make-test-deps \"$(srcdir)\")" \ - 2> $@.tmp - # Hack to elide any CANNOT_DUMP=yes chatter. - sed '/\.log: /!d' $@.tmp >$@ - rm -f $@.tmp diff --git a/test/make-test-deps.emacs-lisp b/test/make-test-deps.emacs-lisp deleted file mode 100644 index 609e9276186..00000000000 --- a/test/make-test-deps.emacs-lisp +++ /dev/null @@ -1,98 +0,0 @@ -;; -*- emacs-lisp -*- - -;; Copyright (C) 2015-2017 Free Software Foundation, Inc. - -;; This file is part of GNU Emacs. - -;; GNU Emacs is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; GNU Emacs is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs. If not, see . - -;;; Commentary: - -;; This file generates dependencies between test files and the files -;; that they test. - -;; It has an .emacs-lisp extension because it makes the Makefile easier! - -(require 'seq) - -(defun make-test-deps (src-dir) - (let ((src-dir (file-truename src-dir))) - (message - "%s" - (concat - (make-test-deps-lisp src-dir) - (make-test-deps-src src-dir))))) - -(defun make-test-deps-lisp (src-dir) - (mapconcat - (lambda (file-without-suffix) - (format "./%s-tests.log: %s/../%s.el\n" - file-without-suffix - src-dir - file-without-suffix)) - (make-test-test-files src-dir "lisp") "")) - -(defun make-test-deps-src (src-dir) - (mapconcat - (lambda (file-without-suffix) - (format "./%s-tests.log: %s/../%s.c\n" - file-without-suffix - src-dir - file-without-suffix)) - (make-test-test-files src-dir "src") "")) - -(defun make-test-test-files (src-dir sub-src-dir) - (make-test-munge-files - src-dir - (directory-files-recursively - (concat src-dir "/" sub-src-dir) - ".*-tests.el$"))) - -(defun make-test-munge-files (src-dir files) - (make-test-sans-suffix - (make-test-de-stem - src-dir - (make-test-no-legacy - (make-test-no-test-dir - (make-test-no-resources - files)))))) - -(defun make-test-sans-suffix (files) - (mapcar - (lambda (file) - (substring file 0 -9)) - files)) - -(defun make-test-de-stem (stem files) - (mapcar - (lambda (file) - (substring - file - (+ 1 (length stem)))) - files)) - -(defun make-test-no-legacy (list) - (make-test-remove list "legacy/")) - -(defun make-test-no-resources (list) - (make-test-remove list "-resources/")) - -(defun make-test-no-test-dir (list) - (make-test-remove list "-tests/")) - -(defun make-test-remove (list match) - (seq-remove - (lambda (file) - (string-match-p match file)) - list))