org-test: prepare for more selective batch testing

* testing/org-test.el: Conditionalize interactive setup on
  bound-and-true `org-batch-test'.  (org-id-locations-file): New
  defvar.  (org-test-run-batch-tests): Use `org-id-locations-file'
  defined before and add optional argument `org-test-selector' to
  control which tests to run.

This change introduces ability to select the tests to run for batch
testing and removes several dependencies not needed during batch test
when `org-batch-test' is defined in preparation for a corresponding
change in how the build system invokes batch testing.  Full backward
compatibility is maintained.
This commit is contained in:
Achim Gratz 2013-05-19 09:20:17 +02:00
parent 24d3fbacaa
commit e63a7ff70c
1 changed files with 52 additions and 50 deletions

View File

@ -39,51 +39,52 @@
(defconst org-test-link-in-heading-file-ob-anchor
"a8b1d111-eca8-49f0-8930-56d4f0875155")
(let* ((org-test-dir (expand-file-name
(file-name-directory
(or load-file-name buffer-file-name))))
(org-lisp-dir (expand-file-name
(concat org-test-dir "../lisp"))))
(unless (and (boundp 'org-batch-test) org-batch-test)
(let* ((org-test-dir (expand-file-name
(file-name-directory
(or load-file-name buffer-file-name))))
(org-lisp-dir (expand-file-name
(concat org-test-dir "../lisp"))))
(unless (featurep 'org)
(setq load-path (cons org-lisp-dir load-path))
(require 'org)
(require 'org-id)
(require 'ox)
(org-babel-do-load-languages
'org-babel-load-languages '((sh . t) (org . t))))
(unless (featurep 'org)
(setq load-path (cons org-lisp-dir load-path))
(require 'org)
(require 'org-id)
(require 'ox)
(org-babel-do-load-languages
'org-babel-load-languages '((sh . t) (org . t))))
(let* ((load-path (cons
org-test-dir
(cons
(expand-file-name "jump" org-test-dir)
load-path))))
(require 'cl)
(when (= emacs-major-version 22)
(defvar special-mode-map
(let ((map (make-sparse-keymap)))
(suppress-keymap map)
(define-key map "q" 'quit-window)
(define-key map " " 'scroll-up)
(define-key map "\C-?" 'scroll-down)
(define-key map "?" 'describe-mode)
(define-key map "h" 'describe-mode)
(define-key map ">" 'end-of-buffer)
(define-key map "<" 'beginning-of-buffer)
(define-key map "g" 'revert-buffer)
(define-key map "z" 'kill-this-buffer)
map))
(let* ((load-path (cons
org-test-dir
(cons
(expand-file-name "jump" org-test-dir)
load-path))))
(require 'cl)
(when (= emacs-major-version 22)
(defvar special-mode-map
(let ((map (make-sparse-keymap)))
(suppress-keymap map)
(define-key map "q" 'quit-window)
(define-key map " " 'scroll-up)
(define-key map "\C-?" 'scroll-down)
(define-key map "?" 'describe-mode)
(define-key map "h" 'describe-mode)
(define-key map ">" 'end-of-buffer)
(define-key map "<" 'beginning-of-buffer)
(define-key map "g" 'revert-buffer)
(define-key map "z" 'kill-this-buffer)
map))
(put 'special-mode 'mode-class 'special)
(define-derived-mode special-mode nil "Special"
"Parent major mode from which special major modes should inherit."
(setq buffer-read-only t)))
(require 'ert)
(require 'ert-x)
(when (file-exists-p
(expand-file-name "jump/jump.el" org-test-dir))
(require 'jump)
(require 'which-func))))
(put 'special-mode 'mode-class 'special)
(define-derived-mode special-mode nil "Special"
"Parent major mode from which special major modes should inherit."
(setq buffer-read-only t)))
(require 'ert)
(require 'ert-x)
(when (file-exists-p
(expand-file-name "jump/jump.el" org-test-dir))
(require 'jump)
(require 'which-func)))))
(defconst org-test-default-test-file-name "tests.el"
"For each defun a separate file with tests may be defined.
@ -111,6 +112,9 @@ 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))
(defconst org-id-locations-file
(expand-file-name ".test-org-id-locations" org-test-dir))
;;; Functions for writing tests
(put 'missing-test-dependency
@ -408,20 +412,18 @@ setting `pp-escape-newlines' to nil manually."
org-test-example-dir 'full
"^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.org$")))
(defun org-test-run-batch-tests ()
"Run all defined tests matching \"\\(org\\|ob\\)\".
(defun org-test-run-batch-tests (&optional org-test-selector)
"Run all tests matching an optional regex which defaults to \"\\(org\\|ob\\)\".
Load all test files first."
(interactive)
(let ((org-id-track-globally t)
(org-id-locations-file
(convert-standard-filename
(expand-file-name
"testing/.test-org-id-locations"
org-base-dir))))
(org-test-selector
(if org-test-selector org-test-selector "\\(org\\|ob\\)"))
org-confirm-babel-evaluate vc-handled-backends)
(org-test-touch-all-examples)
(org-test-update-id-locations)
(org-test-load)
(ert-run-tests-batch-and-exit "\\(org\\|ob\\)")))
(ert-run-tests-batch-and-exit org-test-selector)))
(defun org-test-run-all-tests ()
"Run all defined tests matching \"\\(org\\|ob\\)\".