From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: ob-lua Date: Sun, 21 Aug 2016 11:30:10 +0200 Message-ID: <878tvq1nbx.fsf@saiph.selenimh> References: <87bn0of273.fsf@dell-desktop.WORKGROUP> <87h9af1la2.fsf@saiph.selenimh> <87eg5ik9t7.fsf@dell-desktop.WORKGROUP> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbP57-0005eu-Ht for emacs-orgmode@gnu.org; Sun, 21 Aug 2016 05:30:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bbP52-0001a8-Es for emacs-orgmode@gnu.org; Sun, 21 Aug 2016 05:30:16 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:52955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbP52-0001a2-7u for emacs-orgmode@gnu.org; Sun, 21 Aug 2016 05:30:12 -0400 In-Reply-To: <87eg5ik9t7.fsf@dell-desktop.WORKGROUP> (Thibault Marin's message of "Sat, 20 Aug 2016 23:47:16 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Thibault Marin Cc: "emacs-orgmode@gnu.org" Hello, Thibault Marin 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 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 . > > ;;; 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