Hello, Thibault Marin <thibault.ma...@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