Added `etest-load-path' functionality and tests.
[ETest.git] / etest-execute.el
blobb025aaa7d8acad199fd903e3a5f61c7e7252ccec
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 (make-variable-buffer-local
33 (defvar etest-load-path "~/.etests"
34 "The path of the etest load path."))
36 (defun etest-execute-get-test-file ()
37 "Find a test file by first checking the (buffer local) variable
38 `etest-file' then checking `etest-load-path' for a similarly
39 named (to the buffer) file."
40 (cond
41 ((and etest-file
42 (file-exists-p (expand-file-name etest-file)))
43 (expand-file-name etest-file))
44 ((when etest-load-path
45 (catch 'found
46 (let ((name (concat
47 (file-name-sans-extension
48 (file-name-nondirectory buffer-file-name)) ".etest")))
49 (mapc '(lambda (d)
50 (let ((name (expand-file-name (concat d name))))
51 (when (file-exists-p name)
52 (throw 'found name))))
53 etest-load-path)))))))
56 (defun etest-execute ()
57 (interactive))
60 (provide 'etest-execute)