>From 4ede41abf73867d4af990ec9d444d50d21ff79c7 Mon Sep 17 00:00:00 2001 From: Achim Gratz
Date: Sun, 18 Mar 2012 21:02:41 +0100 Subject: [PATCH] Master fixup --- EXPERIMENTAL/org-e-latex.el | 1317 +++++++---- Makefile | 4 +- contrib/babel/langs/ob-fomus.el | 2 +- contrib/babel/langs/ob-oz.el | 2 +- contrib/lisp/htmlize.el | 8 +- contrib/lisp/org-bookmark.el | 4 +- contrib/lisp/org-checklist.el | 3 - contrib/lisp/org-choose.el | 76 +- contrib/lisp/org-collector.el | 4 +- contrib/lisp/org-drill.el | 1 - contrib/lisp/org-element.el | 2546 +++++++++++---------- contrib/lisp/org-eval-light.el | 4 +- contrib/lisp/org-eval.el | 7 +- contrib/lisp/org-expiry.el | 26 +- contrib/lisp/org-export-generic.el | 60 +- contrib/lisp/org-export.el | 3420 ++++++++++++++++++----------- contrib/lisp/org-interactive-query.el | 8 +- contrib/lisp/org-invoice.el | 18 +- contrib/lisp/org-mac-iCal.el | 6 +- contrib/lisp/org-mac-link-grabber.el | 10 +- contrib/lisp/org-mairix.el | 6 +- contrib/lisp/org-mime.el | 4 +- contrib/lisp/org-mtags.el | 1 - contrib/lisp/org-notmuch.el | 10 +- contrib/lisp/org-panel.el | 2 - contrib/lisp/org-registry.el | 8 +- contrib/lisp/org-screen.el | 8 +- contrib/lisp/org-static-mathjax.el | 12 +- contrib/lisp/org-sudoku.el | 6 +- contrib/lisp/org-toc.el | 8 +- contrib/lisp/org-wikinodes.el | 6 +- contrib/lisp/org2rem.el | 6 +- contrib/lisp/test-org-export-preproc.el | 1 - contrib/scripts/StartOzServer.oz | 2 +- contrib/scripts/org2hpda | 2 +- doc/org.texi | 295 ++- doc/orgcard.tex | 2 +- doc/orgguide.texi | 37 +- doc/pdflayout.sty | 2 +- doc/texinfo.tex | 4 +- lisp/ob-awk.el | 4 +- lisp/ob-ditaa.el | 19 +- lisp/ob-exp.el | 130 +- lisp/ob-gnuplot.el | 2 +- lisp/ob-haskell.el | 2 +- lisp/ob-js.el | 1 + lisp/ob-lilypond.el | 96 +- lisp/ob-lisp.el | 1 + lisp/ob-lob.el | 5 +- lisp/ob-ocaml.el | 2 +- lisp/ob-picolisp.el | 9 +- lisp/ob-plantuml.el | 1 + lisp/ob-ref.el | 2 +- lisp/ob-ruby.el | 4 +- lisp/ob-scheme.el | 1 + lisp/ob-sh.el | 46 +- lisp/ob-sql.el | 6 +- lisp/ob-tangle.el | 15 +- lisp/ob.el | 110 +- lisp/org-agenda.el | 49 +- lisp/org-archive.el | 2 + lisp/org-ascii.el | 2 +- lisp/org-attach.el | 1 + lisp/org-bbdb.el | 1 + lisp/org-beamer.el | 10 + lisp/org-bibtex.el | 9 + lisp/org-capture.el | 14 +- lisp/org-clock.el | 18 +- lisp/org-crypt.el | 7 +- lisp/org-ctags.el | 3 + lisp/org-docbook.el | 2 + lisp/org-entities.el | 2 + lisp/org-eshell.el | 2 +- lisp/org-exp-blocks.el | 7 +- lisp/org-exp.el | 6 + lisp/org-faces.el | 3 + lisp/org-feed.el | 2 +- lisp/org-footnote.el | 1 + lisp/org-freemind.el | 1 + lisp/org-gnus.el | 3 +- lisp/org-habit.el | 2 + lisp/org-html.el | 9 + lisp/org-icalendar.el | 4 + lisp/org-id.el | 6 +- lisp/org-indent.el | 7 +- lisp/org-inlinetask.el | 21 +- lisp/org-irc.el | 2 +- lisp/org-latex.el | 21 +- lisp/org-list.el | 66 +- lisp/org-mks.el | 2 +- lisp/org-mobile.el | 16 +- lisp/org-pcomplete.el | 34 +- lisp/org-publish.el | 11 +- lisp/org-remember.el | 3 +- lisp/org-special-blocks.el | 2 +- lisp/org-src.el | 40 +- lisp/org-table.el | 11 +- lisp/org-taskjuggler.el | 16 +- lisp/org-timer.el | 1 + lisp/org-vm.el | 89 +- lisp/org-wl.el | 5 + lisp/org.el | 381 +++- testing/examples/babel.org | 180 +- testing/examples/normal.org | 10 + testing/lisp/test-ob-C.el | 14 +- testing/lisp/test-ob-R.el | 14 +- testing/lisp/test-ob-awk.el | 14 +- testing/lisp/test-ob-emacs-lisp.el | 12 - testing/lisp/test-ob-exp.el | 250 ++- testing/lisp/test-ob-fortran.el | 34 +- testing/lisp/test-ob-lilypond.el | 35 +- testing/lisp/test-ob-lob.el | 2 +- testing/lisp/test-ob-maxima.el | 28 +- testing/lisp/test-ob-octave.el | 14 +- testing/lisp/test-ob-python.el | 14 +- testing/lisp/test-ob-sh.el | 15 +- testing/lisp/test-ob-table.el | 12 +- testing/lisp/test-ob-tangle.el | 11 +- testing/lisp/test-ob.el | 373 +++- testing/lisp/test-org-exp.el | 11 +- testing/lisp/test-org-html.el | 13 +- testing/lisp/test-org-table.el | 38 +- testing/lisp/test-org.el | 57 +- testing/lisp/test-property-inheritance.el | 11 +- testing/org-test-ob-consts.el | 4 +- testing/org-test.el | 30 +- 126 files changed, 6557 insertions(+), 3937 deletions(-) diff --git a/EXPERIMENTAL/org-e-latex.el b/EXPERIMENTAL/org-e-latex.el index f9bf00d..0f52bec 100644 --- a/EXPERIMENTAL/org-e-latex.el +++ b/EXPERIMENTAL/org-e-latex.el @@ -1,6 +1,6 @@ ;;; org-e-latex.el --- LaTeX Back-End For Org Export Engine -;; Copyright (C) 2011 Free Software Foundation, Inc. +;; Copyright (C) 2011-2012 Free Software Foundation, Inc. ;; Author: Nicolas Goaziou\n?\n") ("v" "#+BEGIN_VERSE\n?\n#+END_VERSE" "
:noweb
header argument expansion"
+ "message" "expanded1"
+ "message" "expanded2"
+ "noweb-1-yes-start"
+ "message" "expanded1"
+ "noweb-no-start"
+ "<<noweb-example1>>"
+ "noweb-2-yes-start"
+ "message" "expanded2"
+ "noweb-tangle-start"
+ "<<noweb-example1>>"
+ "<<noweb-example2>>"))))))
+
+(ert-deftest ob-exp/noweb-on-export-with-exports-results ()
+ "Noweb header arguments export correctly using :exports results.
+- yes expand on both export and tangle
+- no expand on neither export or tangle
+- tangle expand on only tangle not export"
+ (org-test-at-id "8701beb4-13d9-468c-997a-8e63e8b66f8d"
+ (org-narrow-to-subtree)
+ (let ((exported-html
+ (org-export-as-html nil nil nil 'string 'body-only))
+ (test-point 0))
+
+ (org-test-with-temp-text-in-file
+ exported-html
+
+ ;; check following ouput exists and in order
+ (mapcar (lambda (x)
+ (should (< test-point
+ (re-search-forward
+ x
+ nil t)))
+ (setq test-point (point)))
+ '(":noweb
header argument expansion using :exports results"
+ "expanded1"
+ "expanded2"
+ "expanded1"
+ "noweb-no-start"
+ "<<noweb-example1>>"
+ "expanded2"
+ "<<noweb-example1>>"
+ "<<noweb-example2>>"))))))
+
+(ert-deftest ob-exp/exports-both ()
+ "Test the :exports both header argument.
+The code block should create both and " + "
" + "" + "code block results" + "")))))) + +(ert-deftest ob-exp/export-with-name () + (let ((org-babel-exp-code-template + "=%name=\n#+BEGIN_SRC %lang%flags\nbody\n#+END_SRC")) + (org-test-at-id "b02ddd8a-eeb8-42ab-8664-8a759e6f43d9" + (org-narrow-to-subtree) + (let ((ascii (org-export-as-ascii nil nil nil 'string 'body-only))) + (should (string-match "qux" ascii)))))) + +(ert-deftest ob-exp/export-with-header-argument () + (let ((org-babel-exp-code-template + " +| header | value | +|---------+----------| +| foo | %foo | +| results | %results | +#+BEGIN_SRC %lang%flags\nbody\n#+END_SRC")) + (org-test-at-id "b02ddd8a-eeb8-42ab-8664-8a759e6f43d9" + (org-narrow-to-subtree) + (let ((ascii (org-export-as-ascii nil nil nil 'string 'body-only))) + (should (string-match "baz" ascii)) + (should (string-match "replace" ascii)))))) + +(ert-deftest ob-exp/noweb-no-export-and-exports-both () + (org-test-at-id "8a820f6c-7980-43db-8a24-0710d33729c9" + (org-narrow-to-subtree) + (let ((html (org-export-as-html nil nil nil 'string 'body-only))) + (should (string-match (regexp-quote "noweb-no-export-and-exports-both-1") + html))))) (ert-deftest ob-exp/evaluate-all-executables-in-order () (org-test-at-id "96cc7073-97ec-4556-87cf-1f9bffafd317" @@ -110,6 +221,49 @@ (org-export-as-ascii nil nil nil 'string) (should (equal '(5 4 3 2 1) *evaluation-collector*))))) +(ert-deftest ob-exp/export-call-line-information () + (org-test-at-id "bec63a04-491e-4caa-97f5-108f3020365c" + (org-narrow-to-subtree) + (let* ((org-babel-exp-call-line-template "\n: call: %line special-token") + (html (org-export-as-html nil nil nil 'string t))) + (should (string-match "double" html)) + (should (string-match "16" html)) + (should (string-match "special-token" html))))) + +(ert-deftest ob-exp/noweb-strip-export-ensure-strips () + (org-test-at-id "8e7bd234-99b2-4b14-8cd6-53945e409775" + (org-narrow-to-subtree) + (org-babel-next-src-block 2) + (should (= 110 (org-babel-execute-src-block))) + (let ((ascii (org-export-as-ascii nil nil nil 'string t))) + (should-not (string-match (regexp-quote "<>") ascii)) + (should-not (string-match (regexp-quote "i=\"10\"") ascii))))) + +(ert-deftest ob-exp/export-from-a-temp-buffer () + :expected-result :failed + (org-test-with-temp-text + " +#+Title: exporting from a temporary buffer + +#+name: foo +#+BEGIN_SRC emacs-lisp + :foo +#+END_SRC + +#+name: bar +#+BEGIN_SRC emacs-lisp + :bar +#+END_SRC + +#+BEGIN_SRC emacs-lisp :var foo=foo :noweb yes :exports results + (list foo < >) +#+END_SRC +" + (let* ((org-current-export-file (current-buffer)) + (ascii (org-export-as-ascii nil nil nil 'string))) + (should (string-match (regexp-quote (format nil "%S" '(:foo :bar))) + ascii))))) + (provide 'test-ob-exp) ;;; test-ob-exp.el ends here diff --git a/testing/lisp/test-ob-fortran.el b/testing/lisp/test-ob-fortran.el index 8be3287..c18cb64 100644 --- a/testing/lisp/test-ob-fortran.el +++ b/testing/lisp/test-ob-fortran.el @@ -1,35 +1,15 @@ ;;; test-ob-fortran.el --- tests for ob-fortran.el -;; Copyright (c) 2010 Sergey Litvinov +;; Copyright (c) 2010-2012 Sergey Litvinov ;; Authors: Sergey Litvinov ;; Released under the GNU General Public License version 3 ;; see: http://www.gnu.org/licenses/gpl-3.0.html +;;; Code: (org-test-for-executable "gfortran") - -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts)) - -(let ((load-path (cons (expand-file-name - "langs" - (expand-file-name - "babel" - (expand-file-name - "contrib" - (expand-file-name - ".." - (expand-file-name - ".." - (file-name-directory - (or load-file-name buffer-file-name))))))) - load-path))) - - (require 'ob-fortran)) +(unless (featurep 'ob-fortran) + (signal 'missing-test-dependency "Support for Fortran code blocks")) (ert-deftest ob-fortran/assert () (should t)) @@ -38,15 +18,13 @@ "Test of hello world program." (org-test-at-id "459384e8-1797-4f11-867e-dde0473ea7cc" (org-babel-next-src-block) - (should (equal "Hello world" (org-babel-execute-src-block)))) -) + (should (equal "Hello world" (org-babel-execute-src-block))))) (ert-deftest ob-fortran/fortran-var-program () "Test a fortran variable" (org-test-at-id "459384e8-1797-4f11-867e-dde0473ea7cc" (org-babel-next-src-block 2) - (should (= 10 (org-babel-execute-src-block)))) -) + (should (= 10 (org-babel-execute-src-block))))) (ert-deftest ob-fortran/input-var () "Test :var" diff --git a/testing/lisp/test-ob-lilypond.el b/testing/lisp/test-ob-lilypond.el index 2ca0597..306c48a 100644 --- a/testing/lisp/test-ob-lilypond.el +++ b/testing/lisp/test-ob-lilypond.el @@ -1,19 +1,14 @@ ;;; test-ob-lilypond.el --- tests for ob-lilypond.el -;; Copyright (c) 2010 Martyn Jago +;; Copyright (c) 2010-2012 Martyn Jago ;; Authors: Martyn Jago ;; Released under the GNU General Public License version 3 ;; see: http://www.gnu.org/licenses/gpl-3.0.html -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts)) - -(require 'ob-lilypond) +;;; Code: +(unless (featurep 'ob-lilypond) + (signal 'missing-test-dependency "Support for Lilypond code blocks")) (save-excursion (set-buffer (get-buffer-create "test-ob-lilypond.el")) @@ -47,10 +42,10 @@ (should (boundp 'ly-version))) (ert-deftest ob-lilypond/ly-version-command () - (should (equal "ob-lilypond version 0.3" (ly-version))) + (should (equal "ob-lilypond version 7.6" (ly-version))) (with-temp-buffer (ly-version t) - (should (equal "ob-lilypond version 0.3" + (should (equal "ob-lilypond version 7.6" (buffer-substring (point-min) (point-max)))))) (ert-deftest ob-lilypond/ly-compile-lilyfile () @@ -61,6 +56,7 @@ t ;display ,(if ly-gen-png "--png" "") ;&rest... ,(if ly-gen-html "--html" "") + ,(if ly-gen-pdf "--pdf" "") ,(if ly-use-eps "-dbackend=eps" "") ,(if ly-gen-svg "-dbackend=svg" "") "--output=test-file" @@ -121,6 +117,9 @@ (ert-deftest ob-lilypond/ly-gen-html () (should (boundp 'ly-gen-html))) +(ert-deftest ob-lilypond/ly-gen-html () + (should (boundp 'ly-gen-pdf))) + (ert-deftest ob-lilypond/use-eps () (should (boundp 'ly-use-eps))) @@ -301,6 +300,18 @@ (ly-toggle-pdf-display) (should (not ly-display-pdf-post-tangle)))) +(ert-deftest ob-lilypond/ly-toggle-pdf-generation-toggles-flag () + (if ly-gen-pdf + (progn + (ly-toggle-pdf-generation) + (should (not ly-gen-pdf)) + (ly-toggle-pdf-generation) + (should ly-gen-pdf)) + (ly-toggle-pdf-generation) + (should ly-gen-pdf) + (ly-toggle-pdf-generation) + (should (not ly-gen-pdf)))) + (ert-deftest ob-lilypond/ly-toggle-arrange-mode () (if ly-arrange-mode (progn @@ -353,6 +364,7 @@ (should (equal '((:tangle . "yes") (:noweb . "yes") (:results . "silent") + (:cache . "yes") (:comments . "yes")) (ly-set-header-args t))) (should (equal '((:results . "file") @@ -364,6 +376,7 @@ (should (equal '((:tangle . "yes") (:noweb . "yes") (:results . "silent") + (:cache . "yes") (:comments . "yes")) org-babel-default-header-args:lilypond)) (ly-set-header-args nil) diff --git a/testing/lisp/test-ob-lob.el b/testing/lisp/test-ob-lob.el index 5d362d8..2cb49ca 100644 --- a/testing/lisp/test-ob-lob.el +++ b/testing/lisp/test-ob-lob.el @@ -1,6 +1,6 @@ ;;; test-ob-lob.el -;; Copyright (c) 2010 Eric Schulte +;; Copyright (c) 2010-2012 Eric Schulte ;; Authors: Eric Schulte ;; Released under the GNU General Public License version 3 diff --git a/testing/lisp/test-ob-maxima.el b/testing/lisp/test-ob-maxima.el index a63908c..4c92af0 100644 --- a/testing/lisp/test-ob-maxima.el +++ b/testing/lisp/test-ob-maxima.el @@ -1,35 +1,13 @@ ;;; test-ob-maxima.el --- tests for ob-maxima.el -;; Copyright (c) 2010 Sergey Litvinov +;; Copyright (c) 2010-2012 Sergey Litvinov ;; Authors: Sergey Litvinov ;; Released under the GNU General Public License version 3 ;; see: http://www.gnu.org/licenses/gpl-3.0.html - (org-test-for-executable "maxima") - -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts)) - -(let ((load-path (cons (expand-file-name - "langs" - (expand-file-name - "babel" - (expand-file-name - "contrib" - (expand-file-name - ".." - (expand-file-name - ".." - (file-name-directory - (or load-file-name buffer-file-name))))))) - load-path))) - - (require 'ob-maxima)) +(unless (featurep 'ob-maxima) + (signal 'missing-test-dependency "Support for Maxima code blocks")) (ert-deftest ob-maxima/assert () (should t)) diff --git a/testing/lisp/test-ob-octave.el b/testing/lisp/test-ob-octave.el index 528a94a..e642679 100644 --- a/testing/lisp/test-ob-octave.el +++ b/testing/lisp/test-ob-octave.el @@ -1,21 +1,13 @@ ;;; test-ob-octave.el --- tests for ob-octave.el -;; Copyright (c) 2010 Sergey Litvinov +;; Copyright (c) 2010-2012 Sergey Litvinov ;; Authors: Sergey Litvinov ;; Released under the GNU General Public License version 3 ;; see: http://www.gnu.org/licenses/gpl-3.0.html - (org-test-for-executable "octave") - -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts)) - -(require 'ob-octave) +(unless (featurep 'ob-octave) + (signal 'missing-test-dependency "Support for Octave code blocks")) (ert-deftest ob-octave/input-none () "Number output" diff --git a/testing/lisp/test-ob-python.el b/testing/lisp/test-ob-python.el index e2990bc..d6a4133 100644 --- a/testing/lisp/test-ob-python.el +++ b/testing/lisp/test-ob-python.el @@ -1,21 +1,15 @@ ;;; test-ob-python.el --- tests for ob-python.el -;; Copyright (c) 2011 Eric Schulte +;; Copyright (c) 2011-2012 Eric Schulte ;; Authors: Eric Schulte ;; Released under the GNU General Public License version 3 ;; see: http://www.gnu.org/licenses/gpl-3.0.html +;;; Code: (org-test-for-executable "python") - -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts)) - -(require 'ob-python) +(unless (featurep 'ob-python) + (signal 'missing-test-dependency "Support for Python code blocks")) (ert-deftest test-ob-python/colnames-yes-header-argument () (org-test-with-temp-text "#+name: eg diff --git a/testing/lisp/test-ob-sh.el b/testing/lisp/test-ob-sh.el index 8ff7081..297c86e 100644 --- a/testing/lisp/test-ob-sh.el +++ b/testing/lisp/test-ob-sh.el @@ -1,6 +1,6 @@ ;;; test-ob-sh.el -;; Copyright (c) 2010 Eric Schulte +;; Copyright (c) 2010-2012 Eric Schulte ;; Authors: Eric Schulte ;; Released under the GNU General Public License version 3 @@ -8,17 +8,10 @@ ;; Template test file for Org-mode tests - ;;; Code: -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts)) - - -;;; Tests +(unless (featurep 'ob-sh) + (signal 'missing-test-dependency "Support for Sh code blocks")) + (ert-deftest test-ob-sh/dont-insert-spaces-on-expanded-bodies () "Expanded shell bodies should not start with a blank line unless the body of the tangled block does." diff --git a/testing/lisp/test-ob-table.el b/testing/lisp/test-ob-table.el index 65fd7af..d25c7a1 100644 --- a/testing/lisp/test-ob-table.el +++ b/testing/lisp/test-ob-table.el @@ -1,6 +1,6 @@ ;;; test-ob-table.el -;; Copyright (c) ߚ Eric Schulte +;; Copyright (c) 2011-2012 Eric Schulte ;; Authors: Eric Schulte ;; Released under the GNU General Public License version 3 @@ -10,17 +10,7 @@ ;; Template test file for Org-mode tests - ;;; Code: -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts)) - - -;;; Tests ;; TODO Test Broken (wrong-type-argument number-or-marker-p "2.0") ;; (ert-deftest test-ob-table/sbe () diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el index 5f0385e..17bb433 100644 --- a/testing/lisp/test-ob-tangle.el +++ b/testing/lisp/test-ob-tangle.el @@ -1,6 +1,6 @@ ;;; test-ob-tangle.el -;; Copyright (c) 2010 Eric Schulte +;; Copyright (c) 2010-2012 Eric Schulte ;; Authors: Eric Schulte ;; Released under the GNU General Public License version 3 @@ -12,15 +12,6 @@ ;;; Code: -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts)) - - -;;; Tests ;; TODO ;; (ert-deftest ob-tangle/noweb-on-tangle () diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 3f4186e..5f9e29c 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -1,18 +1,10 @@ ;;; test-ob.el --- tests for ob.el -;; Copyright (c) 2010, 2011 Eric Schulte +;; Copyright (c) 2010-2012 Eric Schulte ;; Authors: Eric Schulte, Martyn Jago ;; Released under the GNU General Public License version 3 ;; see: http://www.gnu.org/licenses/gpl-3.0.html - -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts)) - (ert-deftest test-org-babel/multi-line-header-regexp () (should(equal "^[ \t]*#\\+headers?:[ \t]*\\([^\n]*\\)$" org-babel-multi-line-header-regexp)) @@ -26,7 +18,7 @@ (match-string 1 " \t #+headers: blah1 blah2 blah3 \t\n\t\n blah4 blah5 blah6 \n"))) - + ;;TODO Check - should this fail? (should (not (org-test-string-exact-match @@ -114,11 +106,21 @@ (ert-deftest test-org-babel/elisp-in-header-arguments () "Test execution of elisp forms in header arguments." - ;; at the babel.org:elisp-forms-in-header-arguments header - (org-test-at-id "22d67284-bf14-4cdc-8319-f4bd876829d7" - (org-babel-next-src-block) - (let ((info (org-babel-get-src-block-info))) - (should (= 4 (org-babel-execute-src-block)))))) + (org-test-with-temp-text-in-file " + +* elisp forms in header arguments + :PROPERTIES: + :var: prop = (* 7 6) + :END: +#+begin_src emacs-lisp + prop +#+end_src" + + (progn + (goto-char (point-min)) + (org-babel-next-src-block) + (let ((info (org-babel-get-src-block-info))) + (should (= 42 (org-babel-execute-src-block))))))) (ert-deftest test-org-babel/simple-named-code-block () "Test that simple named code blocks can be evaluated." @@ -135,37 +137,84 @@ (ert-deftest test-org-babel/simple-variable-resolution () "Test that simple variable resolution is working." - (org-test-at-id "f68821bc-7f49-4389-85b5-914791ee3718" - (org-babel-next-src-block 2) - (should (= 4 (org-babel-execute-src-block))))) + (org-test-with-temp-text-in-file " + +#+name: four +#+begin_src emacs-lisp + (list 1 2 3 4) +#+end_src + +#+begin_src emacs-lisp :var four=four + (length four) +#+end_src" + + (progn + (org-babel-next-src-block 2) + (should (= 4 (org-babel-execute-src-block))) + (forward-line 5) + (should (string= ": 4" (buffer-substring + (point-at-bol) + (point-at-eol))))))) (ert-deftest test-org-babel/multi-line-header-arguments () "Test that multi-line header arguments and can be read." - (org-test-at-id "b77c8857-6c76-4ea9-8a61-ddc2648d96c4" - (org-babel-next-src-block) - (let ((results (org-babel-execute-src-block))) - (should(equal 'a (cadr (assoc 1 results)))) - (should(equal 'd (cadr (assoc 4 results))))))) + (org-test-with-temp-text-in-file " + +#+headers: :var letters='(a b c d e f g) +#+begin_src emacs-lisp :var numbers='(1 2 3 4 5 6 7) + (map 'list #'list numbers letters) +#+end_src" + + (progn + (org-babel-next-src-block) + (let ((results (org-babel-execute-src-block))) + (should(equal 'a (cadr (assoc 1 results)))) + (should(equal 'd (cadr (assoc 4 results)))))))) (ert-deftest test-org-babel/parse-header-args () - (org-test-at-id "7eb0dc6e-1c53-4275-88b3-b22f3113b9c3" - (org-babel-next-src-block) - (let* ((info (org-babel-get-src-block-info)) - (params (nth 2 info))) - (message "%S" params) - (should(equal "example-lang" (nth 0 info))) - (should(string= "the body" (org-babel-trim (nth 1 info)))) - (should-not (member '(:session\ \ \ \ ) params)) - (should(equal '(:session) (assoc :session params))) - (should(equal '(:result-type . output) (assoc :result-type params))) - (should(equal '(num . 9) (cdr (assoc :var params))))))) + (org-test-with-temp-text-in-file " + +#+begin_src example-lang :session :results output :var num=9 + the body +#+end_src" + + (progn + (org-babel-next-src-block) + (let* ((info (org-babel-get-src-block-info)) + (params (nth 2 info))) + (message "%S" params) + (should(equal "example-lang" (nth 0 info))) + (should(string= "the body" (org-babel-trim (nth 1 info)))) + (should-not (member '(:session\ \ \ \ ) params)) + (should(equal '(:session) (assoc :session params))) + (should(equal '(:result-type . output) (assoc :result-type params))) + (should(equal '(num . 9) (cdr (assoc :var params)))))))) (ert-deftest test-org-babel/parse-header-args2 () - (org-test-at-id "2409e8ba-7b5f-4678-8888-e48aa02d8cb4" - (should (string-match (regexp-quote "this is simple") - (org-babel-ref-resolve "simple-subtree"))) - (org-babel-next-src-block) - (should (= 14 (org-babel-execute-src-block))))) + (org-test-with-temp-text-in-file " + +* resolving sub-trees as references + +#+begin_src emacs-lisp :var text=d4faa7b3-072b-4dcf-813c-dd7141c633f3 + (length text) +#+end_src + +#+begin_src org :noweb yes + < > + < > +#+end_src + +** simple subtree with custom ID + :PROPERTIES: + :CUSTOM_ID: simple-subtree + :END: +this is simple" + + (progn + (should (string-match (regexp-quote "this is simple") + (org-babel-ref-resolve "simple-subtree"))) + (org-babel-next-src-block) + (should (= 14 (org-babel-execute-src-block)))))) (ert-deftest test-org-babel/inline-src-blocks () (org-test-at-id "54cb8dc3-298c-4883-a933-029b3c9d4b18" @@ -199,8 +248,7 @@ (should (re-search-forward ":results" nil t)) ;; 4 (should (org-babel-get-inline-src-block-matches)) (end-of-line) - (should-not (org-babel-get-inline-src-block-matches)) - ))) + (should-not (org-babel-get-inline-src-block-matches))))) (ert-deftest test-org-babel/inline-src_blk-default-results-replace-line-1 () (let ((test-line "src_sh{echo 1}")) @@ -227,7 +275,7 @@ (org-test-with-temp-text test-line (should-error (org-ctrl-c-ctrl-c)) - (forward-char) (org-ctrl-c-ctrl-c) + (forward-char) (org-ctrl-c-ctrl-c) (should (string= (concat test-line " =1=") (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) @@ -284,7 +332,7 @@ (concat test-line " =x=") (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))) - + (let ((test-line (concat " Some text prior to block " "src_emacs-lisp[:results replace]{ \"y\" }"))) (org-test-with-temp-text test-line @@ -375,12 +423,25 @@ (point-min) (point-max))))))) (ert-deftest test-org-babel/combining-scalar-and-raw-result-types () - (flet ((next-result () - (org-babel-next-src-block) - (org-babel-execute-src-block) - (goto-char (org-babel-where-is-src-block-result)) - (forward-line 1))) - (org-test-at-id "a73a2ab6-b8b2-4c0e-ae7f-23ad14eab7bc" + (org-test-with-temp-text-in-file " + +#+begin_src sh :results scalar +echo \"[[file:./cv.cls]]\" +#+end_src + +#+name: +: [[file:./cv.cls]] + +#+begin_src sh :results raw scalar + echo \"[[file:./cv.cls]]\" +#+end_src +" + (flet ((next-result () + (org-babel-next-src-block) + (org-babel-execute-src-block) + (goto-char (org-babel-where-is-src-block-result)) + (forward-line 1))) + (goto-char (point-min)) (next-result) (should (org-babel-in-example-or-verbatim)) (next-result) @@ -558,7 +619,7 @@ (check-eval "never-export" nil) (check-eval "no-export" nil)))) -(ert-deftest test-ob/noweb-expansion () +(ert-deftest test-ob/noweb-expansion-1 () (org-test-with-temp-text "#+begin_src sh :results output :tangle yes < > #+end_src @@ -567,7 +628,9 @@ #+begin_src sh bar #+end_src" - (should (string= (org-babel-expand-noweb-references) "bar"))) + (should (string= (org-babel-expand-noweb-references) "bar")))) + +(ert-deftest test-ob/noweb-expansion-2 () (org-test-with-temp-text "#+begin_src sh :results output :tangle yes < > #+end_src @@ -594,6 +657,7 @@ '(":a 1" "b [2 3]" "c (4 :d (5 6))") (org-babel-balanced-split ":a 1 :b [2 3] :c (4 :d (5 6))" '((32 9) . 58))))) + (ert-deftest test-ob/commented-last-block-line-no-var () (org-test-with-temp-text-in-file " #+begin_src emacs-lisp @@ -791,6 +855,213 @@ (defun test-ob-verify-result-and-removed-result (result buffer-text) * next heading")) +(ert-deftest test-org-babel/inline-src_blk-preceded-punct-preceded-by-point () + (let ((test-line ".src_emacs-lisp[ :results verbatim ]{ \"x\" }")) + (org-test-with-temp-text + test-line + (forward-char 1) + (org-ctrl-c-ctrl-c) + (should (re-search-forward "=\"x\"=" nil t)) + (forward-line)))) + +(ert-deftest test-ob/commented-last-block-line-with-var () + (org-test-with-temp-text-in-file " +#+begin_src emacs-lisp :var a=1 +;; +#+end_src" + (progn + (org-babel-next-src-block) + (org-ctrl-c-ctrl-c) + (re-search-forward "\\#\\+results:" nil t) + (forward-line) + (should (string= + "" + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))) + (org-test-with-temp-text-in-file " +#+begin_src emacs-lisp :var a=2 +2;; +#+end_src" + (progn + (org-babel-next-src-block) + (org-ctrl-c-ctrl-c) + (re-search-forward "\\#\\+results:" nil t) + (forward-line) + (should (string= + ": 2" + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))) + +(defun test-ob-verify-result-and-removed-result (result buffer-text) + "Test helper function to test `org-babel-remove-result'. +A temp buffer is populated with BUFFER-TEXT, the first block is executed, +and the result of execution is verified against RESULT. + +The block is actually executed /twice/ to ensure result +replacement happens correctly." + (org-test-with-temp-text + buffer-text + (progn + (org-babel-next-src-block) (org-ctrl-c-ctrl-c) (org-ctrl-c-ctrl-c) + (should (re-search-forward "\\#\\+results:" nil t)) + (forward-line) + (should (string= result + (buffer-substring-no-properties + (point-at-bol) + (- (point-max) 16)))) + (org-babel-previous-src-block) (org-babel-remove-result) + (should (string= buffer-text + (buffer-substring-no-properties + (point-min) (point-max))))))) + +(ert-deftest test-ob/org-babel-remove-result--results-default () + "Test `org-babel-remove-result' with default :results." + (mapcar (lambda (language) + (test-ob-verify-result-and-removed-result + "\n" + (concat +"* org-babel-remove-result +#+begin_src " language " +#+end_src + +* next heading"))) + '("sh" "emacs-lisp"))) + +(ert-deftest test-ob/org-babel-remove-result--results-list () + "Test `org-babel-remove-result' with :results list." + (test-ob-verify-result-and-removed-result + "- 1 +- 2 +- 3 +- (quote (4 5))" + +"* org-babel-remove-result +#+begin_src emacs-lisp :results list +'(1 2 3 '(4 5)) +#+end_src + +* next heading")) + +(ert-deftest test-ob/org-babel-remove-result--results-wrap () + "Test `org-babel-remove-result' with :results wrap." + (test-ob-verify-result-and-removed-result + ":RESULTS: +hello there +:END:" + + "* org-babel-remove-result + +#+begin_src emacs-lisp :results wrap +\"hello there\" +#+end_src + +* next heading")) + +(ert-deftest test-ob/org-babel-remove-result--results-org () + "Test `org-babel-remove-result' with :results org." + (test-ob-verify-result-and-removed-result + "#+BEGIN_ORG +* heading +** subheading +content +#+END_ORG" + +"* org-babel-remove-result +#+begin_src emacs-lisp :results org +\"* heading +** subheading +content\" +#+end_src + +* next heading")) + +(ert-deftest test-ob/org-babel-remove-result--results-html () + "Test `org-babel-remove-result' with :results html." + (test-ob-verify-result-and-removed-result + "#+BEGIN_HTML + +#+END_HTML" + +"* org-babel-remove-result +#+begin_src emacs-lisp :results html +\"\" +#+end_src + +* next heading")) + +(ert-deftest test-ob/org-babel-remove-result--results-latex () + "Test `org-babel-remove-result' with :results latex." + (test-ob-verify-result-and-removed-result + "#+BEGIN_LaTeX +Line 1 +Line 2 +Line 3 +#+END_LaTeX" + +"* org-babel-remove-result +#+begin_src emacs-lisp :results latex +\"Line 1 +Line 2 +Line 3\" +#+end_src + +* next heading")) + +(ert-deftest test-ob/org-babel-remove-result--results-code () + "Test `org-babel-remove-result' with :results code." + + (test-ob-verify-result-and-removed-result + "#+BEGIN_SRC emacs-lisp +\"I am working!\" +#+END_SRC" + +"* org-babel-remove-result +#+begin_src emacs-lisp :results code +(message \"I am working!\") +#+end_src + +* next heading")) + +(ert-deftest test-ob/org-babel-remove-result--results-pp () + "Test `org-babel-remove-result' with :results pp." + (test-ob-verify-result-and-removed-result + ": \"I /am/ working!\"" + +"* org-babel-remove-result +#+begin_src emacs-lisp :results pp +\"I /am/ working!\") +#+end_src + +* next heading")) + +(ert-deftest test-ob/results-do-not-replace-code-blocks () + (org-test-with-temp-text "Block two has a space after the name. + + #+name: foo + #+begin_src emacs-lisp + 1 + #+end_src emacs-lisp + +#+name: foo +#+begin_src emacs-lisp + 2 +#+end_src + +#+name: foo +#+begin_src emacs-lisp + 3 +#+end_src + +#+RESULTS: foo +: foo +" + (dolist (num '(1 2 3)) + ;; execute the block + (goto-char (point-min)) + (org-babel-next-src-block num) (org-babel-execute-src-block) + ;; check the results + (goto-char (point-max)) + (move-beginning-of-line 0) + (should (looking-at (format ": %d" num)))))) + (provide 'test-ob) ;;; test-ob ends here diff --git a/testing/lisp/test-org-exp.el b/testing/lisp/test-org-exp.el index 0ed8d68..1f01499 100644 --- a/testing/lisp/test-org-exp.el +++ b/testing/lisp/test-org-exp.el @@ -1,19 +1,12 @@ ;;; test-org-exp.el --- tests for org-exp.el -;; Copyright (c) 2010 Eric Schulte +;; Copyright (c) 2010-2012 Eric Schulte ;; Authors: Eric Schulte ;; Released under the GNU General Public License version 3 ;; see: http://www.gnu.org/licenses/gpl-3.0.html -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts) - (require 'org-ascii)) - +;;; Code: (ert-deftest test-org-exp/stripping-commas () "Test the stripping of commas from within blocks during export." (org-test-at-id "76d3a083-67fa-4506-a41d-837cc48158b5" diff --git a/testing/lisp/test-org-html.el b/testing/lisp/test-org-html.el index c2cc067..74780bd 100644 --- a/testing/lisp/test-org-html.el +++ b/testing/lisp/test-org-html.el @@ -10,18 +10,9 @@ ;; Template test file for Org-mode tests - ;;; Code: -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts)) - - -;;; Tests -(require 'org-html) +(unless (featurep 'org-html) + (signal 'missing-test-dependency "Support for Org-html")) (defmacro org-test-html/export-link (name link expected &optional desc opt-plist) `(ert-deftest ,(intern (concat "test-org-html/export-link/" name)) () diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index 3ecc384..92c136d 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -10,17 +10,7 @@ ;; Template test file for Org-mode tests - ;;; Code: -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts)) - - -;;; Tests (ert-deftest test-org-table/org-table-convert-refs-to-an/1 () "Simple reference @1$1." (should @@ -54,12 +44,28 @@ ;; (string= "$3 = remote(FOO, @@#$2)" (org-table-convert-refs-to-rc "C& = remote(FOO, @@#B&)")))) (ert-deftest test-org-table/simple-formula () - (org-test-at-id "563523f7-3f3e-49c9-9622-9216cc9a5d95" - (re-search-forward (regexp-quote "#+tblname: simple-formula") nil t) - (forward-line 1) - (should (org-at-table-p)) - (should (org-table-recalculate 'all)) - (should (string= "10" (first (nth 5 (org-table-to-lisp))))))) + (org-test-with-temp-text-in-file " + +* simple formula + :PROPERTIES: + :ID: 563523f7-3f3e-49c9-9622-9216cc9a5d95 + :END: + +#+tblname: simple-formula +| 1 | +| 2 | +| 3 | +| 4 | +|----| +| | + #+TBLFM: $1=vsum(@address@hidden) +" + (progn + (re-search-forward (regexp-quote "#+tblname: simple-formula") nil t) + (forward-line 1) + (should (org-at-table-p)) + (should (org-table-recalculate 'all)) + (should (string= "10" (first (nth 5 (org-table-to-lisp)))))))) (provide 'test-org-table) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 00ccd81..5edc401 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -10,17 +10,7 @@ ;; Template test file for Org-mode tests - ;;; Code: -(let* ((testing-lisp-dir (file-name-directory - (or load-file-name buffer-file-name))) - (load-path (cons testing-lisp-dir load-path))) - (dolist (file (directory-files testing-lisp-dir 'full - "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.org$")) - (require (intern (substring file 0 (- (length file) 3)))))) - - -;;; Tests (ert-deftest test-org/org-link-escape-ascii-character () "Escape an ascii character." (should @@ -92,6 +82,53 @@ "http://some.host.com/form?&id=blah%2Bblah25" (org-link-unescape (org-link-escape "http://some.host.com/form?&id=blah%2Bblah25"))))) +(ert-deftest test-org/accumulated-properties-in-drawers () + "Ensure properties accumulate in subtree drawers." + (org-test-at-id "75282ba2-f77a-4309-a970-e87c149fe125" + (org-babel-next-src-block) + (should (equal '(2 1) (org-babel-execute-src-block))))) + + + +;;; Links + +;;;; Fuzzy links + +;; Fuzzy links [[text]] encompass links to a target (< >), to +;; a target keyword (aka an invisible target: #+TARGET: text), to +;; a named element (#+name: text) and to headlines (* Text). + +(ert-deftest test-org-export/fuzzy-links () + "Test fuzzy links specifications." + ;; 1. Fuzzy link goes in priority to a matching target. + (org-test-with-temp-text + "#+TARGET: Test\n#+NAME: Test\n|a|b|\n< >\n* Test\n[[Test]]" + (goto-line 6) + (org-open-at-point) + (should (looking-at "< >"))) + ;; 2. Fuzzy link should then go to a matching target keyword. + (org-test-with-temp-text + "#+NAME: Test\n|a|b|\n#+TARGET: Test\n* Test\n[[Test]]" + (goto-line 5) + (org-open-at-point) + (should (looking-at "#\\+TARGET: Test"))) + ;; 3. Then fuzzy link points to an element with a given name. + (org-test-with-temp-text "Test\n#+NAME: Test\n|a|b|\n* Test\n[[Test]]" + (goto-line 5) + (org-open-at-point) + (should (looking-at "#\\+NAME: Test"))) + ;; 4. A target still lead to a matching headline otherwise. + (org-test-with-temp-text "* Head1\n* Head2\n*Head3\n[[Head2]]" + (goto-line 4) + (org-open-at-point) + (should (looking-at "\\* Head2"))) + ;; 5. With a leading star in link, enforce heading match. + (org-test-with-temp-text "#+TARGET: Test\n* Test\n< >\n[[*Test]]" + (goto-line 4) + (org-open-at-point) + (should (looking-at "\\* Test")))) + + (provide 'test-org) ;;; test-org.el ends here diff --git a/testing/lisp/test-property-inheritance.el b/testing/lisp/test-property-inheritance.el index 60e955d..a68d7c6 100644 --- a/testing/lisp/test-property-inheritance.el +++ b/testing/lisp/test-property-inheritance.el @@ -1,24 +1,19 @@ ;;; test-ob-R.el --- tests for ob-R.el -;; Copyright (c) 2011 Eric Schulte +;; Copyright (c) 2011-2012 Eric Schulte ;; Authors: Eric Schulte ;; Released under the GNU General Public License version 3 ;; see: http://www.gnu.org/licenses/gpl-3.0.html -(let ((load-path (cons (expand-file-name - ".." (file-name-directory - (or load-file-name buffer-file-name))) - load-path))) - (require 'org-test) - (require 'org-test-ob-consts)) - +;;; Code: (defmacro test-org-in-property-buffer (&rest body) `(with-temp-buffer (insert-file-contents (expand-file-name "property-inheritance.org" org-test-example-dir)) (org-mode) ,@body)) +(def-edebug-spec test-org-in-property-buffer (body)) (ert-deftest test-org-property-accumulation-top-use () (test-org-in-property-buffer diff --git a/testing/org-test-ob-consts.el b/testing/org-test-ob-consts.el index 75b4e3b..c0cb181 100644 --- a/testing/org-test-ob-consts.el +++ b/testing/org-test-ob-consts.el @@ -1,6 +1,6 @@ ;;; org-test-ob-consts.el --- constants for use in code block tests -;; Copyright (c) 2010 Eric Schulte +;; Copyright (c) 2010-2012 Eric Schulte ;; Authors: Eric Schulte ;; Released under the GNU General Public License version 3 @@ -20,4 +20,4 @@ (defconst org-test-link-in-heading-file-ob-anchor (provide 'org-test-ob-consts) -;;; org-test-ob-consts.el ends here \ No newline at end of file +;;; org-test-ob-consts.el ends here diff --git a/testing/org-test.el b/testing/org-test.el index 255cb96..f255584 100644 --- a/testing/org-test.el +++ b/testing/org-test.el @@ -1,6 +1,6 @@ ;;;; org-test.el --- Tests for Org-mode -;; Copyright (c) 2010 Sebastian Rose, Eric Schulte +;; Copyright (c) 2010-2012 Sebastian Rose, Eric Schulte ;; Authors: ;; Sebastian Rose, Hannover, Germany, sebastian_rose gmx de ;; Eric Schulte, Santa Fe, New Mexico, USA, schulte.eric gmail com @@ -30,6 +30,8 @@ ;;;; Code: +(require 'org-test-ob-consts) + (let* ((org-test-dir (expand-file-name (file-name-directory (or load-file-name buffer-file-name)))) @@ -170,6 +172,7 @@ (defmacro org-test-in-example-file (file &rest body) (save-restriction ,@body))) (unless visited-p (kill-buffer to-be-removed)))) +(def-edebug-spec org-test-in-example-file (form body)) (defmacro org-test-at-marker (file marker &rest body) "Run body after placing the point at MARKER in FILE. @@ -198,7 +201,7 @@ (defmacro org-test-with-temp-text (text &rest body) (goto-char ,(match-beginning 0))) `(progn (insert ,inside-text) (goto-char (point-min))))) - ,@body))) + (prog1 ,@body (kill-buffer))))) (def-edebug-spec org-test-with-temp-text (form body)) (defmacro org-test-with-temp-text-in-file (text &rest body) @@ -223,12 +226,8 @@ (defmacro org-test-with-temp-text-in-file (text &rest body) (defjump org-test-jump (("lisp/\\1.el" . "testing/lisp/test-\\1.el") ("lisp/\\1.el" . "testing/lisp/\\1.el/test.*.el") - ("contrib/lisp/\\1.el" . "testing/contrib/lisp/test-\\1.el") - ("contrib/lisp/\\1.el" . "testing/contrib/lisp/\\1.el/test.*.el") ("testing/lisp/test-\\1.el" . "lisp/\\1.el") - ("testing/lisp/\\1.el" . "lisp/\\1.el/test.*.el") - ("testing/contrib/lisp/test-\\1.el" . "contrib/lisp/\\1.el") - ("testing/contrib/lisp/test-\\1.el" . "contrib/lisp/\\1.el/test.*.el")) + ("testing/lisp/\\1.el" . "lisp/\\1.el/test.*.el")) (concat org-base-dir "/") "Jump between org-mode files and their tests." (lambda (path) @@ -312,8 +311,7 @@ (defun org-test-load () :expected-result :failed (should 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))))) + (rld (expand-file-name "lisp" org-test-dir)))) (defun org-test-current-defun () "Test the current function." @@ -328,11 +326,20 @@ (defun org-test-current-file () (file-name-nondirectory (buffer-file-name))) "/"))) +(defvar org-test-buffers nil + "Hold buffers open for running Org-mode tests.") + (defun org-test-touch-all-examples () (dolist (file (directory-files org-test-example-dir 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.org$")) - (find-file file))) + (unless (get-file-buffer file) + (add-to-list 'org-test-buffers (find-file file))))) + +(defun org-test-kill-all-examples () + (while org-test-buffers + (let ((b (pop org-test-buffers))) + (when (buffer-live-p b) (kill-buffer b))))) (defun org-test-update-id-locations () (org-id-update-id-locations @@ -361,7 +368,8 @@ (defun org-test-run-all-tests () (interactive) (org-test-touch-all-examples) (org-test-load) - (ert "\\(org\\|ob\\)")) + (ert "\\(org\\|ob\\)") + (org-test-kill-all-examples)) (provide 'org-test) -- 1.7.9.2