emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] migrate ob-clojure initiate session code from ob-clojure-literate.el into ob-clojure.el
@ 2018-04-19 10:22 stardiviner
  2018-04-20  8:59 ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: stardiviner @ 2018-04-19 10:22 UTC (permalink / raw)
  To: org-mode


[-- Attachment #1.1: Type: text/plain, Size: 38 bytes --]

Those code belongs to ob-clojure.el.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-ob-clojure.el-support-org-babel-initiate-session-to-.patch --]
[-- Type: text/x-patch, Size: 5869 bytes --]

From 7306147a55ea29be7a685cd7a92dc158612dfccd Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Thu, 19 Apr 2018 18:16:27 +0800
Subject: [PATCH] * ob-clojure.el: support `org-babel-initiate-session' to
 initialize.

Migrate from ob-clojure-literate.el into ob-clojure.el.
---
 contrib/lisp/ob-clojure-literate.el | 56 -----------------------------
 lisp/ob-clojure.el                  | 55 ++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 56 deletions(-)

diff --git a/contrib/lisp/ob-clojure-literate.el b/contrib/lisp/ob-clojure-literate.el
index e702582d9..ecf786df7 100644
--- a/contrib/lisp/ob-clojure-literate.el
+++ b/contrib/lisp/ob-clojure-literate.el
@@ -185,62 +185,6 @@ If it is a directory, `ob-clojure-literate' will try to create Clojure project a
                  org-babel-default-header-args:clojure)))
     ))
 
-;;; Support `org-babel-initiate-session' / [C-c C-v z] to initialize Clojure session.
-
-(defun org-babel-clojure-initiate-session (&optional session _params)
-  "Initiate a session named SESSION according to PARAMS."
-  (when (and session (not (string= session "none")))
-    (save-window-excursion
-      (unless (org-babel-comint-buffer-livep session)
-        ;; CIDER jack-in to the Clojure project directory.
-        (cond
-         ((eq org-babel-clojure-backend 'cider)
-          (require 'cider)
-          (let ((session-buffer (save-window-excursion
-                                  (cider-jack-in t)
-                                  (current-buffer))))
-            (if (org-babel-comint-buffer-livep session-buffer)
-                (progn (sit-for .25) session-buffer))))
-         ((eq org-babel-clojure-backend 'slime)
-          (error "Session evaluation with SLIME is not supported"))
-         (t
-          (error "Session initiate failed")))
-        )
-      (get-buffer session)
-      )))
-
-(defun org-babel-prep-session:clojure (session params)
-  "Prepare SESSION according to the header arguments specified in PARAMS."
-  (let* ((session (org-babel-clojure-initiate-session session))
-         (var-lines (org-babel-variable-assignments:clojure params)))
-    (when session
-      (org-babel-comint-in-buffer session
-        (mapc (lambda (var)
-                (insert var) (comint-send-input nil t)
-		(org-babel-comint-wait-for-output session)
-		(sit-for .1) (goto-char (point-max))) var-lines)))
-    session))
-
-(defun org-babel-clojure-var-to-clojure (var)
-  "Convert src block's `VAR' to Clojure variable."
-  (if (listp var)
-      (replace-regexp-in-string "(" "'(" var)
-    (cond
-     ((stringp var)
-      ;; wrap org-babel passed in header argument value with quote in Clojure.
-      (format "\"%s\"" var))
-     (t
-      (format "%s" var))))
-  )
-
-(defun org-babel-variable-assignments:clojure (params)
-  "Return a list of Clojure statements assigning the block's variables in `PARAMS'."
-  (mapcar
-   (lambda (pair)
-     (format "(def %s %s)"
-             (car pair)
-             (org-babel-clojure-var-to-clojure (cdr pair))))
-   (org-babel--get-vars params)))
 
 ;;; Support header arguments  :results graphics :file "image.png" by inject Clojure code.
 (defun ob-clojure-literate-inject-code (args)
diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index 93674b552..f647a3282 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -211,6 +211,61 @@ using the :show-process parameter."
       (condition-case nil (org-babel-script-escape result)
 	(error result)))))
 
+(defun org-babel-clojure-initiate-session (&optional session _params)
+  "Initiate a session named SESSION according to PARAMS."
+  (when (and session (not (string= session "none")))
+    (save-window-excursion
+      (unless (org-babel-comint-buffer-livep session)
+        ;; CIDER jack-in to the Clojure project directory.
+        (cond
+         ((eq org-babel-clojure-backend 'cider)
+          (require 'cider)
+          (let ((session-buffer (save-window-excursion
+                                  (cider-jack-in t)
+                                  (current-buffer))))
+            (if (org-babel-comint-buffer-livep session-buffer)
+                (progn (sit-for .25) session-buffer))))
+         ((eq org-babel-clojure-backend 'slime)
+          (error "Session evaluation with SLIME is not supported"))
+         (t
+          (error "Session initiate failed")))
+        )
+      (get-buffer session)
+      )))
+
+(defun org-babel-prep-session:clojure (session params)
+  "Prepare SESSION according to the header arguments specified in PARAMS."
+  (let* ((session (org-babel-clojure-initiate-session session))
+         (var-lines (org-babel-variable-assignments:clojure params)))
+    (when session
+      (org-babel-comint-in-buffer session
+        (mapc (lambda (var)
+                (insert var) (comint-send-input nil t)
+		(org-babel-comint-wait-for-output session)
+		(sit-for .1) (goto-char (point-max))) var-lines)))
+    session))
+
+(defun org-babel-clojure-var-to-clojure (var)
+  "Convert src block's `VAR' to Clojure variable."
+  (if (listp var)
+      (replace-regexp-in-string "(" "'(" var)
+    (cond
+     ((stringp var)
+      ;; wrap org-babel passed in header argument value with quote in Clojure.
+      (format "\"%s\"" var))
+     (t
+      (format "%s" var))))
+  )
+
+(defun org-babel-variable-assignments:clojure (params)
+  "Return a list of Clojure statements assigning the block's variables in `PARAMS'."
+  (mapcar
+   (lambda (pair)
+     (format "(def %s %s)"
+             (car pair)
+             (org-babel-clojure-var-to-clojure (cdr pair))))
+   (org-babel--get-vars params)))
+
 (provide 'ob-clojure)
 
 ;;; ob-clojure.el ends here
-- 
2.17.0


[-- Attachment #1.3: Type: text/plain, Size: 202 bytes --]


-- 
[ stardiviner ] don't need to convince with trends.
       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] migrate ob-clojure initiate session code from ob-clojure-literate.el into ob-clojure.el
  2018-04-19 10:22 [PATCH] migrate ob-clojure initiate session code from ob-clojure-literate.el into ob-clojure.el stardiviner
@ 2018-04-20  8:59 ` Nicolas Goaziou
  2018-10-23 12:02   ` stardiviner
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2018-04-20  8:59 UTC (permalink / raw)
  To: stardiviner; +Cc: org-mode

Hello,

stardiviner <numbchild@gmail.com> writes:

> Those code belongs to ob-clojure.el.

Thank you. Comments follow.

> From 7306147a55ea29be7a685cd7a92dc158612dfccd Mon Sep 17 00:00:00 2001
> From: stardiviner <numbchild@gmail.com>
> Date: Thu, 19 Apr 2018 18:16:27 +0800
> Subject: [PATCH] * ob-clojure.el: support `org-babel-initiate-session' to
>  initialize.

  ob-clojure.el: Support `org-babel-initiate-session' to initialize.

(no leading star, capitalization)

> Migrate from ob-clojure-literate.el into ob-clojure.el.

You need to expound the commit message. In particular, you need to
specify which functions are new, which are modified.

> +(defun org-babel-clojure-initiate-session (&optional session _params)
> +  "Initiate a session named SESSION according to PARAMS."
> +  (when (and session (not (string= session "none")))
> +    (save-window-excursion
> +      (unless (org-babel-comint-buffer-livep session)

You can merge the `unless' within the `cond', e.g.,

(cond
 ((org-babel-comint-buffer-livep session) nil)
 ...)

> +        ;; CIDER jack-in to the Clojure project directory.
> +        (cond
> +         ((eq org-babel-clojure-backend 'cider)
> +          (require 'cider)
> +          (let ((session-buffer (save-window-excursion
> +                                  (cider-jack-in t)
> +                                  (current-buffer))))
> +            (if (org-babel-comint-buffer-livep session-buffer)
> +                (progn (sit-for .25) session-buffer))))
> +         ((eq org-babel-clojure-backend 'slime)
> +          (error "Session evaluation with SLIME is not supported"))
> +         (t
> +          (error "Session initiate failed")))
> +        )
> +      (get-buffer session)
> +      )))

No dangling parens, please.

> +(defun org-babel-prep-session:clojure (session params)
> +  "Prepare SESSION according to the header arguments specified in PARAMS."
> +  (let* ((session (org-babel-clojure-initiate-session session))
> +         (var-lines (org-babel-variable-assignments:clojure params)))

No need for `let*'. `let' is sufficient.

> +    (when session
> +      (org-babel-comint-in-buffer session
> +        (mapc (lambda (var)
> +                (insert var) (comint-send-input nil t)
> +		(org-babel-comint-wait-for-output session)
> +		(sit-for .1) (goto-char (point-max))) var-lines)))
> +    session))

`mapc' + `lambda' -> `dolist', e.g:

    (defun org-babel-prep-session:clojure (session params)
      "Prepare SESSION according to the header arguments specified in PARAMS."
      (let ((session (org-babel-clojure-initiate-session session))
            (var-lines (org-babel-variable-assignments:clojure params)))
        (when session
          (org-babel-comint-in-buffer session
            (dolist (var var-lines)
              (insert var)
              (comint-send-input nil t)
              (org-babel-comint-wait-for-output session)
              (sit-for .1)
              (goto-char (point-max)))))
        session))

> +(defun org-babel-clojure-var-to-clojure (var)
> +  "Convert src block's `VAR' to Clojure variable."

VAR, not `VAR'

> +  (if (listp var)
> +      (replace-regexp-in-string "(" "'(" var)
> +    (cond

You can merge the THEN part of the `if' in the `cond'.

> +     ((stringp var)
> +      ;; wrap org-babel passed in header argument value with quote in Clojure.

;; Wrap Babel passed-in header argument value with quotes in Cojure.

> +      (format "\"%s\"" var))

  (format "%S" var)
  
> +     (t
> +      (format "%s" var))))
> +  )

Dangling parens.

> +(defun org-babel-variable-assignments:clojure (params)
> +  "Return a list of Clojure statements assigning the block's variables in `PARAMS'."

PARAMS, not `PARAMS'.

> +  (mapcar
> +   (lambda (pair)
> +     (format "(def %s %s)"
> +             (car pair)
> +             (org-babel-clojure-var-to-clojure (cdr pair))))
> +   (org-babel--get-vars params)))

Would it make sense to add a few tests for this?

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] migrate ob-clojure initiate session code from ob-clojure-literate.el into ob-clojure.el
  2018-04-20  8:59 ` Nicolas Goaziou
@ 2018-10-23 12:02   ` stardiviner
  2018-10-24 11:41     ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: stardiviner @ 2018-10-23 12:02 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org-mode

[-- Attachment #1: Type: text/plain, Size: 573 bytes --]


Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

Hi, sorry for late response, because I'm a little lazy on give effort on
review my patch and improve it again. But now I finished it. Actually I
corrected my patch as soon as you replied email with mentioned. Today I
pick up this task again, and add a new improve which support CIDER new
API which using sesman to manage REPL sessions.

>
> Would it make sense to add a few tests for this?
>
> Regards,

It is hard for me to write tests for CIDER session. It has some kind of interactive and don't know how to verify it.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: support initialize clojure session --]
[-- Type: text/x-patch, Size: 9031 bytes --]

From f495c5b4e65fd8c6a64e8619d974d6eb051fb1f7 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Thu, 19 Apr 2018 18:16:27 +0800
Subject: [PATCH 1/2] ob-clojure.el: Support `org-babel-initiate-session' to
 initialize.

* ob-clojure.el (org-babel-clojure-initiate-session): Initialize session
for src block.
(org-babel-prep-session:clojure): Prepare Clojure session.
(org-babel-clojure-var-to-clojure): Convert header argument :var into
clojure variables definitions.
(org-babel-variable-assignments:clojure): Support assign variables when
initialize session.
---
 contrib/lisp/ob-clojure-literate.el | 56 ---------------------
 lisp/ob-clojure.el                  | 55 +++++++++++++++++++++
 testing/lisp/test-ob-clojure.el     | 77 +++++++++++++++++++++++++++++
 3 files changed, 132 insertions(+), 56 deletions(-)
 create mode 100644 testing/lisp/test-ob-clojure.el

diff --git a/contrib/lisp/ob-clojure-literate.el b/contrib/lisp/ob-clojure-literate.el
index 4c4d38a0f..b1cc386ee 100644
--- a/contrib/lisp/ob-clojure-literate.el
+++ b/contrib/lisp/ob-clojure-literate.el
@@ -184,62 +184,6 @@ If it is a directory, `ob-clojure-literate' will try to create Clojure project a
                  (lambda (cons) (if (eq (car cons) :session) t cons))
                  org-babel-default-header-args:clojure)))))
 
-;;; Support `org-babel-initiate-session' / [C-c C-v z] to initialize Clojure session.
-
-(defun org-babel-clojure-initiate-session (&optional session _params)
-  "Initiate a session named SESSION according to PARAMS."
-  (when (and session (not (string= session "none")))
-    (save-window-excursion
-      (unless (org-babel-comint-buffer-livep session)
-        ;; CIDER jack-in to the Clojure project directory.
-        (cond
-         ((eq org-babel-clojure-backend 'cider)
-          (require 'cider)
-          (let ((session-buffer (save-window-excursion
-                                  (cider-jack-in t)
-                                  (current-buffer))))
-            (if (org-babel-comint-buffer-livep session-buffer)
-                (progn (sit-for .25) session-buffer))))
-         ((eq org-babel-clojure-backend 'slime)
-          (error "Session evaluation with SLIME is not supported"))
-         (t
-          (error "Session initiate failed")))
-        )
-      (get-buffer session)
-      )))
-
-(defun org-babel-prep-session:clojure (session params)
-  "Prepare SESSION according to the header arguments specified in PARAMS."
-  (let* ((session (org-babel-clojure-initiate-session session))
-         (var-lines (org-babel-variable-assignments:clojure params)))
-    (when session
-      (org-babel-comint-in-buffer session
-        (mapc (lambda (var)
-                (insert var) (comint-send-input nil t)
-		(org-babel-comint-wait-for-output session)
-		(sit-for .1) (goto-char (point-max))) var-lines)))
-    session))
-
-(defun org-babel-clojure-var-to-clojure (var)
-  "Convert src block's `VAR' to Clojure variable."
-  (if (listp var)
-      (replace-regexp-in-string "(" "'(" var)
-    (cond
-     ((stringp var)
-      ;; wrap org-babel passed in header argument value with quote in Clojure.
-      (format "\"%s\"" var))
-     (t
-      (format "%s" var))))
-  )
-
-(defun org-babel-variable-assignments:clojure (params)
-  "Return a list of Clojure statements assigning the block's variables in `PARAMS'."
-  (mapcar
-   (lambda (pair)
-     (format "(def %s %s)"
-             (car pair)
-             (org-babel-clojure-var-to-clojure (cdr pair))))
-   (org-babel--get-vars params)))
 
 ;;; Support header arguments  :results graphics :file "image.png" by inject Clojure code.
 (defun ob-clojure-literate-inject-code (args)
diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index d5b918b01..048ba3735 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -43,6 +43,7 @@
 (require 'ob)
 (require 'org-macs)
 
+(declare-function cider-jack-in "ext:cider" (&optional prompt-project cljs-too))
 (declare-function cider-current-connection "ext:cider-client" (&optional type))
 (declare-function cider-current-ns "ext:cider-client" ())
 (declare-function nrepl--merge "ext:nrepl-client" (dict1 dict2))
@@ -211,6 +212,60 @@ using the :show-process parameter."
       (condition-case nil (org-babel-script-escape result)
 	(error result)))))
 
+(defun org-babel-clojure-initiate-session (&optional session _params)
+  "Initiate a session named SESSION according to PARAMS."
+  (when (and session (not (string= session "none")))
+    (save-window-excursion
+      (cond
+       ((org-babel-comint-buffer-livep session) nil)
+       ;; CIDER jack-in to the Clojure project directory.
+       ((eq org-babel-clojure-backend 'cider)
+        (require 'cider)
+        (let ((session-buffer (save-window-excursion
+                                (cider-jack-in t)
+                                (current-buffer))))
+          (if (org-babel-comint-buffer-livep session-buffer)
+              (progn (sit-for .25) session-buffer))))
+       ((eq org-babel-clojure-backend 'slime)
+        (error "Session evaluation with SLIME is not supported"))
+       (t
+        (error "Session initiate failed")))
+      (get-buffer session))))
+
+(defun org-babel-prep-session:clojure (session params)
+  "Prepare SESSION according to the header arguments specified in PARAMS."
+  (let ((session (org-babel-clojure-initiate-session session))
+        (var-lines (org-babel-variable-assignments:clojure params)))
+    (when session
+      (org-babel-comint-in-buffer session
+	(dolist (var var-lines)
+	  (insert var)
+	  (comint-send-input nil t)
+	  (org-babel-comint-wait-for-output session)
+	  (sit-for .1)
+	  (goto-char (point-max)))))
+    session))
+
+(defun org-babel-clojure-var-to-clojure (var)
+  "Convert src block's VAR to Clojure variable."
+  (cond
+   ((listp var)
+    (replace-regexp-in-string "(" "'(" var))
+   ((stringp var)
+    ;; Wrap Babel passed-in header argument value with quotes in Clojure.
+    (format "\"%s\"" var))
+   (t
+    (format "%S" var))))
+
+(defun org-babel-variable-assignments:clojure (params)
+  "Return a list of Clojure statements assigning the block's variables in PARAMS."
+  (mapcar
+   (lambda (pair)
+     (format "(def %s %s)"
+             (car pair)
+             (org-babel-clojure-var-to-clojure (cdr pair))))
+   (org-babel--get-vars params)))
+
 (provide 'ob-clojure)
 
 ;;; ob-clojure.el ends here
diff --git a/testing/lisp/test-ob-clojure.el b/testing/lisp/test-ob-clojure.el
new file mode 100644
index 000000000..f917ca4cc
--- /dev/null
+++ b/testing/lisp/test-ob-clojure.el
@@ -0,0 +1,77 @@
+;;; test-ob-clojure.el
+
+;; Copyright (c) 2018-2022 Free Software Foundation, Inc.
+;; Authors: stardiviner
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Comments:
+
+;; Org tests for ob-clojure.el live here
+
+;;; Code:
+(org-test-for-executable "cider")
+(unless (featurep 'cider)
+  (signal 'missing-test-dependency "CIDER"))
+(unless (featurep 'ob-clojure)
+  (signal 'missing-test-dependency "Support for Clojure code blocks"))
+
+(ert-deftest ob-clojure/simple-session ()
+  (org-test-with-temp-text
+      "#+begin_src clojure :session
+(print \"hello, world\")
+#+end_src
+"
+    (should (string= "hello, world" (org-babel-execute-src-block)))))
+
+(ert-deftest ob-clojure/initiate-session ()
+  (org-test-with-temp-text
+      "#+begin_src clojure :session :var a=1 :results output
+(print \"hello, world\")
+#+end_src
+
+#+begin_src clojure :session :results output
+(print a)
+#+end_src"
+    (goto-char (point-min))
+    (org-babel-switch-to-session)
+    (sleep-for 2)
+    (org-babel-execute-maybe)
+    (org-babel-next-src-block)
+    (goto-char (org-babel-result-end))
+    (forward-line 2)
+    (should (string=
+	     ": 1"
+	     (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
+
+(ert-deftest ob-clojure/initiate-session-with-var ()
+  (org-test-with-temp-text
+      "#+begin_src clojure :session :var a=1 :results output
+(print a)
+#+end_src"
+    (org-babel-next-src-block)
+    (org-babel-initiate-session)
+    (sleep-for 2)
+    (org-babel-execute-maybe)
+    (goto-char (org-babel-result-end))
+    (forward-line 2)
+    (should (string=
+	     ": 1"
+	     (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
+
+(provide 'test-ob-clojure)
+
+ ;;; test-ob-clojure.el ends here
-- 
2.19.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: support new CIDER API with sesman to manage REPL sessions --]
[-- Type: text/x-patch, Size: 1361 bytes --]

From 18810dbf156172598f94795e801191ba2ca51f7a Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Tue, 23 Oct 2018 19:23:45 +0800
Subject: [PATCH 2/2] ob-clojure.el: Support new CIDER using sesman to manage
 sessions.

* ob-clojure.el (org-babel-clojure-initiate-session): improve ob-clojure
  initialize session way to support CIDER new API.
---
 lisp/ob-clojure.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index 048ba3735..b0a38cb0f 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -222,7 +222,13 @@ using the :show-process parameter."
        ((eq org-babel-clojure-backend 'cider)
         (require 'cider)
         (let ((session-buffer (save-window-excursion
-                                (cider-jack-in t)
+				(if (version< cider-version "0.18.0")
+				    ;; older CIDER (without sesman) still need to use old way.
+				    (cider-jack-in nil) ; nil for jack-in without project.
+				  ;; new CIDER (with sesman to manage sessions)
+				  (unless (cider-repls)
+				    (let ((sesman-system 'CIDER))
+				      (call-interactively 'sesman-link-with-directory))))
                                 (current-buffer))))
           (if (org-babel-comint-buffer-livep session-buffer)
               (progn (sit-for .25) session-buffer))))
-- 
2.19.1


[-- Attachment #4: Type: text/plain, Size: 373 bytes --]


As always, thank you for maintaining Org Mode and reviewing my patches and patient of my stupidity. Point out any issue if you found. Thanks again.

--
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.
       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] migrate ob-clojure initiate session code from ob-clojure-literate.el into ob-clojure.el
  2018-10-23 12:02   ` stardiviner
@ 2018-10-24 11:41     ` Nicolas Goaziou
  2018-10-25  5:51       ` stardiviner
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2018-10-24 11:41 UTC (permalink / raw)
  To: stardiviner; +Cc: org-mode

Hello,

stardiviner <numbchild@gmail.com> writes:

> Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>
> Hi, sorry for late response, because I'm a little lazy on give effort on
> review my patch and improve it again. But now I finished it. Actually I
> corrected my patch as soon as you replied email with mentioned. Today I
> pick up this task again, and add a new improve which support CIDER new
> API which using sesman to manage REPL sessions.

OK. So does it qualify as a bug fix, i.e., should that go into master
branch, or is it a new feature, for next branch?

BTW, there are some compilation warning:

--8<---------------cut here---------------start------------->8---
Compiling /home/ngz/dev/org-mode/lisp/ob-clojure.el...

In toplevel form:
ob-clojure.el:215:1:Warning: Unused lexical variable ‘sesman-system’

In org-babel-clojure-initiate-session:
ob-clojure.el:225:47:Warning: reference to free variable ‘cider-version’

In end of data:
ob-clojure.el:278:1:Warning: the function ‘cider-repls’ is not known to be
    defined.
--8<---------------cut here---------------end--------------->8---

Could you fix them?

Thank you.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] migrate ob-clojure initiate session code from ob-clojure-literate.el into ob-clojure.el
  2018-10-24 11:41     ` Nicolas Goaziou
@ 2018-10-25  5:51       ` stardiviner
  2018-10-25  8:37         ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: stardiviner @ 2018-10-25  5:51 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org-mode

[-- Attachment #1: Type: text/plain, Size: 2661 bytes --]


Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> stardiviner <numbchild@gmail.com> writes:
>
>> Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>>
>> Hi, sorry for late response, because I'm a little lazy on give effort on
>> review my patch and improve it again. But now I finished it. Actually I
>> corrected my patch as soon as you replied email with mentioned. Today I
>> pick up this task again, and add a new improve which support CIDER new
>> API which using sesman to manage REPL sessions.
>
> OK. So does it qualify as a bug fix, i.e., should that go into master
> branch, or is it a new feature, for next branch?
>
> BTW, there are some compilation warning:
>
> --8<---------------cut here---------------start------------->8---
> Compiling /home/ngz/dev/org-mode/lisp/ob-clojure.el...
>
> In toplevel form:
> ob-clojure.el:215:1:Warning: Unused lexical variable ‘sesman-system’
>
> In org-babel-clojure-initiate-session:
> ob-clojure.el:225:47:Warning: reference to free variable ‘cider-version’
>
> In end of data:
> ob-clojure.el:278:1:Warning: the function ‘cider-repls’ is not known to be
>     defined.
> --8<---------------cut here---------------end--------------->8---
>
> Could you fix them?
>
> Thank you.
>
> Regards,

Hi, Nicolas. I fixed those warning. I think this should be a feature. not a patch.

And run `make test`. Here is the result:

```
...
executing Vala source code block
Code block evaluation complete.
   passed  138/814  ob-vala/static-output
   failed  139/814  org-missing-dependency/test-ob-R
   failed  140/814  org-missing-dependency/test-ob-clojure
   failed  141/814  org-missing-dependency/test-ob-lua
   failed  142/814  org-missing-dependency/test-ob-maxima
   failed  143/814  org-missing-dependency/test-ob-plantuml
   failed  144/814  org-missing-dependency/test-ob-ruby
   failed  145/814  org-missing-dependency/test-ob-scheme
   failed  146/814  org-missing-dependency/test-org-attach-annex
   failed  147/814  org-missing-dependency/test-org-protocol
   passed  148/814  test-ob-exp/org-babel-exp-src-blocks/w-no-file
   passed  149/814  test-ob-exp/org-babel-exp-src-blocks/w-no-headers
   passed  150/814  test-ob-exp/org-babel-exp-src-blocks/w-no-headers2
executing Emacs-Lisp code block...
.....
.....
6 unexpected results:
   FAILED  ob-D/inhomogeneous_table
   FAILED  ob-D/list-list-var
   FAILED  ob-D/list-var
   FAILED  ob-D/vector-var
   FAILED  test-org-clock/clocktable/lang
   FAILED  test-org-colview/columns-width
```
Also I added an entry in ORG-NEWS mentioned about this new feature.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-clojure.el-Support-org-babel-initiate-session-to-.patch --]
[-- Type: text/x-patch, Size: 9031 bytes --]

From f495c5b4e65fd8c6a64e8619d974d6eb051fb1f7 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Thu, 19 Apr 2018 18:16:27 +0800
Subject: [PATCH 1/2] ob-clojure.el: Support `org-babel-initiate-session' to
 initialize.

* ob-clojure.el (org-babel-clojure-initiate-session): Initialize session
for src block.
(org-babel-prep-session:clojure): Prepare Clojure session.
(org-babel-clojure-var-to-clojure): Convert header argument :var into
clojure variables definitions.
(org-babel-variable-assignments:clojure): Support assign variables when
initialize session.
---
 contrib/lisp/ob-clojure-literate.el | 56 ---------------------
 lisp/ob-clojure.el                  | 55 +++++++++++++++++++++
 testing/lisp/test-ob-clojure.el     | 77 +++++++++++++++++++++++++++++
 3 files changed, 132 insertions(+), 56 deletions(-)
 create mode 100644 testing/lisp/test-ob-clojure.el

diff --git a/contrib/lisp/ob-clojure-literate.el b/contrib/lisp/ob-clojure-literate.el
index 4c4d38a0f..b1cc386ee 100644
--- a/contrib/lisp/ob-clojure-literate.el
+++ b/contrib/lisp/ob-clojure-literate.el
@@ -184,62 +184,6 @@ If it is a directory, `ob-clojure-literate' will try to create Clojure project a
                  (lambda (cons) (if (eq (car cons) :session) t cons))
                  org-babel-default-header-args:clojure)))))
 
-;;; Support `org-babel-initiate-session' / [C-c C-v z] to initialize Clojure session.
-
-(defun org-babel-clojure-initiate-session (&optional session _params)
-  "Initiate a session named SESSION according to PARAMS."
-  (when (and session (not (string= session "none")))
-    (save-window-excursion
-      (unless (org-babel-comint-buffer-livep session)
-        ;; CIDER jack-in to the Clojure project directory.
-        (cond
-         ((eq org-babel-clojure-backend 'cider)
-          (require 'cider)
-          (let ((session-buffer (save-window-excursion
-                                  (cider-jack-in t)
-                                  (current-buffer))))
-            (if (org-babel-comint-buffer-livep session-buffer)
-                (progn (sit-for .25) session-buffer))))
-         ((eq org-babel-clojure-backend 'slime)
-          (error "Session evaluation with SLIME is not supported"))
-         (t
-          (error "Session initiate failed")))
-        )
-      (get-buffer session)
-      )))
-
-(defun org-babel-prep-session:clojure (session params)
-  "Prepare SESSION according to the header arguments specified in PARAMS."
-  (let* ((session (org-babel-clojure-initiate-session session))
-         (var-lines (org-babel-variable-assignments:clojure params)))
-    (when session
-      (org-babel-comint-in-buffer session
-        (mapc (lambda (var)
-                (insert var) (comint-send-input nil t)
-		(org-babel-comint-wait-for-output session)
-		(sit-for .1) (goto-char (point-max))) var-lines)))
-    session))
-
-(defun org-babel-clojure-var-to-clojure (var)
-  "Convert src block's `VAR' to Clojure variable."
-  (if (listp var)
-      (replace-regexp-in-string "(" "'(" var)
-    (cond
-     ((stringp var)
-      ;; wrap org-babel passed in header argument value with quote in Clojure.
-      (format "\"%s\"" var))
-     (t
-      (format "%s" var))))
-  )
-
-(defun org-babel-variable-assignments:clojure (params)
-  "Return a list of Clojure statements assigning the block's variables in `PARAMS'."
-  (mapcar
-   (lambda (pair)
-     (format "(def %s %s)"
-             (car pair)
-             (org-babel-clojure-var-to-clojure (cdr pair))))
-   (org-babel--get-vars params)))
 
 ;;; Support header arguments  :results graphics :file "image.png" by inject Clojure code.
 (defun ob-clojure-literate-inject-code (args)
diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index d5b918b01..048ba3735 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -43,6 +43,7 @@
 (require 'ob)
 (require 'org-macs)
 
+(declare-function cider-jack-in "ext:cider" (&optional prompt-project cljs-too))
 (declare-function cider-current-connection "ext:cider-client" (&optional type))
 (declare-function cider-current-ns "ext:cider-client" ())
 (declare-function nrepl--merge "ext:nrepl-client" (dict1 dict2))
@@ -211,6 +212,60 @@ using the :show-process parameter."
       (condition-case nil (org-babel-script-escape result)
 	(error result)))))
 
+(defun org-babel-clojure-initiate-session (&optional session _params)
+  "Initiate a session named SESSION according to PARAMS."
+  (when (and session (not (string= session "none")))
+    (save-window-excursion
+      (cond
+       ((org-babel-comint-buffer-livep session) nil)
+       ;; CIDER jack-in to the Clojure project directory.
+       ((eq org-babel-clojure-backend 'cider)
+        (require 'cider)
+        (let ((session-buffer (save-window-excursion
+                                (cider-jack-in t)
+                                (current-buffer))))
+          (if (org-babel-comint-buffer-livep session-buffer)
+              (progn (sit-for .25) session-buffer))))
+       ((eq org-babel-clojure-backend 'slime)
+        (error "Session evaluation with SLIME is not supported"))
+       (t
+        (error "Session initiate failed")))
+      (get-buffer session))))
+
+(defun org-babel-prep-session:clojure (session params)
+  "Prepare SESSION according to the header arguments specified in PARAMS."
+  (let ((session (org-babel-clojure-initiate-session session))
+        (var-lines (org-babel-variable-assignments:clojure params)))
+    (when session
+      (org-babel-comint-in-buffer session
+	(dolist (var var-lines)
+	  (insert var)
+	  (comint-send-input nil t)
+	  (org-babel-comint-wait-for-output session)
+	  (sit-for .1)
+	  (goto-char (point-max)))))
+    session))
+
+(defun org-babel-clojure-var-to-clojure (var)
+  "Convert src block's VAR to Clojure variable."
+  (cond
+   ((listp var)
+    (replace-regexp-in-string "(" "'(" var))
+   ((stringp var)
+    ;; Wrap Babel passed-in header argument value with quotes in Clojure.
+    (format "\"%s\"" var))
+   (t
+    (format "%S" var))))
+
+(defun org-babel-variable-assignments:clojure (params)
+  "Return a list of Clojure statements assigning the block's variables in PARAMS."
+  (mapcar
+   (lambda (pair)
+     (format "(def %s %s)"
+             (car pair)
+             (org-babel-clojure-var-to-clojure (cdr pair))))
+   (org-babel--get-vars params)))
+
 (provide 'ob-clojure)
 
 ;;; ob-clojure.el ends here
diff --git a/testing/lisp/test-ob-clojure.el b/testing/lisp/test-ob-clojure.el
new file mode 100644
index 000000000..f917ca4cc
--- /dev/null
+++ b/testing/lisp/test-ob-clojure.el
@@ -0,0 +1,77 @@
+;;; test-ob-clojure.el
+
+;; Copyright (c) 2018-2022 Free Software Foundation, Inc.
+;; Authors: stardiviner
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Comments:
+
+;; Org tests for ob-clojure.el live here
+
+;;; Code:
+(org-test-for-executable "cider")
+(unless (featurep 'cider)
+  (signal 'missing-test-dependency "CIDER"))
+(unless (featurep 'ob-clojure)
+  (signal 'missing-test-dependency "Support for Clojure code blocks"))
+
+(ert-deftest ob-clojure/simple-session ()
+  (org-test-with-temp-text
+      "#+begin_src clojure :session
+(print \"hello, world\")
+#+end_src
+"
+    (should (string= "hello, world" (org-babel-execute-src-block)))))
+
+(ert-deftest ob-clojure/initiate-session ()
+  (org-test-with-temp-text
+      "#+begin_src clojure :session :var a=1 :results output
+(print \"hello, world\")
+#+end_src
+
+#+begin_src clojure :session :results output
+(print a)
+#+end_src"
+    (goto-char (point-min))
+    (org-babel-switch-to-session)
+    (sleep-for 2)
+    (org-babel-execute-maybe)
+    (org-babel-next-src-block)
+    (goto-char (org-babel-result-end))
+    (forward-line 2)
+    (should (string=
+	     ": 1"
+	     (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
+
+(ert-deftest ob-clojure/initiate-session-with-var ()
+  (org-test-with-temp-text
+      "#+begin_src clojure :session :var a=1 :results output
+(print a)
+#+end_src"
+    (org-babel-next-src-block)
+    (org-babel-initiate-session)
+    (sleep-for 2)
+    (org-babel-execute-maybe)
+    (goto-char (org-babel-result-end))
+    (forward-line 2)
+    (should (string=
+	     ": 1"
+	     (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
+
+(provide 'test-ob-clojure)
+
+ ;;; test-ob-clojure.el ends here
-- 
2.19.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-ob-clojure.el-Support-new-CIDER-using-sesman-to-mana.patch --]
[-- Type: text/x-patch, Size: 3148 bytes --]

From 62dc8625005af2e1be9e1e3dde897e294bd56324 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Tue, 23 Oct 2018 19:23:45 +0800
Subject: [PATCH 2/2] ob-clojure.el: Support new CIDER using sesman to manage
 sessions.

* ob-clojure.el (org-babel-clojure-initiate-session): improve ob-clojure
  initialize session way to support CIDER new API.
* etc/ORG-NEWS: add declare for new :session support feature.
---
 etc/ORG-NEWS       | 11 +++++++++++
 lisp/ob-clojure.el | 11 ++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 811e98147..100f9fd75 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -170,6 +170,17 @@ This is consistent with the naming of =org-dblock-write:columnview=
 options, where =:match= is also used as a headlines filter.
 
 ** New features
+*** Add ~:session~ support of ob-clojure for CIDER
+You can initialize source block session with Babel default keybinding
+=[C-c C-v C-z]= to use =sesman= session manager to link current
+project, directory or buffer with specific Clojure session, or
+=cider-jack-in= a new CIDER REPL if no CIDER REPLs available. In older
+CIDER version which has not =sesman= integrated, only has
+=cider-jack-in= without Clojure project is supported.
+#+begin_src clojure :session
+(dissoc Clojure 'JVM)
+(conj clojurists "stardiviner")
+#+end_src
 *** Add ~:results link~ support for Babel
 
 With this output format, create a link to the file specified in
diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index 048ba3735..ffac3c149 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -46,6 +46,7 @@
 (declare-function cider-jack-in "ext:cider" (&optional prompt-project cljs-too))
 (declare-function cider-current-connection "ext:cider-client" (&optional type))
 (declare-function cider-current-ns "ext:cider-client" ())
+(declare-function cider-repls "ext:cider-connection" (&optional type ensure))
 (declare-function nrepl--merge "ext:nrepl-client" (dict1 dict2))
 (declare-function nrepl-dict-get "ext:nrepl-client" (dict key))
 (declare-function nrepl-dict-put "ext:nrepl-client" (dict key value))
@@ -55,6 +56,8 @@
 
 (defvar nrepl-sync-request-timeout)
 (defvar cider-buffer-ns)
+(defvar sesman-system)
+(defvar cider-version)
 
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj"))
@@ -222,7 +225,13 @@ using the :show-process parameter."
        ((eq org-babel-clojure-backend 'cider)
         (require 'cider)
         (let ((session-buffer (save-window-excursion
-                                (cider-jack-in t)
+				(if (version< cider-version "0.18.0")
+				    ;; older CIDER (without sesman) still need to use old way.
+				    (cider-jack-in nil) ; nil for jack-in without project.
+				  ;; new CIDER (with sesman to manage sessions)
+				  (unless (cider-repls)
+				    (let ((sesman-system 'CIDER))
+				      (call-interactively 'sesman-link-with-directory))))
                                 (current-buffer))))
           (if (org-babel-comint-buffer-livep session-buffer)
               (progn (sit-for .25) session-buffer))))
-- 
2.19.1


[-- Attachment #4: Type: text/plain, Size: 233 bytes --]



-- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.
       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] migrate ob-clojure initiate session code from ob-clojure-literate.el into ob-clojure.el
  2018-10-25  5:51       ` stardiviner
@ 2018-10-25  8:37         ` Nicolas Goaziou
  2018-10-25 23:38           ` stardiviner
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2018-10-25  8:37 UTC (permalink / raw)
  To: stardiviner; +Cc: org-mode

Hello,

stardiviner <numbchild@gmail.com> writes:

> Hi, Nicolas. I fixed those warning. I think this should be a feature.
> not a patch.

Applied in "next", then. Thank you.

> And run `make test`. Here is the result:

[...]

> executing Vala source code block
> Code block evaluation complete.
>    passed  138/814  ob-vala/static-output
>    failed  139/814  org-missing-dependency/test-ob-R
>    failed  140/814  org-missing-dependency/test-ob-clojure
>    failed  141/814  org-missing-dependency/test-ob-lua
>    failed  142/814  org-missing-dependency/test-ob-maxima
>    failed  143/814  org-missing-dependency/test-ob-plantuml
>    failed  144/814  org-missing-dependency/test-ob-ruby
>    failed  145/814  org-missing-dependency/test-ob-scheme
>    failed  146/814  org-missing-dependency/test-org-attach-annex
>    failed  147/814  org-missing-dependency/test-org-protocol

This is expected.

> 6 unexpected results:
>    FAILED  ob-D/inhomogeneous_table
>    FAILED  ob-D/list-list-var
>    FAILED  ob-D/list-var
>    FAILED  ob-D/vector-var
>    FAILED  test-org-clock/clocktable/lang
>    FAILED  test-org-colview/columns-width

I cannot reproduce it. Could you show the full output of these errors?

Thank you.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] migrate ob-clojure initiate session code from ob-clojure-literate.el into ob-clojure.el
  2018-10-25  8:37         ` Nicolas Goaziou
@ 2018-10-25 23:38           ` stardiviner
  0 siblings, 0 replies; 7+ messages in thread
From: stardiviner @ 2018-10-25 23:38 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org-mode


Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

>> 6 unexpected results:
>>    FAILED  ob-D/inhomogeneous_table
>>    FAILED  ob-D/list-list-var
>>    FAILED  ob-D/list-var
>>    FAILED  ob-D/vector-var

Test ob-D/inhomogeneous_table backtrace:
  signal(ert-test-failed (((should (equal '(("monday" 34) ("tuesday" 4
  ert-fail(((should (equal '(("monday" 34) ("tuesday" 41) ("wednesday"
  (if (unwind-protect (setq value-94 (apply fn-92 args-93)) (setq form
  (let (form-description-96) (if (unwind-protect (setq value-94 (apply
  (let ((value-94 'ert-form-evaluation-aborted-95)) (let (form-descrip
  (let* ((fn-92 (function equal)) (args-93 (condition-case err (let ((
  (save-restriction (org-babel-next-src-block 2) (let* ((fn-92 (functi
  (progn (org-id-goto "e112bc2e-419a-4890-99c2-7ac4779531cc") (setq to
  (unwind-protect (progn (org-id-goto "e112bc2e-419a-4890-99c2-7ac4779
  (let ((save-match-data-internal (match-data))) (unwind-protect (prog
  (progn (let ((save-match-data-internal (match-data))) (unwind-protec
  (unwind-protect (progn (let ((save-match-data-internal (match-data))
  (let ((wconfig (current-window-configuration))) (unwind-protect (pro
  (unwind-protect (let ((wconfig (current-window-configuration))) (unw
  (let* ((id-location (org-id-find "e112bc2e-419a-4890-99c2-7ac4779531
  (if (executable-find org-babel-D-compiler) (let* ((id-location (org-
  (lambda nil (if (executable-find org-babel-D-compiler) (let* ((id-lo
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name ob-D/inhomogeneous_table :documentati
  ert-run-or-rerun-test(#s(ert--stats :selector "\\(org\\|ob\\)" :test
  ert-run-tests("\\(org\\|ob\\)" #f(compiled-function (event-type &res
  ert-run-tests-batch("\\(org\\|ob\\)")
  ert-run-tests-batch-and-exit("\\(org\\|ob\\)")
  (let ((org-id-track-globally t) (org-test-selector (if org-test-sele
  org-test-run-batch-tests("\\(org\\|ob\\)")
  eval((org-test-run-batch-tests org-test-select-re))
  command-line-1(("--eval" "(setq vc-handled-backends nil org-startup-
  command-line()
  normal-top-level()
Test ob-D/inhomogeneous_table condition:
    (ert-test-failed
     ((should
       (equal '...
        (org-babel-execute-src-block)))
      :form
      (equal
       (("monday" 34)
        ("tuesday" 41)
        ("wednesday" 56)
        ("thursday" 17)
        ("friday" 12)
        ("saturday" 7)
        ("sunday" 4)
        ("Friday" "friday"))
       nil)
      :value nil :explanation
      (different-types
       (("monday" 34)
        ("tuesday" 41)
        ("wednesday" 56)
        ("thursday" 17)
        ("friday" 12)
        ("saturday" 7)
        ("sunday" 4)
        ("Friday" "friday"))
       nil)))
   FAILED   12/814  ob-D/inhomogeneous_table
executing D code block (integer_var)...
"12"
   passed   13/814  ob-D/integer-var
executing D code block (list_list_var)...
Babel evaluation exited with code 1
nil
Test ob-D/list-list-var backtrace:
  signal(ert-test-failed (((should (equal '((1 3) (2 4)) (org-babel-ex
  ert-fail(((should (equal '((1 3) (2 4)) (org-babel-execute-src-block
  (if (unwind-protect (setq value-84 (apply fn-82 args-83)) (setq form
  (let (form-description-86) (if (unwind-protect (setq value-84 (apply
  (let ((value-84 'ert-form-evaluation-aborted-85)) (let (form-descrip
  (let* ((fn-82 (function equal)) (args-83 (condition-case err (let ((
  (save-restriction (org-babel-next-src-block 6) (let* ((fn-82 (functi
  (progn (org-id-goto "cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5") (setq to
  (unwind-protect (progn (org-id-goto "cc65d6b3-8e8e-4f9c-94cd-f5a00cd
  (let ((save-match-data-internal (match-data))) (unwind-protect (prog
  (progn (let ((save-match-data-internal (match-data))) (unwind-protec
  (unwind-protect (progn (let ((save-match-data-internal (match-data))
  (let ((wconfig (current-window-configuration))) (unwind-protect (pro
  (unwind-protect (let ((wconfig (current-window-configuration))) (unw
  (let* ((id-location (org-id-find "cc65d6b3-8e8e-4f9c-94cd-f5a00cdece
  (if (executable-find org-babel-D-compiler) (let* ((id-location (org-
  (lambda nil (if (executable-find org-babel-D-compiler) (let* ((id-lo
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name ob-D/list-list-var :documentation "Te
  ert-run-or-rerun-test(#s(ert--stats :selector "\\(org\\|ob\\)" :test
  ert-run-tests("\\(org\\|ob\\)" #f(compiled-function (event-type &res
  ert-run-tests-batch("\\(org\\|ob\\)")
  ert-run-tests-batch-and-exit("\\(org\\|ob\\)")
  (let ((org-id-track-globally t) (org-test-selector (if org-test-sele
  org-test-run-batch-tests("\\(org\\|ob\\)")
  eval((org-test-run-batch-tests org-test-select-re))
  command-line-1(("--eval" "(setq vc-handled-backends nil org-startup-
  command-line()
  normal-top-level()
Test ob-D/list-list-var condition:
    (ert-test-failed
     ((should
       (equal '...
        (org-babel-execute-src-block)))
      :form
      (equal
       ((1 3)
        (2 4))
       nil)
      :value nil :explanation
      (different-types
       ((1 3)
        (2 4))
       nil)))
   FAILED   14/814  ob-D/list-list-var
executing D code block (list_var)...
Babel evaluation exited with code 1
nil
Test ob-D/list-var backtrace:
  signal(ert-test-failed (((should (string= "abcdef2" (org-babel-execu
  ert-fail(((should (string= "abcdef2" (org-babel-execute-src-block)))
  (if (unwind-protect (setq value-64 (apply fn-62 args-63)) (setq form
  (let (form-description-66) (if (unwind-protect (setq value-64 (apply
  (let ((value-64 'ert-form-evaluation-aborted-65)) (let (form-descrip
  (let* ((fn-62 (function string=)) (args-63 (condition-case err (let
  (save-restriction (org-babel-next-src-block 2) (let* ((fn-62 (functi
  (progn (org-id-goto "cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5") (setq to
  (unwind-protect (progn (org-id-goto "cc65d6b3-8e8e-4f9c-94cd-f5a00cd
  (let ((save-match-data-internal (match-data))) (unwind-protect (prog
  (progn (let ((save-match-data-internal (match-data))) (unwind-protec
  (unwind-protect (progn (let ((save-match-data-internal (match-data))
  (let ((wconfig (current-window-configuration))) (unwind-protect (pro
  (unwind-protect (let ((wconfig (current-window-configuration))) (unw
  (let* ((id-location (org-id-find "cc65d6b3-8e8e-4f9c-94cd-f5a00cdece
  (if (executable-find org-babel-D-compiler) (let* ((id-location (org-
  (lambda nil (if (executable-find org-babel-D-compiler) (let* ((id-lo
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name ob-D/list-var :documentation "Test of
  ert-run-or-rerun-test(#s(ert--stats :selector "\\(org\\|ob\\)" :test
  ert-run-tests("\\(org\\|ob\\)" #f(compiled-function (event-type &res
  ert-run-tests-batch("\\(org\\|ob\\)")
  ert-run-tests-batch-and-exit("\\(org\\|ob\\)")
  (let ((org-id-track-globally t) (org-test-selector (if org-test-sele
  org-test-run-batch-tests("\\(org\\|ob\\)")
  eval((org-test-run-batch-tests org-test-select-re))
  command-line-1(("--eval" "(setq vc-handled-backends nil org-startup-
  command-line()
  normal-top-level()
Test ob-D/list-var condition:
    (ert-test-failed
     ((should
       (string= "abcdef2"
                (org-babel-execute-src-block)))
      :form
      (string= "abcdef2" nil)
      :value nil))
   FAILED   15/814  ob-D/list-var
Babel evaluation exited with code 1
nil
Test ob-D/vector-var backtrace:
  signal(ert-test-failed (((should (equal 122 (org-babel-execute-src-b
  ert-fail(((should (equal 122 (org-babel-execute-src-block))) :form (
  (if (unwind-protect (setq value-74 (apply fn-72 args-73)) (setq form
  (let (form-description-76) (if (unwind-protect (setq value-74 (apply
  (let ((value-74 'ert-form-evaluation-aborted-75)) (let (form-descrip
  (let* ((fn-72 (function equal)) (args-73 (condition-case err (let ((
  (save-restriction (org-babel-next-src-block 4) (let* ((fn-72 (functi
  (progn (org-id-goto "cc65d6b3-8e8e-4f9c-94cd-f5a00cdeceb5") (setq to
  (unwind-protect (progn (org-id-goto "cc65d6b3-8e8e-4f9c-94cd-f5a00cd
  (let ((save-match-data-internal (match-data))) (unwind-protect (prog
  (progn (let ((save-match-data-internal (match-data))) (unwind-protec
  (unwind-protect (progn (let ((save-match-data-internal (match-data))
  (let ((wconfig (current-window-configuration))) (unwind-protect (pro
  (unwind-protect (let ((wconfig (current-window-configuration))) (unw
  (let* ((id-location (org-id-find "cc65d6b3-8e8e-4f9c-94cd-f5a00cdece
  (if (executable-find org-babel-D-compiler) (let* ((id-location (org-
  (lambda nil (if (executable-find org-babel-D-compiler) (let* ((id-lo
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name ob-D/vector-var :documentation "Test
  ert-run-or-rerun-test(#s(ert--stats :selector "\\(org\\|ob\\)" :test
  ert-run-tests("\\(org\\|ob\\)" #f(compiled-function (event-type &res
  ert-run-tests-batch("\\(org\\|ob\\)")
  ert-run-tests-batch-and-exit("\\(org\\|ob\\)")
  (let ((org-id-track-globally t) (org-test-selector (if org-test-sele
  org-test-run-batch-tests("\\(org\\|ob\\)")
  eval((org-test-run-batch-tests org-test-select-re))
  command-line-1(("--eval" "(setq vc-handled-backends nil org-startup-
  command-line()
  normal-top-level()
Test ob-D/vector-var condition:
    (ert-test-failed
     ((should
       (equal 122
              (org-babel-execute-src-block)))
      :form
      (equal 122 nil)
      :value nil :explanation
      (different-types 122 nil)))
   FAILED   20/814  ob-D/vector-var

>>    FAILED  test-org-clock/clocktable/lang
>>    FAILED  test-org-colview/columns-width

For this two failed test, after I run it again 3 times, it does not appears anymore.

-- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.
       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-10-25 23:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-19 10:22 [PATCH] migrate ob-clojure initiate session code from ob-clojure-literate.el into ob-clojure.el stardiviner
2018-04-20  8:59 ` Nicolas Goaziou
2018-10-23 12:02   ` stardiviner
2018-10-24 11:41     ` Nicolas Goaziou
2018-10-25  5:51       ` stardiviner
2018-10-25  8:37         ` Nicolas Goaziou
2018-10-25 23:38           ` stardiviner

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).