]> code.delx.au - gnu-emacs-elpa/blob - admin/ert-support.el
New package systemd
[gnu-emacs-elpa] / admin / ert-support.el
1 ;; The contents of this file are subject to the GPL License, Version 3.0.
2
3 ;; Copyright (C) 2016, Free Software Foundation, Inc.
4
5 ;; This program is free software: you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, either version 3 of the License, or
8 ;; (at your option) any later version.
9
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
14
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 (defun ert-support-package-install (top-directory package)
19 ;; blitz default value and set up from elpa.
20 (setq package-archives
21 `(("local-elpa" . ,(concat top-directory "/archive/packages"))))
22 (setq package-user-dir
23 (make-temp-file "elpa-test" t))
24 (package-initialize)
25 (package-refresh-contents)
26 (package-install package))
27
28 (defun ert-support-test-find-tests (package-directory package)
29 (or
30 (directory-files package-directory nil ".*-test.el$")
31 (directory-files package-directory nil ".*-tests.el$")
32 (let ((dir-test
33 (concat package-directory "/test")))
34 (when (file-exists-p dir-test)
35 (directory-files dir-test)))
36 (let ((dir-tests
37 (concat package-directory "/tests")))
38 (when (file-exists-p dir-tests)
39 (directory-files dir-tests)))))
40
41 (defun ert-support-load-tests (package-directory package)
42 (mapc
43 (lambda(file)
44 (message "Loading test file... %s" (concat package-directory file))
45 (load-file (concat package-directory file)))
46 (ert-support-test-find-tests package-directory package)))
47
48 (defun ert-support-test-package (top-directory package)
49 (ert-support-package-install top-directory package)
50 (ert-support-load-tests
51 (concat top-directory "/packages/" (symbol-name package) "/")
52 package)
53
54 (ert-run-tests-batch-and-exit t))