"Christopher M. Miles" <[email protected]> writes:

> I added :session header argument for ob-lua.el library.
> I attached the patch file in email attachment.

Thanks!
One thing immediately striking me
What is (let* ((session (org-babel-gnuplot-initiate-session session)) ??
(why gnuplot?)

> I also have written a test for ob-lua :session, but failed. Hope you can
> point out where is wrong. Thanks.
>
> Here it is:
>
> #+begin_src emacs-lisp
> (ert-deftest test-ob-lua/session-default ()
>   (should
>    (equal
>     (string-join
>      '("#+BEGIN_SRC lua :session \"*lua*\""
>        "print(\"hello, world\")<point>"
>        "#+END_SRC"
>        ""
>        "#+RESULTS:"
>        ": "
>        ": print(\"hello, world\")"
>        ": "
>        ": hello, world"
>        ": >")

Is it really expected that you get a copy of your command + ">" prompt
in the output? Other backends usually strip those things via
`org-babel-comint-with-output'.

> I tested this single test with steps:
>
> 1. first load the necessary macros and functions in tests.
>    =[M-x load-file RET /path/to/org-mode/testing/org-test.el RET]=
> 3. put point on the ert unit test and press =[C-M-x]= to evaluate the ert 
> test.
> 4. =[M-x ert RET test-ob-lua/session-default RET]=
>
> Here is the *ert* buffer output:
> ...
>       :form
>       (equal
>        "#+BEGIN_SRC lua :session \"*lua*\"\nprint(\"hello, 
> world\")<point>\n#+END_SRC\n\n#+RESULTS:\n: \n: print(\"hello, world\")\n: 
> \n: hello, world\n: >"

<point> is a typo.

>        "#+BEGIN_SRC lua :session \"*lua*\"\nprint(\"hello, 
> world\")\n#+END_SRC\n\n#+RESULTS[833e9c971f68b6513b25586dae31dec28afd0af3]:\n:
>  \n: print(\"hello, world\")\n: \n: hello, world\n: >\n")

Also, it looks like you trigger async output? (hash inside results)

> $ make BTEST_RE="test-ob-lua/session-default" test-dirty
> ...
> TMPDIR=/var/folders/ym/f3v5_yk1279g5ls70x3hzblh0000gn/T//tmp-orgtest emacs  
> -Q -batch --eval '(setq vc-handled-backends nil org-startup-folded nil 
> org-element-cache-persistent nil)'  --eval '(add-to-list `load-path (concat 
> default-directory "lisp"))' --eval '(add-to-list `load-path (concat 
> default-directory "testing"))'  -l org-batch-test-init --eval '(setq 
> org-batch-test t org-babel-load-languages (quote ( (awk . t)  (C . t)  
> (fortran . t)  (maxima . t)  (lilypond . t)  (octave . t)  (perl . t)  
> (python . t)  (java . t)  (sqlite . t)  (eshell . t)  (calc . t)  (emacs-lisp 
> . t)  (shell . t)  (org . t))) org-test-select-re 
> "test-ob-lua/session-default" )' -l org-loaddefs.el -l testing/org-test.el -l 
> ert -l org -l ox -l ol  --eval '(org-test-run-batch-tests org-test-select-re)'

Note that you did not activate ob-lua in the tests. See BTEST_OB_LANGUAGES

> +(defvar org-babel-lua-last-input-start nil)
> +(defvar org-babel-lua-last-input-end nil)
> +(defvar org-babel-lua-last-output-start nil)
> +(defvar org-babel-lua-last-output-end nil)

ob-comint library should be able to handle output tracking better.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to