summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2011-09-21 16:34:43 -0600
committerEric Schulte <schulte.eric@gmail.com>2011-09-21 16:41:44 -0600
commitdecd7227f669e59a5346ddb601e70699b1219900 (patch)
tree2958bb3796f4f99b8611e05ec65d1e8930c6e52c
parent20e670946e6b5a83b7d92ecf68db84e731db5ffd (diff)
downloadorg-mode-decd7227f669e59a5346ddb601e70699b1219900.tar.gz
only load those test files for which the required executables are present
* testing/org-test.el (org-exe-not-found): An error type used to signal a missing executable (org-test-for-executable): A function used by test files to throw an error if a required executable is not present. (org-test-load): Simply skip files for which the required executables are not present. * testing/lisp/test-ob-R.el: Conditional loading. * testing/lisp/test-ob-awk.el: Conditional loading. * testing/lisp/test-ob-fortran.el: Conditional loading.
-rw-r--r--testing/lisp/test-ob-R.el4
-rw-r--r--testing/lisp/test-ob-awk.el2
-rw-r--r--testing/lisp/test-ob-fortran.el2
-rw-r--r--testing/org-test.el42
4 files changed, 41 insertions, 9 deletions
diff --git a/testing/lisp/test-ob-R.el b/testing/lisp/test-ob-R.el
index 1fe63a5..d60088c 100644
--- a/testing/lisp/test-ob-R.el
+++ b/testing/lisp/test-ob-R.el
@@ -6,6 +6,10 @@
;; Released under the GNU General Public License version 3
;; see: http://www.gnu.org/licenses/gpl-3.0.html
+(org-test-for-executable "R")
+(unless (featurep 'ess)
+ (signal 'org-test-lib-not-found "ess"))
+
(let ((load-path (cons (expand-file-name
".." (file-name-directory
(or load-file-name buffer-file-name)))
diff --git a/testing/lisp/test-ob-awk.el b/testing/lisp/test-ob-awk.el
index 261f8fd..e372fef 100644
--- a/testing/lisp/test-ob-awk.el
+++ b/testing/lisp/test-ob-awk.el
@@ -6,6 +6,8 @@
;; Released under the GNU General Public License version 3
;; see: http://www.gnu.org/licenses/gpl-3.0.html
+(org-test-for-executable "awk")
+
(let ((load-path (cons (expand-file-name
".." (file-name-directory
(or load-file-name buffer-file-name)))
diff --git a/testing/lisp/test-ob-fortran.el b/testing/lisp/test-ob-fortran.el
index d4ccbab..8be3287 100644
--- a/testing/lisp/test-ob-fortran.el
+++ b/testing/lisp/test-ob-fortran.el
@@ -6,6 +6,8 @@
;; Released under the GNU General Public License version 3
;; see: http://www.gnu.org/licenses/gpl-3.0.html
+(org-test-for-executable "gfortran")
+
(let ((load-path (cons (expand-file-name
".." (file-name-directory
(or load-file-name buffer-file-name)))
diff --git a/testing/org-test.el b/testing/org-test.el
index 4d0726a..b0be4f9 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -100,8 +100,25 @@ org-test searches this directory up the directory tree.")
(defconst org-test-link-in-heading-file
(expand-file-name "link-in-heading.org" org-test-dir))
+;; Errors used by test files that shouldn't be run because local
+;; dependencies are missing.
+(put 'org-exe-not-found
+ 'error-conditions
+ '(error org-test-missing-dependency org-test-exe-not-found))
+(put 'org-lib-not-found
+ 'error-conditions
+ '(error org-test-missing-dependency org-test-lib-not-found))
+
;;; Functions for writing tests
+(defun org-test-for-executable (exe)
+ "Throw an error if EXE is not available.
+This can be used at the top of code-block-language specific test
+files to avoid loading the file on systems without the
+executable."
+ (unless (> (length (shell-command-to-string (format "which %s" exe))) 0)
+ (signal 'org-test-exe-not-found exe)))
+
(defun org-test-buffer (&optional file)
"TODO: Setup and return a buffer to work with.
If file is non-nil insert it's contents in there.")
@@ -252,15 +269,22 @@ then remove it and place the point there before running BODY."
(defun org-test-load ()
"Load up the org-mode test suite."
(interactive)
- (flet ((rload (base)
- (mapc
- (lambda (path)
- (if (file-directory-p path) (rload path) (load-file path)))
- (directory-files base 'full
- "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.el$"))))
- (rload (expand-file-name "lisp" org-test-dir))
- (rload (expand-file-name "lisp"
- (expand-file-name "contrib" org-test-dir)))))
+ (flet ((rld (base)
+ ;; Recursively load all files, if files throw errors
+ ;; then silently ignore the error and continue to the
+ ;; next file. This allows files to error out if
+ ;; required executables aren't available.
+ (mapc
+ (lambda (path)
+ (if (file-directory-p path)
+ (rld path)
+ (condition-case nil
+ (load-file path)
+ (org-exe-not-found nil))))
+ (directory-files base 'full
+ "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.el$"))))
+ (rld (expand-file-name "lisp" org-test-dir))
+ (rld (expand-file-name "lisp" (expand-file-name "contrib" org-test-dir)))))
(defun org-test-current-defun ()
"Test the current function."