diff options
author | Gustav Wikström <gustav@whil.se> | 2019-05-26 03:34:34 +0200 |
---|---|---|
committer | Gustav Wikström <gustav@whil.se> | 2019-07-07 19:42:50 +0200 |
commit | 3cbe356b0a9d1a98848df0fa09ba306392995b88 (patch) | |
tree | eb79fc26eae77af39e2e6a442c1d0bdeee37d40f | |
parent | 0201d1c0cc367fea0e561ba113f02f263b0ed501 (diff) | |
download | org-mode-3cbe356b0a9d1a98848df0fa09ba306392995b88.tar.gz |
org-test, test-org-element, test-org, test-ox, test-property-inheritance
* org-test.el:
Fix org-test-with-temp-text-in-file. Make it work with <point>, as
some tests already expect it to do! Also make it fail more gracefully
by still removing temporary buffers and files.
Improve org-test-in-example-file. Make it behave similar to
org-test-with-temp-text and org-test-with-temp-text-in-file, in that
it will return the last evaluated expression.
* testing/lisp/test-org-element.el
Fix a temp-text strings so that it doesn't have an initial newline.
* testing/lisp/test-org.el
Minor cleanup to align code-structure with other tests. Nothing
changes in the test execpt style.
* testing/lisp/test-ox.el
Fix a couple of temp-text strings so that they don't have initial
newlines.
** test-org-export/expand-include
Test specification was wrong, due to org-test-with-temp-text-in-file
not previously working with <point>. Since that is fixed in this
patch the test needed to be updated to match the expected outcome.
* testing/lisp/test-property-inheritance.el
Fix wrong file-header and file-ending.
-rw-r--r-- | testing/lisp/test-org-element.el | 4 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 12 | ||||
-rw-r--r-- | testing/lisp/test-ox.el | 30 | ||||
-rw-r--r-- | testing/lisp/test-property-inheritance.el | 4 | ||||
-rw-r--r-- | testing/org-test.el | 44 |
5 files changed, 53 insertions, 41 deletions
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 04f97f9..f2ab380 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -3264,8 +3264,8 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu (ert-deftest test-org-element/granularity () "Test granularity impact on buffer parsing." - (org-test-with-temp-text " -* Head 1 + (org-test-with-temp-text + "* Head 1 ** Head 2 #+BEGIN_CENTER Centered paragraph. diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index abc0046..d671b5c 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -5060,18 +5060,18 @@ Paragraph<point>" (should (equal "1" - (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:END:\n** <point>H2" - (org-entry-get (point) "A" t)))) + (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:END:\n** H2" + (org-entry-get (point-max) "A" t)))) (should (equal "1" - (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:END:\n** <point>H2" + (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:END:\n** H2" (let ((org-use-property-inheritance t)) - (org-entry-get (point) "A" 'selective))))) + (org-entry-get (point-max) "A" 'selective))))) (should-not - (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:END:\n** <point>H2" + (org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:END:\n** H2" (let ((org-use-property-inheritance nil)) - (org-entry-get (point) "A" 'selective)))) + (org-entry-get (point-max) "A" 'selective)))) (should (equal "1 2" diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 2c2778f..b8c507e 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -1352,7 +1352,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote] org-test-dir) (narrow-to-region (point) (point-max)) (org-export-expand-include-keyword) - (eq 1 (org-current-level)))) + (eq 2 (org-current-level)))) ;; If :minlevel is present do not alter it. (should (org-test-with-temp-text @@ -2003,8 +2003,8 @@ In particular, structure of the document mustn't be altered after comments removal." (should (equal "Para1\n\nPara2\n" - (org-test-with-temp-text " -Para1 + (org-test-with-temp-text + "Para1 # Comment # Comment @@ -2012,15 +2012,15 @@ Para2" (org-export-as (org-test-default-backend))))) (should (equal "Para1\n\nPara2\n" - (org-test-with-temp-text " -Para1 + (org-test-with-temp-text + "Para1 # Comment Para2" (org-export-as (org-test-default-backend))))) (should (equal "[fn:1] Para1\n\n\nPara2\n" - (org-test-with-temp-text " -\[fn:1] Para1 + (org-test-with-temp-text + "[fn:1] Para1 # Inside definition @@ -2029,8 +2029,8 @@ Para2" (org-export-as (org-test-default-backend))))) (should (equal "[fn:1] Para1\n\nPara2\n" - (org-test-with-temp-text " -\[fn:1] Para1 + (org-test-with-temp-text + "[fn:1] Para1 # Inside definition @@ -2040,24 +2040,24 @@ Para2" (org-export-as (org-test-default-backend))))) (should (equal "[fn:1] Para1\n\nPara2\n" - (org-test-with-temp-text " -\[fn:1] Para1 + (org-test-with-temp-text + "[fn:1] Para1 # Inside definition Para2" (org-export-as (org-test-default-backend))))) (should (equal "[fn:1] Para1\n\nPara2\n" - (org-test-with-temp-text " -\[fn:1] Para1 + (org-test-with-temp-text + "[fn:1] Para1 # Inside definition Para2" (org-export-as (org-test-default-backend))))) (should (equal "- item 1\n\n- item 2\n" - (org-test-with-temp-text " -- item 1 + (org-test-with-temp-text + "- item 1 # Comment diff --git a/testing/lisp/test-property-inheritance.el b/testing/lisp/test-property-inheritance.el index 0f803e5..1d0dcfb 100644 --- a/testing/lisp/test-property-inheritance.el +++ b/testing/lisp/test-property-inheritance.el @@ -1,4 +1,4 @@ -;;; test-ob-R.el --- tests for ob-R.el +;;; test-property-inheritance.el --- tests for property-inheritance.el ;; Copyright (c) 2011-2014, 2019 Eric Schulte ;; Authors: Eric Schulte @@ -47,4 +47,4 @@ (provide 'test-ob-R) -;;; test-ob-R.el ends here +;;; test-property-inheritance.el ends here diff --git a/testing/org-test.el b/testing/org-test.el index 39c3464..295df19 100644 --- a/testing/org-test.el +++ b/testing/org-test.el @@ -146,7 +146,8 @@ currently executed.") (declare (indent 1)) `(let* ((my-file (or ,file org-test-file)) (visited-p (get-file-buffer my-file)) - to-be-removed) + to-be-removed + results) (save-window-excursion (save-match-data (find-file my-file) @@ -160,9 +161,10 @@ currently executed.") (org-show-subtree) (org-show-all '(blocks))) (error nil)) - (save-restriction ,@body))) + (setq results (save-restriction ,@body)))) (unless visited-p - (kill-buffer to-be-removed)))) + (kill-buffer to-be-removed)) + results)) (def-edebug-spec org-test-in-example-file (form body)) (defmacro org-test-at-marker (file marker &rest body) @@ -198,20 +200,30 @@ otherwise place the point at the beginning of the inserted text." (def-edebug-spec org-test-with-temp-text (form body)) (defmacro org-test-with-temp-text-in-file (text &rest body) - "Run body in a temporary file buffer with Org mode as the active mode." + "Run body in a temporary file buffer with Org mode as the active mode. +If the string \"<point>\" appears in TEXT then remove it and +place the point there before running BODY, otherwise place the +point at the beginning of the buffer." (declare (indent 1)) - (let ((results (cl-gensym))) - `(let ((file (make-temp-file "org-test")) - (kill-buffer-query-functions nil) - (inside-text (if (stringp ,text) ,text (eval ,text))) - ,results) - (with-temp-file file (insert inside-text)) - (find-file file) - (org-mode) - (setq ,results (progn ,@body)) - (save-buffer) (kill-buffer (current-buffer)) - (delete-file file) - ,results))) + `(let ((file (make-temp-file "org-test")) + (inside-text (if (stringp ,text) ,text (eval ,text))) + buffer) + (with-temp-file file (insert inside-text)) + (unwind-protect + (progn + (setq buffer (find-file file)) + (when (re-search-forward "<point>" nil t) + (replace-match "")) + (org-mode) + (progn ,@body)) + (let ((kill-buffer-query-functions nil)) + (when buffer + (set-buffer buffer) + ;; Ignore changes, we're deleting the file in the next step + ;; anyways. + (set-buffer-modified-p nil) + (kill-buffer)) + (delete-file file))))) (def-edebug-spec org-test-with-temp-text-in-file (form body)) (defun org-test-table-target-expect (target &optional expect laps |