From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Thibault Marin <thibault.marin@gmx.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: ob-lua
Date: Sun, 21 Aug 2016 11:30:10 +0200 [thread overview]
Message-ID: <878tvq1nbx.fsf@saiph.selenimh> (raw)
In-Reply-To: <87eg5ik9t7.fsf@dell-desktop.WORKGROUP> (Thibault Marin's message of "Sat, 20 Aug 2016 23:47:16 -0500")
Hello,
Thibault Marin <thibault.marin@gmx.com> writes:
> I have updated the patch to use `org-babel--get-vars' as suggested. I
> also have replaced `org-babel-trim' by `org-trim' (as advised in
> ORG-NEWS) and replaced the `case' statement by a `pcase' (I used
> ob-python.el for reference). Please let me know if these changes are
n> acceptable and if other changes are required.
The changes look fine. Could you send them using git format-patch, with
a proper commit message? See
<http://orgmode.org/worg/org-contribute.html#patches> for details.
> About the test, I am attaching my first attempt at this, please let me
> know if you have some advice on how to improve it or if you had
> something else in mind. This is the first time I use ert or org-test,
> but these seem to pass and test the basic features.
Nice. Thank you. I only have a small suggestion about test structure.
See above.
> By the way, when trying to run the tests from emacs, I had an error
> message when doing a (require 'org-test): "let: Required feature `ert-x'
> was not provided". Am I doing something wrong? I worked around it by
> (1) installing the `ertx' package and (2) replacing (require 'ert-x) by
> (require 'ertx) in org-test.el (that's probably the wrong thing to do,
> but it allowed me to run my tests).
I usually only call "make test" from Org root directory.
> ;;; test-ob-lua.el --- tests for ob-lua.el
>
> ;; Copyright (c) 2011-2014 Eric Schulte
> ;; Authors: Eric Schulte
The information above is wrong.
> ;; 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/>.
>
> ;;; Code:
> (unless (featurep 'ob-lua)
> (signal 'missing-test-dependency "Support for Lua code blocks"))
>
>
> (ert-deftest test-ob-lua/simple-value ()
> (org-test-with-temp-text "#+name: eg
> | a | 1 |
> | b | 2 |
>
> #+header: :results value
> #+header: :var x = eg
> #+begin_src lua
> return x['b']
> #+end_src"
> (org-babel-next-src-block)
> (should (equal 2 (org-babel-execute-src-block)))))
You could explain in the docstring, or in a comment, what you are
testing.
Also, I suggest to move `should' and the test on the outside of the
sexp, like this
(ert-deftest test-ob-lua/simple-value ()
"Test ..."
(should
(= 2
(org-test-with-temp-text "#+name: eg
| a | 1 |
| b | 2 |
#+header: :results value
#+header: :var x = eg
#+begin_src lua
return x['b']
#+end_src"
(org-babel-next-src-block)
(org-babel-execute-src-block)))))
This way, you can simply inspect the return value of your test by
calling `eval-last-sexp' after the parenthesis closing
(org-test-with-temp-text ...). It makes debugging easier, IMO.
Regards,
--
Nicolas Goaziou
next prev parent reply other threads:[~2016-08-21 9:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-20 5:18 ob-lua Thibault Marin
2016-08-20 16:02 ` ob-lua Nicolas Goaziou
2016-08-21 4:47 ` ob-lua Thibault Marin
2016-08-21 9:30 ` Nicolas Goaziou [this message]
2016-08-22 2:38 ` ob-lua Thibault Marin
2016-08-22 9:28 ` ob-lua Nicolas Goaziou
2016-08-22 12:56 ` ob-lua Thibault Marin
2016-08-24 2:39 ` ob-lua Thibault Marin
2016-08-29 7:10 ` ob-lua Nicolas Goaziou
2016-08-31 3:36 ` ob-lua Thibault Marin
2016-09-01 16:40 ` ob-lua Nicolas Goaziou
2016-09-08 4:37 ` ob-lua Thibault Marin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878tvq1nbx.fsf@saiph.selenimh \
--to=mail@nicolasgoaziou.fr \
--cc=emacs-orgmode@gnu.org \
--cc=thibault.marin@gmx.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public 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).