From c1950ad49a4f84308b67106e19d97cef602dbb5c Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Tue, 5 Aug 2008 17:52:10 +0100 Subject: [PATCH] Added `etest-load-path' functionality and tests. --- etest-execute.el | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ etest.etest | 16 +++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 etest-execute.el diff --git a/etest-execute.el b/etest-execute.el new file mode 100644 index 0000000..b025aaa --- /dev/null +++ b/etest-execute.el @@ -0,0 +1,60 @@ +;;; etest-execute.el --- Help the user run tests. + +;; Copyright (C) 2008 Philip Jackson + +;; Author: Philip Jackson + +;; This file is not currently part of GNU Emacs. + +;; 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 2, 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 ; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; This file will aid the execution of a test run. + +(make-variable-buffer-local + (defvar etest-file nil + "The path of the etest file associated with the current buffer.")) + +(make-variable-buffer-local + (defvar etest-load-path "~/.etests" + "The path of the etest load path.")) + +(defun etest-execute-get-test-file () + "Find a test file by first checking the (buffer local) variable +`etest-file' then checking `etest-load-path' for a similarly +named (to the buffer) file." + (cond + ((and etest-file + (file-exists-p (expand-file-name etest-file))) + (expand-file-name etest-file)) + ((when etest-load-path + (catch 'found + (let ((name (concat + (file-name-sans-extension + (file-name-nondirectory buffer-file-name)) ".etest"))) + (mapc '(lambda (d) + (let ((name (expand-file-name (concat d name)))) + (when (file-exists-p name) + (throw 'found name)))) + etest-load-path))))))) + + +(defun etest-execute () + (interactive)) + + +(provide 'etest-execute) diff --git a/etest.etest b/etest.etest index 29024f0..add00dd 100644 --- a/etest.etest +++ b/etest.etest @@ -1,4 +1,20 @@ (etest + ("Execute" + (null (let ((etest-file nil) + (etest-load-path nil)) + (etest-execute-get-test-file)) + "No etest-file or load-path results in nil") + (like (let ((etest-file "etest.etest")) + (etest-execute-get-test-file)) + (concat default-directory etest-file) + "etest-file being set returns a good path") + (like (let ((etest-file nil) + (etest-load-path default-directory)) + (etest-execute-get-test-file)) + "^etest.etest$" + "Load path being set returns correct value"))) + +(etest ("Etest" ("Simple" (ok 1) -- 2.11.4.GIT