emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH] Replace `org-ctrl-c-ctrl-c' by `org-babel-execute-maybe' in


From: Sebastien Vauban
Subject: [O] [PATCH] Replace `org-ctrl-c-ctrl-c' by `org-babel-execute-maybe' in tests
Date: Mon, 29 Dec 2014 17:06:47 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (windows-nt)


Nicolas Goaziou wrote:
> Sebastien Vauban writes:
>
>> Or even more sense: calling `org-babel-execute-maybe' instead?
>
> I think it would be better, yes. There is no point in testing
> `org-ctrl-c-ctrl-c' in "test-ob.el".

Here's a patch doing so.

Best regards,
  Seb

Subject: [PATCH] Replace `org-ctrl-c-ctrl-c' by `org-babel-execute-maybe' in 
tests

        * test-ob-emacs-lisp.el, test-ob-ruby.el, test-ob.el: Use
          `org-babel-execute-maybe' instead of `org-ctrl-c-ctrl-c'.
---
 testing/lisp/test-ob-emacs-lisp.el | 10 ++---
 testing/lisp/test-ob-ruby.el       |  8 ++--
 testing/lisp/test-ob.el            | 88 +++++++++++++++++++-------------------
 3 files changed, 53 insertions(+), 53 deletions(-)

diff --git a/testing/lisp/test-ob-emacs-lisp.el 
b/testing/lisp/test-ob-emacs-lisp.el
index f771ee3..bb3f51b 100644
--- a/testing/lisp/test-ob-emacs-lisp.el
+++ b/testing/lisp/test-ob-emacs-lisp.el
@@ -1,6 +1,6 @@
 ;;; test-ob-emacs-lisp.el
 
-;; Copyright (c) 2012, 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (c) 2012-2014 Free Software Foundation, Inc.
 ;; Authors: Eric Schulte, Martyn Jago
 
 ;; This file is not part of GNU Emacs.
@@ -29,7 +29,7 @@
 ;;
 #+end_src"
     (org-babel-next-src-block)
-    (org-ctrl-c-ctrl-c)
+    (org-babel-execute-maybe)
     (should (re-search-forward "results:" nil t))
     (forward-line)
     (should
@@ -42,7 +42,7 @@
 #+end_src"
 
     (org-babel-next-src-block)
-    (org-ctrl-c-ctrl-c)
+    (org-babel-execute-maybe)
     (should (re-search-forward "results:" nil t))
     (forward-line)
     (should
@@ -56,7 +56,7 @@
 ;;
 #+end_src"
     (org-babel-next-src-block)
-    (org-ctrl-c-ctrl-c)
+    (org-babel-execute-maybe)
     (re-search-forward "results" nil t)
     (forward-line)
     (should (string=
@@ -69,7 +69,7 @@
 2;;
 #+end_src"
     (org-babel-next-src-block)
-    (org-ctrl-c-ctrl-c)
+    (org-babel-execute-maybe)
     (re-search-forward "results" nil t)
     (forward-line)
     (should (string=
diff --git a/testing/lisp/test-ob-ruby.el b/testing/lisp/test-ob-ruby.el
index ee7e837..28c06a4 100644
--- a/testing/lisp/test-ob-ruby.el
+++ b/testing/lisp/test-ob-ruby.el
@@ -1,6 +1,6 @@
 ;;; test-ob-ruby.el --- tests for ob-ruby.el
 
-;; Copyright (c) 2013 Oleh Krehel
+;; Copyright (c) 2013-2014 Oleh Krehel
 ;; Authors: Oleh Krehel
 
 ;; This program is free software; you can redistribute it and/or modify
@@ -28,7 +28,7 @@ s = \"2\"
 s = \"3\"
 puts s
 #+end_src"
-  (org-ctrl-c-ctrl-c)
+  (org-babel-execute-maybe)
   (substring-no-properties
    (buffer-string)))
                   "#+begin_src ruby :session :results output
@@ -47,7 +47,7 @@ puts s
 s = \"5\"
 puts s
 #+end_src"
-  (org-ctrl-c-ctrl-c)
+  (org-babel-execute-maybe)
   (substring-no-properties
    (buffer-string)))
                   "#+begin_src ruby :session :results output
@@ -63,7 +63,7 @@ puts s
     (should (equal (org-test-with-temp-text "#+begin_src ruby :session 
:results output
 puts s
 #+end_src"
-  (org-ctrl-c-ctrl-c)
+  (org-babel-execute-maybe)
   (substring-no-properties
    (buffer-string)))
                   "#+begin_src ruby :session :results output
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index efde99a..5b75e23 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -269,7 +269,7 @@ this is simple"
 
 (ert-deftest test-org-babel/org-babel-get-inline-src-block-matches ()
   (flet ((test-at-id (id)
-          (org-test-at-id 
+          (org-test-at-id
            id
            (let ((test-point (point)))
              (should (fboundp 'org-babel-get-inline-src-block-matches))
@@ -298,18 +298,18 @@ this is simple"
     ;; src_ at bol line 1...
     (org-test-with-temp-text
        test-line
-      (goto-char (point-min)) (org-ctrl-c-ctrl-c)
+      (goto-char (point-min)) (org-babel-execute-maybe)
       (should (string=
                       (concat test-line " =1=")
                       (buffer-substring-no-properties (point-at-bol) 
(point-at-eol))))
-      (forward-char) (org-ctrl-c-ctrl-c)
+      (forward-char) (org-babel-execute-maybe)
       (should (string=
                       (concat test-line " =1= =1=")
                       (buffer-substring-no-properties (point-at-bol) 
(point-at-eol))))
       (re-search-forward "1}")
-      (should-error (org-ctrl-c-ctrl-c))
+      (should-error (org-babel-execute-maybe))
       (backward-char) ;; last char of block body
-      (org-ctrl-c-ctrl-c)
+      (org-babel-execute-maybe)
       (should (string=
                       (concat test-line " =1= =1= =1=")
                       (buffer-substring-no-properties (point-at-bol) 
(point-at-eol)))))
@@ -317,29 +317,29 @@ this is simple"
     (let ((test-line " src_emacs-lisp{ 1 }"))
       (org-test-with-temp-text
          test-line
-       (should-error (org-ctrl-c-ctrl-c))
-       (forward-char) (org-ctrl-c-ctrl-c)
+       (should-error (org-babel-execute-maybe))
+       (forward-char) (org-babel-execute-maybe)
        (should (string=
                 (concat test-line " =1=")
                 (buffer-substring-no-properties (point-at-bol) 
(point-at-eol))))
-       (re-search-forward "{ 1 ") (org-ctrl-c-ctrl-c)
+       (re-search-forward "{ 1 ") (org-babel-execute-maybe)
        (should (string=
                 (concat test-line " =1= =1=")
                 (buffer-substring-no-properties (point-at-bol) 
(point-at-eol))))
        (forward-char)
-       (should-error (org-ctrl-c-ctrl-c))))))
+       (should-error (org-babel-execute-maybe))))))
 
 (ert-deftest test-org-babel/inline-src_blk-default-results-replace-line-2 ()
   ;; src_ at bol line 2...
   (let ((test-line " src_emacs-lisp{ \"x\" }"))
     (org-test-with-temp-text
        (concat "\n" test-line)
-      (should-error (org-ctrl-c-ctrl-c))
+      (should-error (org-babel-execute-maybe))
       (goto-char (point-min))
-      (should-error (org-ctrl-c-ctrl-c))
+      (should-error (org-babel-execute-maybe))
       (forward-line)
-      (should-error (org-ctrl-c-ctrl-c))
-      (forward-char) (org-ctrl-c-ctrl-c)
+      (should-error (org-babel-execute-maybe))
+      (forward-char) (org-babel-execute-maybe)
       (should (string=
               (concat test-line " =x=")
               (buffer-substring-no-properties
@@ -350,27 +350,27 @@ this is simple"
        test-line
       (goto-char (point-max))
       (insert (concat "\n" test-line " end"))
-      (re-search-backward "src") (org-ctrl-c-ctrl-c)
+      (re-search-backward "src") (org-babel-execute-maybe)
       (should (string=
               (concat test-line " =y= end")
               (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
-      (re-search-forward "\" ") (org-ctrl-c-ctrl-c)
+      (re-search-forward "\" ") (org-babel-execute-maybe)
       (should (string=
               (concat test-line " =y= =y= end")
               (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
       (forward-char)
-      (should-error (org-ctrl-c-ctrl-c)))))
+      (should-error (org-babel-execute-maybe)))))
 
 (ert-deftest test-org-babel/inline-src_blk-manual-results-replace ()
   (let ((test-line " src_emacs-lisp[:results replace]{ \"x\" }"))
     (org-test-with-temp-text
        (concat "\n" test-line)
-      (should-error (org-ctrl-c-ctrl-c))
+      (should-error (org-babel-execute-maybe))
       (goto-char (point-max))
-      (should-error (org-ctrl-c-ctrl-c))
+      (should-error (org-babel-execute-maybe))
       (beginning-of-line)
-      (should-error (org-ctrl-c-ctrl-c))
-      (forward-char) (org-ctrl-c-ctrl-c)
+      (should-error (org-babel-execute-maybe))
+      (forward-char) (org-babel-execute-maybe)
       (should (string=
               (concat test-line " =x=")
               (buffer-substring-no-properties
@@ -381,68 +381,68 @@ this is simple"
     (org-test-with-temp-text test-line
       (goto-char (point-max))
       (insert (concat "\n" test-line " end"))
-      (re-search-backward "src") (org-ctrl-c-ctrl-c)
+      (re-search-backward "src") (org-babel-execute-maybe)
       (should (string=
               (concat test-line " =y= end")
               (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
-      (re-search-forward "\" ") (org-ctrl-c-ctrl-c)
+      (re-search-forward "\" ") (org-babel-execute-maybe)
       (should (string=
               (concat test-line " =y= =y= end")
               (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
       (forward-char)
-      (should-error (org-ctrl-c-ctrl-c)))))
+      (should-error (org-babel-execute-maybe)))))
 
 (ert-deftest test-org-babel/inline-src_blk-results-silent ()
   (let ((test-line "src_emacs-lisp[ :results silent ]{ \"x\" }"))
     (org-test-with-temp-text test-line
-      (org-ctrl-c-ctrl-c)
+      (org-babel-execute-maybe)
       (should (string= test-line
                       (buffer-substring-no-properties
                        (point-at-bol) (point-at-eol))))
       (end-of-buffer)
-      (should-error (org-ctrl-c-ctrl-c))))
+      (should-error (org-babel-execute-maybe))))
   (let ((test-line (concat " Some text prior to block src_emacs-lisp"
                           "[ :results silent ]{ \"y\" }")))
     (org-test-with-temp-text
        test-line
       (goto-char (point-max))
       (insert (concat "\n" test-line " end"))
-      (re-search-backward "src_") (org-ctrl-c-ctrl-c)
+      (re-search-backward "src_") (org-babel-execute-maybe)
       (should (string= (concat test-line " end")
                       (buffer-substring-no-properties
                        (point-at-bol) (point-at-eol))))
-      (re-search-forward "\" ") (org-ctrl-c-ctrl-c)
+      (re-search-forward "\" ") (org-babel-execute-maybe)
       (should (string= (concat test-line " end")
                       (buffer-substring-no-properties
                        (point-at-bol) (point-at-eol))))
       (forward-char)
-      (should-error (org-ctrl-c-ctrl-c)))))
+      (should-error (org-babel-execute-maybe)))))
 
 (ert-deftest test-org-babel/inline-src_blk-results-raw ()
   (let ((test-line "src_emacs-lisp[ :results raw ]{ \"x\" }"))
     (org-test-with-temp-text test-line
-      (org-ctrl-c-ctrl-c)
+      (org-babel-execute-maybe)
       (should (string= (concat test-line " x")
                       (buffer-string)))))
   (let ((test-line (concat " Some text prior to block "
                           "src_emacs-lisp[ :results raw ]{ \"the\" }")))
     (org-test-with-temp-text (concat test-line " end")
-      (re-search-forward "src_") (org-ctrl-c-ctrl-c)
+      (re-search-forward "src_") (org-babel-execute-maybe)
       (should (string= (concat test-line " the end")
                       (buffer-substring-no-properties
                        (point-at-bol) (point-at-eol))))
-      (re-search-forward "\" ") (org-ctrl-c-ctrl-c)
+      (re-search-forward "\" ") (org-babel-execute-maybe)
       (should (string= (concat test-line " the the end")
                       (buffer-substring-no-properties
                        (point-at-bol) (point-at-eol))))
       (forward-char)
-      (should-error (org-ctrl-c-ctrl-c)))))
+      (should-error (org-babel-execute-maybe)))))
 
 (ert-deftest test-org-babel/inline-src_blk-results-file ()
   (let ((test-line "src_emacs-lisp[ :results file ]{ \"~/test-file\"  }"))
     (org-test-with-temp-text
        test-line
-      (org-ctrl-c-ctrl-c)
+      (org-babel-execute-maybe)
       (should (string= (concat test-line " [[file:~/test-file]]")
                       (buffer-substring-no-properties
                        (point-min) (point-max)))))))
@@ -451,7 +451,7 @@ this is simple"
   (let ((test-line "src_emacs-lisp[ :results scalar ]{ \"x\"  }"))
     (org-test-with-temp-text
        test-line
-      (org-ctrl-c-ctrl-c)
+      (org-babel-execute-maybe)
       (should (string= (concat test-line  " =\"x\"=")
                       (buffer-substring-no-properties
                        (point-min) (point-max)))))))
@@ -460,7 +460,7 @@ this is simple"
   (let ((test-line "src_emacs-lisp[ :results verbatim ]{ \"x\"  }"))
     (org-test-with-temp-text
        test-line
-      (org-ctrl-c-ctrl-c)
+      (org-babel-execute-maybe)
       (should (string= (concat test-line " =\"x\"=")
                       (buffer-substring-no-properties
                        (point-min) (point-max)))))))
@@ -710,7 +710,7 @@ on two lines
 ;;
 #+end_src"
     (org-babel-next-src-block)
-    (org-ctrl-c-ctrl-c)
+    (org-babel-execute-maybe)
     (should (re-search-forward "\\#\\+results:" nil t))
     (forward-line)
     (should
@@ -722,7 +722,7 @@ on two lines
 \"some text\";;
 #+end_src"
     (org-babel-next-src-block)
-    (org-ctrl-c-ctrl-c)
+    (org-babel-execute-maybe)
     (should (re-search-forward "\\#\\+results:" nil t))
     (forward-line)
     (should
@@ -736,7 +736,7 @@ on two lines
 ;;
 #+end_src"
     (org-babel-next-src-block)
-    (org-ctrl-c-ctrl-c)
+    (org-babel-execute-maybe)
     (re-search-forward "\\#\\+results:" nil t)
     (forward-line)
     (should (string=
@@ -747,7 +747,7 @@ on two lines
 2;;
 #+end_src"
     (org-babel-next-src-block)
-    (org-ctrl-c-ctrl-c)
+    (org-babel-execute-maybe)
     (re-search-forward "\\#\\+results:" nil t)
     (forward-line)
     (should (string=
@@ -763,7 +763,7 @@ The block is actually executed /twice/ to ensure result
 replacement happens correctly."
   (org-test-with-temp-text
       buffer-text
-    (org-babel-next-src-block) (org-ctrl-c-ctrl-c) (org-ctrl-c-ctrl-c)
+    (org-babel-next-src-block) (org-babel-execute-maybe) 
(org-babel-execute-maybe)
     (should (re-search-forward "\\#\\+results:" nil t))
     (forward-line)
     (should (string= result
@@ -849,7 +849,7 @@ trying to find the :END: marker."
     (org-test-with-temp-text
        test-line
       (forward-char 1)
-      (org-ctrl-c-ctrl-c)
+      (org-babel-execute-maybe)
       (should (re-search-forward "=\"x\"=" nil t))
       (forward-line))))
 
@@ -859,7 +859,7 @@ trying to find the :END: marker."
 ;;
 #+end_src"
     (org-babel-next-src-block)
-    (org-ctrl-c-ctrl-c)
+    (org-babel-execute-maybe)
     (re-search-forward "\\#\\+results:" nil t)
     (forward-line)
     (should (string=
@@ -870,7 +870,7 @@ trying to find the :END: marker."
 2;;
 #+end_src"
     (org-babel-next-src-block)
-    (org-ctrl-c-ctrl-c)
+    (org-babel-execute-maybe)
     (re-search-forward "\\#\\+results:" nil t)
     (forward-line)
     (should (string=
@@ -886,7 +886,7 @@ The block is actually executed /twice/ to ensure result
 replacement happens correctly."
   (org-test-with-temp-text
       buffer-text
-    (org-babel-next-src-block) (org-ctrl-c-ctrl-c) (org-ctrl-c-ctrl-c)
+    (org-babel-next-src-block) (org-babel-execute-maybe) 
(org-babel-execute-maybe)
     (should (re-search-forward "\\#\\+results:" nil t))
     (forward-line)
     (should (string= result
-- 
2.1.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]