From: Phillip Lord Date: Thu, 21 Jan 2016 17:46:30 +0000 (+0000) Subject: Add test capability to ELPA X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/381726a3c99bdbd4d6f067c24e755a99f95d06cf Add test capability to ELPA make check now attempts to run tests in all packages. --- diff --git a/.gitignore b/.gitignore index 72ebc0fe5..43c9d2b03 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,8 @@ packages/rudel packages/soap-client packages/w3 packages/xelb + +# Testing file +/archive +*.log +*.buildlog \ No newline at end of file diff --git a/GNUmakefile b/GNUmakefile index ad86a7f8d..d23d52316 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,4 +1,5 @@ # Makefile for GNU Emacs Lisp Package Archive. +# EMACS=emacs --batch @@ -190,3 +191,31 @@ all-in-place: $(extra_elcs) $(autoloads) $(pkg_descs) externals: $(EMACS) -l admin/archive-contents.el \ -f archive-add/remove/update-externals + + + + +################### Testing ############### + +PACKAGE_DIRS = $(shell find packages -maxdepth 1 -type d) +PACKAGES=$(subst /,,$(subst packages,,$(PACKAGE_DIRS))) + +TOP =$(shell pwd) + +define test_template +$(1)-test: + cd packages/$(1);\ + $(EMACS) -l $(TOP)/admin/ert-support.el \ + --eval "(ert-support-test-package \"$(TOP)\" '$(1))" \ + +$(1)-test-log: + $(MAKE) $(1)-test > packages/$(1)/$(1).log 2>&1 || { stat=ERROR; } +endef + +$(foreach package,$(PACKAGES),$(eval $(call test_template,$(package)))) + +PACKAGES_TESTS=$(addsuffix -test-log,$(PACKAGES)) +PACKAGES_LOG=$(foreach package,$(PACKAGES),packages/$(package)/$(package).log) + +check: $(PACKAGES_TESTS) + $(EMACS) -l ert -f ert-summarize-tests-batch-and-exit $(PACKAGES_LOG) diff --git a/admin/ert-support.el b/admin/ert-support.el new file mode 100644 index 000000000..93d1af8ff --- /dev/null +++ b/admin/ert-support.el @@ -0,0 +1,54 @@ +;; The contents of this file are subject to the GPL License, Version 3.0. + +;; Copyright (C) 2016, Free Software Foundation, Inc. + +;; This program 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. + +;; This program 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 this program. If not, see . + +(defun ert-support-package-install (top-directory package) + ;; blitz default value and set up from elpa. + (setq package-archives + `(("local-elpa" . ,(concat top-directory "/archive/packages")))) + (setq package-user-dir + (make-temp-file "elpa-test" t)) + (package-initialize) + (package-refresh-contents) + (package-install package)) + +(defun ert-support-test-find-tests (package-directory package) + (or + (directory-files package-directory nil ".*-test.el$") + (directory-files package-directory nil ".*-tests.el$") + (let ((dir-test + (concat package-directory "/test"))) + (when (file-exists-p dir-test) + (directory-files dir-test))) + (let ((dir-tests + (concat package-directory "/tests"))) + (when (file-exists-p dir-tests) + (directory-files dir-tests))))) + +(defun ert-support-load-tests (package-directory package) + (mapc + (lambda(file) + (message "Loading test file... %s" (concat package-directory file)) + (load-file (concat package-directory file))) + (ert-support-test-find-tests package-directory package))) + +(defun ert-support-test-package (top-directory package) + (ert-support-package-install top-directory package) + (ert-support-load-tests + (concat top-directory "/packages/" (symbol-name package) "/") + package) + + (ert-run-tests-batch-and-exit t))