From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martyn Jago Subject: Re: [babel] Collection of code block snippets Date: Thu, 08 Sep 2011 17:18:16 +0100 Message-ID: References: <878vq48dvt.fsf@gmail.com> <87zkiiq4ko.fsf@gmail.com> <87bouxr3v1.fsf@gmail.com> <87mxef6p4r.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:37412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1hJM-0000UH-H5 for emacs-orgmode@gnu.org; Thu, 08 Sep 2011 12:18:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1hJK-0002cZ-Qc for emacs-orgmode@gnu.org; Thu, 08 Sep 2011 12:18:44 -0400 Received: from lo.gmane.org ([80.91.229.12]:48792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1hJK-0002bw-Dl for emacs-orgmode@gnu.org; Thu, 08 Sep 2011 12:18:42 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1R1hJD-0000nZ-NW for emacs-orgmode@gnu.org; Thu, 08 Sep 2011 18:18:35 +0200 Received: from 88-96-171-142.dsl.zen.co.uk ([88.96.171.142]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 08 Sep 2011 18:18:35 +0200 Received: from martyn.jago by 88-96-171-142.dsl.zen.co.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 08 Sep 2011 18:18:35 +0200 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi Eric Eric Schulte writes: > Hi Martyn > > Martyn Jago writes: > >> Hi Eric >> >> Eric Schulte writes: >> >> [...] >> >>> >>> I just made three small changes to the testing framework so it is now >>> possible to run the test suite in batch mode with the following. >>> >>> emacs -Q --batch -l path/to/org/testing/org-test.el --eval "(setq >>> org-confirm-babel-evaluate nil)" -f org-test-run-all-tests >> >> Great idea - unfortunately its not quite working for me since I get >> four failing tests. In addition I have no (easy) indication of which >> four tests are failing since the backtrace is just the output of the >> tests working (no backtrace for failed tests). >> > > I'm getting four failing tests as well when I start Emacs with the -Q > option and no failing tests when I run it with my configuration loaded. > I will dig through my personal config, find out what options are making > these tests pass, and adjust the tests appropriately so that they all > pass with no personal config. > >> >> This is what I like about the ert-run-batch commands - you get an >> indication and summary of tests passed, and the backtrace of any >> failures. >> >> Also, I mentioned that ert-batch.el and ert-run.el are not part of >> Emacs. This is actually because their contents were merged into ert.el >> within Emacs. >> > > Thanks for mentioning the batch ert commands, I was not aware of their > existence. I've added a batch version of org-test-run-all-tests to the > org-mode test suite, the following should now be sufficient to run the > test suite from the command line with nicer output. > > #+begin_src sh > emacs -Q --batch -l path/to/org/testing/org-test.el \ > --eval "(setq org-confirm-babel-evaluate nil)" \ > -f org-test-run-all-tests > #+end_src Thats great - I'll try it out when I get a chance. I have written a few more tests for inline source blocks execution with org-ctrl-c-ctrl-c (not extensive by any means). The last two [:results scaler] and [:results verbatim] surprised me slightly since the manual suggests to me that they would be identical (although verbatim does what I would expect). ,---- | - scalar, verbatim The results should be interpreted literally—they | will not be converted into a table. The results will be inserted into | the Org-mode buffer as quoted text. E.g., :results value verbatim. `---- --8<---------------cut here---------------start------------->8--- src_src_emacs-lisp[ :results scalar ]{ \"x\" } =x= src_src_emacs-lisp[ :results verbatim ]{ \"x\" } ="x"= --8<---------------cut here---------------end--------------->8--- --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-testing-lisp-test-ob.el-More-tests-for-inline-source.patch Content-Description: lisp-test-ob.el-More-tests-for-inline-source-blocks >From b0ea0a6e96188c8ee6861d6cbd04182eb966dbe3 Mon Sep 17 00:00:00 2001 From: Martyn Jago Date: Thu, 8 Sep 2011 16:50:26 +0100 Subject: [PATCH] * testing/lisp/test-ob.el: More tests for inline source blocks execution via org-ctrl-c-ctrl-c --- testing/lisp/test-ob.el | 172 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 172 insertions(+), 0 deletions(-) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index e0f7c65..9735bd8 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -236,6 +236,178 @@ (should-not (org-babel-get-inline-src-block-matches)) ))) +(ert-deftest test-org-babel/inline-src_blk-default-results-replace-line-1 () + (with-temp-buffer + + ;; src_ at bol line 1... + (let ((test-line "src_sh{echo 1}")) + (insert test-line) + (should-error (org-ctrl-c-ctrl-c)) + (goto-char (point-min)) (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =1=") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (forward-char) (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =1= =1=") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (re-search-forward "1}") + (should-error (org-ctrl-c-ctrl-c)) + (backward-char) ;; last char of block body + (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =1= =1= =1=") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + + ;; src_ follows space line 1... + (let ((test-line " src_emacs-lisp{ 1 }")) + (beginning-of-line) + (insert (concat test-line "\n")) + (goto-char (point-min)) + (should-error (org-ctrl-c-ctrl-c)) + (forward-char) (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =1=") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (re-search-forward "{ 1 ") (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =1= =1=") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (forward-char) + (should-error (org-ctrl-c-ctrl-c)) + ))) + +(ert-deftest test-org-babel/inline-src_blk-default-results-replace-line-2 () + (with-temp-buffer + + ;; src_ at bol line 2... + (let ((test-line " src_emacs-lisp{ \"x\" }")) + (insert (concat "\n" test-line)) + (should-error (org-ctrl-c-ctrl-c)) + (goto-char (point-min)) + (should-error (org-ctrl-c-ctrl-c)) + (forward-line) + (should-error (org-ctrl-c-ctrl-c)) + (forward-char) (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =x=") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + + (let ((test-line "Some text prior to block src_emacs-lisp{ \"y\" }")) + (goto-char (point-max)) + (insert (concat "\n" test-line " end")) + (re-search-backward "src") (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =y= end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (re-search-forward "\" ") (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =y= =y= end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (forward-char) + (should-error (org-ctrl-c-ctrl-c)) + ))) + +(ert-deftest test-org-babel/inline-src_blk-manual-results-replace () + (with-temp-buffer + + (let ((test-line " src_emacs-lisp[:results replace]{ \"x\" }")) + (insert (concat "\n" test-line)) + (should-error (org-ctrl-c-ctrl-c)) + (goto-char (point-min)) + (should-error (org-ctrl-c-ctrl-c)) + (forward-line) + (should-error (org-ctrl-c-ctrl-c)) + (forward-char) (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =x=") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + + (let ((test-line " Some text prior to block src_emacs-lisp[:results replace]{ \"y\" }")) + (goto-char (point-max)) + (insert (concat "\n" test-line " end")) + (re-search-backward "src") (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =y= end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (re-search-forward "\" ") (org-ctrl-c-ctrl-c) + (should (string= + (concat test-line " =y= =y= end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (forward-char) + (should-error (org-ctrl-c-ctrl-c))) + )) + +(ert-deftest test-org-babel/inline-src_blk-results-silent () + (with-temp-buffer + + (let ((test-line "src_emacs-lisp[ :results silent ]{ \"x\" }")) + (insert test-line) + (should-error (org-ctrl-c-ctrl-c)) + (goto-char (point-min)) (org-ctrl-c-ctrl-c) + (should (string= test-line + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + (let ((test-line " Some text prior to block src_emacs-lisp[ :results silent ]{ \"y\" }")) + (goto-char (point-max)) + (insert (concat "\n" test-line " end")) + (re-search-backward "src_") (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (re-search-forward "\" ") (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (forward-char) + (should-error (org-ctrl-c-ctrl-c))) + )) + +(ert-deftest test-org-babel/inline-src_blk-results-raw () + (with-temp-buffer + + (let ((test-line "src_emacs-lisp[ :results raw ]{ \"x\" }")) + (insert test-line) + (goto-char (point-min)) (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " x") + (buffer-substring-no-properties (point-at-bol) (point-at-eol))))) + (let ((test-line " Some text prior to block src_emacs-lisp[ :results raw ]{ \"the\" }")) + (goto-char (point-max)) + (insert (concat "\n" test-line " end")) + (re-search-backward "src_") (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " the end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (re-search-forward "\" ") (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " the the end") + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (forward-char) + (should-error (org-ctrl-c-ctrl-c))) + )) + +(ert-deftest test-org-babel/inline-src_blk-results-file () + (with-temp-buffer + + (let ((test-line "src_emacs-lisp[ :results file ]{ \"~/test-file\" }")) + (insert test-line) + (goto-char (point-min)) (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " [[file:~/test-file]]") + (buffer-substring-no-properties (point-min) (point-max))))))) + +(ert-deftest test-org-babel/inline-src_blk-results-scaler () + (with-temp-buffer + + (let ((test-line "src_emacs-lisp[ :results scaler ]{ \"x\" }")) + (insert test-line) + (goto-char (point-min)) (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " =x=") + (buffer-substring-no-properties (point-min) (point-max))))))) + +(ert-deftest test-org-babel/inline-src_blk-results-verbatim () + (with-temp-buffer + + (let ((test-line "src_emacs-lisp[ :results verbatim ]{ \"x\" }")) + (insert test-line) + (goto-char (point-min)) (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " =\"x\"=") + (buffer-substring-no-properties (point-min) (point-max))))))) + (provide 'test-ob) ;;; test-ob ends here -- 1.7.3.4 --=-=-= Content-Type: text/plain Best, Martyn > > Thanks -- Eric > >> >> Regards >> >> Martyn >> >>> >>> Best -- Eric >> >> --=-=-=--