Browse Source

Fix some tests when run interactively

* testing/lisp/test-ob.el (test-org-babel/nested-code-block,
  test-ob/blocks-with-spaces, test-ob/results-in-narrowed-buffer,
  test-ob/specific-colnames):
* testing/lisp/test-org-clock.el (test-org-clock/clocktable):
* testing/lisp/test-org-element.el (test-org-element/src-block-interpreter):
* testing/lisp/test-org-src.el (test-org-src/basic,
  test-org-src/empty-block, test-org-src/blank-line-block): Ensure
  default values are used for defcustoms.
Nicolas Goaziou 10 years ago
parent
commit
ae11759d41

+ 18 - 9
testing/lisp/test-ob.el

@@ -515,13 +515,16 @@ duplicate results block."
 
 (ert-deftest test-org-babel/nested-code-block ()
   "Test nested code blocks inside code blocks don't cause problems."
-  (org-test-with-temp-text "#+begin_src org :results silent
+  (should
+   (string= "#+begin_src emacs-lisp\n  'foo\n#+end_src"
+	    (org-test-with-temp-text "#+begin_src org :results silent
   ,#+begin_src emacs-lisp
   ,  'foo
   ,#+end_src
 #+end_src"
-    (should (string= (org-babel-execute-src-block)
-		     "#+begin_src emacs-lisp\n  'foo\n#+end_src"))))
+	      (let ((org-edit-src-content-indentation 2)
+		    (org-src-preserve-indentation nil))
+		(org-babel-execute-src-block))))))
 
 (ert-deftest test-org-babel/partial-nested-code-block ()
   "Test nested code blocks inside code blocks don't cause problems."
@@ -1057,7 +1060,8 @@ Line 3\"
 	  (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp
 \(+ 1 2)
 #+END_SRC\n\n\n"
-	    (org-babel-execute-src-block)
+	    (let ((org-babel-next-src-block "RESULTS"))
+	      (org-babel-execute-src-block))
 	    (buffer-string)))))
 
 (ert-deftest test-ob/results-in-narrowed-buffer ()
@@ -1070,7 +1074,8 @@ Line 3\"
     (org-test-with-temp-text
 	"#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\nParagraph"
       (narrow-to-region (point) (save-excursion (forward-line 3) (point)))
-      (org-babel-execute-src-block)
+      (let ((org-babel-results-keyword "RESULTS"))
+	(org-babel-execute-src-block))
       (org-trim (buffer-string)))))
   (should
    (equal
@@ -1078,7 +1083,8 @@ Line 3\"
     (org-test-with-temp-text
 	"#+NAME: test\n#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\nParagraph"
       (narrow-to-region (point) (save-excursion (forward-line 4) (point)))
-      (org-babel-execute-src-block)
+      (let ((org-babel-results-keyword "RESULTS"))
+	(org-babel-execute-src-block))
       (org-trim (buffer-string)))))
   ;; Results in visible part of buffer, should be updated here.
   (should
@@ -1101,7 +1107,8 @@ Line 3\"
 
 Paragraph"
       (narrow-to-region (point) (save-excursion (forward-line 7) (point)))
-      (org-babel-execute-src-block)
+      (let ((org-babel-results-keyword "RESULTS"))
+	(org-babel-execute-src-block))
       (org-trim (buffer-string)))))
   ;; Results in invisible part of buffer, should be updated there.
   (org-test-with-temp-text
@@ -1115,7 +1122,8 @@ Paragraph"
 
 Paragraph"
     (narrow-to-region (point) (save-excursion (forward-line 4) (point)))
-    (org-babel-execute-src-block)
+    (let ((org-babel-results-keyword "RESULTS"))
+      (org-babel-execute-src-block))
     (should-not (re-search-forward "^#\\+RESULTS:" nil t))
     (widen)
     (should (should (re-search-forward "^: 3" nil t)))))
@@ -1155,7 +1163,8 @@ echo \"$data\"
 	    (should (re-search-forward org-babel-src-block-regexp nil t))
 	    (goto-char (match-beginning 0))
 	    ;; now that we've located the code block, it may be evaluated
-	    (org-babel-execute-src-block)
+	    (let ((org-babel-execute-src-block "RESULTS"))
+	      (org-babel-execute-src-block))
 	    (buffer-string)))))
 
 (ert-deftest test-ob/location-of-header-arg-eval ()

+ 1 - 1
testing/lisp/test-org-clock.el

@@ -98,7 +98,7 @@ contents.  The clocktable doesn't appear in the buffer."
 | Bar                          |         | 11:00 |
 "
     (org-test-with-temp-text "* Relative times in clocktable\n** Foo\n** Bar\n"
-      (progn
+      (let ((org-clock-total-time-cell-format "*%s*"))
 	;; Install Clock lines in "Foo".
 	(search-forward "** Foo")
 	(forward-line)

+ 8 - 4
testing/lisp/test-org-element.el

@@ -2572,19 +2572,22 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu
   "Test src block interpreter."
   ;; With arguments.
   (should
-   (equal (let ((org-edit-src-content-indentation 2))
+   (equal (let ((org-edit-src-content-indentation 2)
+		(org-src-preserve-indentation nil))
 	    (org-test-parse-and-interpret
 	     "#+BEGIN_SRC emacs-lisp :results silent\n(+ 1 1)\n#+END_SRC"))
 	  "#+BEGIN_SRC emacs-lisp :results silent\n  (+ 1 1)\n#+END_SRC\n"))
   ;; With switches.
   (should
-   (equal (let ((org-edit-src-content-indentation 2))
+   (equal (let ((org-edit-src-content-indentation 2)
+		(org-src-preserve-indentation nil))
 	    (org-test-parse-and-interpret
 	     "#+BEGIN_SRC emacs-lisp -n -k\n(+ 1 1)\n#+END_SRC"))
 	  "#+BEGIN_SRC emacs-lisp -n -k\n  (+ 1 1)\n#+END_SRC\n"))
   ;; Preserve code escaping.
   (should
-   (equal (let ((org-edit-src-content-indentation 2))
+   (equal (let ((org-edit-src-content-indentation 2)
+		(org-src-preserve-indentation nil))
 	    (org-test-parse-and-interpret
 	     "#+BEGIN_SRC org\n,* Headline\n ,#+keyword\nText #+END_SRC"))
 	  "#+BEGIN_SRC org\n,* Headline\n ,#+keyword\nText #+END_SRC\n"))
@@ -2606,7 +2609,8 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu
   (should
    (equal
     "#+BEGIN_SRC emacs-lisp\n  Test\n#+END_SRC\n"
-    (let ((org-edit-src-content-indentation 2))
+    (let ((org-edit-src-content-indentation 2)
+	  (org-src-preserve-indentation nil))
       (org-element-interpret-data
        '(src-block (:language "emacs-lisp" :value "Test")))))))
 

+ 25 - 22
testing/lisp/test-org-src.el

@@ -26,26 +26,25 @@
 
 
 (ert-deftest test-org-src/basic ()
-  "Editing regular block works. with point on
-
-#+begin_src line
-"
+  "Editing regular block works, with point on source block."
   (org-test-with-temp-text
       "
 #+begin_src emacs-lisp
   (message hello)
 #+end_src
 "
-    (goto-line 2)
-    (org-edit-special)
-    (insert "blah")
-    (org-edit-src-exit)
-    (should (equal (buffer-string) "
+    (let ((org-edit-src-content-indentation 2)
+	  (org-src-preserve-indentation nil))
+      (goto-line 2)
+      (org-edit-special)
+      (insert "blah")
+      (org-edit-src-exit)
+      (should (equal (buffer-string) "
 #+begin_src emacs-lisp
   blah(message hello)
 #+end_src
 "))
-    (should (equal (word-at-point) "blah"))))
+      (should (equal (word-at-point) "blah")))))
 
 (ert-deftest test-org-src/point-outside-block ()
   "Editing with point before/after block signals expected error."
@@ -67,16 +66,18 @@
 #+begin_src emacs-lisp
 #+end_src
 "
-    (goto-line 2)
-    (org-edit-special)
-    (insert "blah")
-    (org-edit-src-exit)
-    (should (equal (buffer-string) "
+    (let ((org-edit-src-content-indentation 2)
+	  (org-src-preserve-indentation nil))
+      (goto-line 2)
+      (org-edit-special)
+      (insert "blah")
+      (org-edit-src-exit)
+      (should (equal (buffer-string) "
 #+begin_src emacs-lisp
   blah
 #+end_src
 "))
-    (should (equal (word-at-point) "blah"))))
+      (should (equal (word-at-point) "blah")))))
 
 (ert-deftest test-org-src/blank-line-block ()
   "Editing block with just a blank line."
@@ -86,15 +87,17 @@
 
 #+end_src
 "
-    (goto-line 2)
-    (org-edit-special)
-    (insert "blah")
-    (org-edit-src-exit)
-    (should (equal (buffer-string) "
+    (let ((org-edit-src-content-indentation 2)
+	  (org-src-preserve-indentation nil))
+      (goto-line 2)
+      (org-edit-special)
+      (insert "blah")
+      (org-edit-src-exit)
+      (should (equal (buffer-string) "
 #+begin_src emacs-lisp
   blah
 #+end_src
-"))))
+")))))
 
 (provide 'test-org-src)
 ;;; test-org-src.el ends here