Added new tests.
[ETest.git] / etest-execute.el
blob60048316b9005d24d286d17d7e0bcc5b8b695861
1 ;;; etest-execute.el --- Help the user run tests.
3 ;; Copyright (C) 2008 Philip Jackson
5 ;; Author: Philip Jackson <phil@shellarchive.co.uk>
7 ;; This file is not currently part of GNU Emacs.
9 ;; This program is free software; you can redistribute it and/or
10 ;; modify it under the terms of the GNU General Public License as
11 ;; published by the Free Software Foundation; either version 2, or (at
12 ;; your option) any later version.
14 ;; This program is distributed in the hope that it will be useful, but
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ;; General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with this program ; see the file COPYING. If not, write to
21 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
24 ;;; Commentary:
26 ;; This file will aid the execution of a test run.
28 (make-variable-buffer-local
29 (defvar etest-file nil
30 "The path of the etest file associated with the current buffer."))
32 (defvar etest-load-path '("~/.etests")
33 "The path of the etest load path.")
35 (defun etest-execute-get-test-file ()
36 "Find a test file by first checking the (buffer local) variable
37 `etest-file'. Then checking `etest-load-path' for a similarly
38 named (to the buffer) file. Then looking in `default-directory'."
39 (cond
40 ((and etest-file
41 (file-exists-p (expand-file-name etest-file)))
42 (expand-file-name etest-file))
43 ((catch 'found
44 (let ((etest-load-path (append etest-load-path (list default-directory)))
45 (name (concat
46 (file-name-sans-extension
47 (file-name-nondirectory buffer-file-name)) ".etest")))
48 (mapc '(lambda (d)
49 (let ((name (expand-file-name (concat d "/" name))))
50 (when (file-exists-p name)
51 (throw 'found name))))
52 etest-load-path)
53 nil)))))
55 (defun etest-execute ()
56 (interactive)
57 (let ((file (etest-execute-get-test-file)))
58 (unless file
59 (error "No matching .etest file found"))
60 (load-file file)))
62 (provide 'etest-execute)