Browse Source

Fix tests wrt 2f53429413

* testing/lisp/test-ob.el (test-ob/inline-src_blk-default-results-replace-line-1)
(test-ob/just-one-results-block)
(test-ob/org-babel-remove-result--results-default)
(test-ob/specific-colnames): Fix tests.

* testing/lisp/test-ob-tangle.el (ob-tangle/comment-links-at-left-margin): Ditto.

* testing/lisp/test-ob-shell.el (ob-shell/generic-uses-no-arrays)
(ob-shell/bash-uses-arrays)
(ob-shell/generic-uses-no-assoc-arrays)
(ob-shell/bash-uses-assoc-arrays, ob-shell/simple-list): Ditto.

* testing/lisp/test-ob-exp.el (ob-exp/exports-inline)
(ob-exp/exports-inline-code): Ditto.

* testing/examples/ob-shell-test.org (Generic shell: no arrays)
(Bash shell: support for arrays)
(Generic shell: no special handing)
(Bash shell: support for associative arrays)
(Generic shell: no special handing)
(Bash shell: support for associative arrays with lists): Ditto.
Bastien 4 years ago
parent
commit
3e191242dc

+ 6 - 6
testing/examples/ob-shell-test.org

@@ -22,7 +22,7 @@
   :ID:       0ba56632-8dc1-405c-a083-c204bae477cf
   :ID:       0ba56632-8dc1-405c-a083-c204bae477cf
   :END:
   :END:
 ** Generic shell: no arrays
 ** Generic shell: no arrays
-#+begin_src sh :exports results :var array=sample_array
+#+begin_src sh :exports results :results output :var array=sample_array
 echo ${array}
 echo ${array}
 #+end_src
 #+end_src
 
 
@@ -34,7 +34,7 @@ Bash will see a simple indexed array. In this test, we check that the
 returned value is indeed only the first item of the array, as opposed to
 returned value is indeed only the first item of the array, as opposed to
 the generic serialiation that will return all elements of the array as 
 the generic serialiation that will return all elements of the array as 
 a single string.
 a single string.
-#+begin_src bash :exports results :var array=sample_array
+#+begin_src bash :exports results :results output :var array=sample_array
 echo ${array}
 echo ${array}
 #+end_src
 #+end_src
 
 
@@ -47,7 +47,7 @@ echo ${array}
   :END:
   :END:
 ** Generic shell: no special handing
 ** Generic shell: no special handing
 The shell will see all values as a single string.
 The shell will see all values as a single string.
-#+begin_src sh :exports results :var table=sample_mapping_table
+#+begin_src sh :exports results :results output :var table=sample_mapping_table
 echo ${table}
 echo ${table}
 #+end_src
 #+end_src
 
 
@@ -57,7 +57,7 @@ echo ${table}
 ** Bash shell: support for associative arrays
 ** Bash shell: support for associative arrays
 Bash will see a table that contains the first column as the 'index'
 Bash will see a table that contains the first column as the 'index'
 of the associative array, and the second column as the value.
 of the associative array, and the second column as the value.
-#+begin_src bash :exports results :var table=sample_mapping_table
+#+begin_src bash :exports :results output results :var table=sample_mapping_table
 echo ${table[second]}
 echo ${table[second]}
 #+end_src
 #+end_src
 
 
@@ -69,7 +69,7 @@ echo ${table[second]}
   :ID:       82320a48-3409-49d7-85c9-5de1c6d3ff87
   :ID:       82320a48-3409-49d7-85c9-5de1c6d3ff87
   :END:
   :END:
 ** Generic shell: no special handing
 ** Generic shell: no special handing
-#+begin_src sh :exports results :var table=sample_big_table
+#+begin_src sh :exports results :results output :var table=sample_big_table
 echo ${table}
 echo ${table}
 #+end_src
 #+end_src
 
 
@@ -79,7 +79,7 @@ echo ${table}
 ** Bash shell: support for associative arrays with lists
 ** Bash shell: support for associative arrays with lists
 Bash will see an associative array that contains each row as a single
 Bash will see an associative array that contains each row as a single
 string. Bash cannot handle lists in associative arrays.
 string. Bash cannot handle lists in associative arrays.
-#+begin_src bash :exports results :var table=sample_big_table
+#+begin_src bash :exports results :results output :var table=sample_big_table
 echo ${table[spaghetti]}
 echo ${table[spaghetti]}
 #+end_src
 #+end_src
 
 

+ 4 - 4
testing/lisp/test-ob-exp.el

@@ -190,9 +190,9 @@ a table."
 (ert-deftest ob-exp/exports-inline ()
 (ert-deftest ob-exp/exports-inline ()
   (should
   (should
    (string-match
    (string-match
-    (regexp-quote "Here is one in the middle {{{results(=1=)}}} of a line.
-Here is one at the end of a line. {{{results(=2=)}}}
-{{{results(=3=)}}} Here is one at the beginning of a line.")
+    (regexp-quote "Here is one in the middle {{{results(=0=)}}} of a line.
+Here is one at the end of a line. {{{results(=0=)}}}
+{{{results(=0=)}}} Here is one at the beginning of a line.")
     (org-test-at-id "54cb8dc3-298c-4883-a933-029b3c9d4b18"
     (org-test-at-id "54cb8dc3-298c-4883-a933-029b3c9d4b18"
       (org-narrow-to-subtree)
       (org-narrow-to-subtree)
       (let ((org-babel-inline-result-wrap "=%s="))
       (let ((org-babel-inline-result-wrap "=%s="))
@@ -252,7 +252,7 @@ Here is one at the end of a line. {{{results(=2=)}}}
      (regexp-quote "Here is one in the middle src_sh[]{echo 1} of a line.
      (regexp-quote "Here is one in the middle src_sh[]{echo 1} of a line.
 Here is one at the end of a line. src_sh[]{echo 2}
 Here is one at the end of a line. src_sh[]{echo 2}
 src_sh[]{echo 3} Here is one at the beginning of a line.
 src_sh[]{echo 3} Here is one at the beginning of a line.
-Here is one that is also evaluated: src_sh[]{echo 4} {{{results(=4=)}}}")
+Here is one that is also evaluated: src_sh[]{echo 4} {{{results(=0=)}}}")
      nil t)
      nil t)
     (org-test-at-id "cd54fc88-1b6b-45b6-8511-4d8fa7fc8076"
     (org-test-at-id "cd54fc88-1b6b-45b6-8511-4d8fa7fc8076"
       (org-narrow-to-subtree)
       (org-narrow-to-subtree)

+ 24 - 20
testing/lisp/test-ob-shell.el

@@ -52,55 +52,59 @@ ob-comint.el, which was not previously tested."
   "No arrays for generic"
   "No arrays for generic"
   (org-test-at-id "0ba56632-8dc1-405c-a083-c204bae477cf"
   (org-test-at-id "0ba56632-8dc1-405c-a083-c204bae477cf"
     (org-babel-next-src-block)
     (org-babel-next-src-block)
-    (should (equal "one two three" (org-babel-execute-src-block)))))
+    (should (equal "one two three" (org-trim (org-babel-execute-src-block))))))
 
 
 (ert-deftest ob-shell/bash-uses-arrays ()
 (ert-deftest ob-shell/bash-uses-arrays ()
   "Bash arrays"
   "Bash arrays"
   (org-test-at-id "0ba56632-8dc1-405c-a083-c204bae477cf"
   (org-test-at-id "0ba56632-8dc1-405c-a083-c204bae477cf"
     (org-babel-next-src-block 2)
     (org-babel-next-src-block 2)
-    (should (equal "one" (org-babel-execute-src-block)))))
+    (should (equal "one" (org-trim (org-babel-execute-src-block))))))
 
 
 (ert-deftest ob-shell/generic-uses-no-assoc-arrays ()
 (ert-deftest ob-shell/generic-uses-no-assoc-arrays ()
   "No associative arrays for generic"
   "No associative arrays for generic"
   (should
   (should
    (equal "first one second two third three"
    (equal "first one second two third three"
-	  (org-test-at-id "bec1a5b0-4619-4450-a8c0-2a746b44bf8d"
-	    (org-babel-next-src-block)
-	    (org-babel-execute-src-block))))
+	  (org-test-at-id
+	   "bec1a5b0-4619-4450-a8c0-2a746b44bf8d"
+	   (org-babel-next-src-block)
+	   (org-trim (org-babel-execute-src-block)))))
   (should
   (should
    (equal "bread 2 kg spaghetti 20 cm milk 50 dl"
    (equal "bread 2 kg spaghetti 20 cm milk 50 dl"
-	  (org-test-at-id "82320a48-3409-49d7-85c9-5de1c6d3ff87"
-	    (org-babel-next-src-block)
-	    (org-babel-execute-src-block)))))
+	  (org-test-at-id
+	   "82320a48-3409-49d7-85c9-5de1c6d3ff87"
+	   (org-babel-next-src-block)
+	   (org-trim (org-babel-execute-src-block))))))
 
 
 (ert-deftest ob-shell/bash-uses-assoc-arrays ()
 (ert-deftest ob-shell/bash-uses-assoc-arrays ()
   "Bash associative arrays"
   "Bash associative arrays"
   (should
   (should
    (equal "two"
    (equal "two"
-	  (org-test-at-id "bec1a5b0-4619-4450-a8c0-2a746b44bf8d"
-	    (org-babel-next-src-block 2)
-	    (org-babel-execute-src-block))))
+	  (org-test-at-id
+	   "bec1a5b0-4619-4450-a8c0-2a746b44bf8d"
+	   (org-babel-next-src-block 2)
+	   (org-trim (org-babel-execute-src-block)))))
   ;; Bash associative arrays as strings for the row.
   ;; Bash associative arrays as strings for the row.
   (should
   (should
    (equal "20 cm"
    (equal "20 cm"
-	  (org-test-at-id "82320a48-3409-49d7-85c9-5de1c6d3ff87"
-	    (org-babel-next-src-block 2)
-	    (org-babel-execute-src-block)))))
+	  (org-test-at-id
+	   "82320a48-3409-49d7-85c9-5de1c6d3ff87"
+	   (org-babel-next-src-block 2)
+	   (org-trim (org-babel-execute-src-block))))))
 
 
 (ert-deftest ob-shell/simple-list ()
 (ert-deftest ob-shell/simple-list ()
   "Test list variables in shell."
   "Test list variables in shell."
   ;; With bash, a list is turned into an array.
   ;; With bash, a list is turned into an array.
   (should
   (should
-   (= 2
-      (org-test-with-temp-text
-	  "#+BEGIN_SRC bash :var l='(1 2)\necho ${l[1]}\n#+END_SRC"
-	(org-babel-execute-src-block))))
+   (equal "2"
+	  (org-test-with-temp-text
+	   "#+BEGIN_SRC bash :results output :var l='(1 2)\necho ${l[1]}\n#+END_SRC"
+	   (org-trim (org-babel-execute-src-block)))))
   ;; On sh, it is a string containing all values.
   ;; On sh, it is a string containing all values.
   (should
   (should
    (equal "1 2"
    (equal "1 2"
 	  (org-test-with-temp-text
 	  (org-test-with-temp-text
-	      "#+BEGIN_SRC sh :var l='(1 2)\necho ${l}\n#+END_SRC"
-	    (org-babel-execute-src-block)))))
+	   "#+BEGIN_SRC sh :results output :var l='(1 2)\necho ${l}\n#+END_SRC"
+	   (org-trim (org-babel-execute-src-block))))))
 
 
 (provide 'test-ob-shell)
 (provide 'test-ob-shell)
 
 

+ 1 - 1
testing/lisp/test-ob-tangle.el

@@ -87,7 +87,7 @@
     (regexp-quote "# [[https://orgmode.org][Org mode]]")
     (regexp-quote "# [[https://orgmode.org][Org mode]]")
     (org-test-with-temp-text-in-file
     (org-test-with-temp-text-in-file
         "[[https://orgmode.org][Org mode]]
         "[[https://orgmode.org][Org mode]]
-#+header: :comments org :tangle \"test-ob-tangle.sh\"
+#+header: :comments org :results output :tangle \"test-ob-tangle.sh\"
 #+begin_src sh
 #+begin_src sh
 echo 1
 echo 1
 #+end_src"
 #+end_src"

+ 5 - 5
testing/lisp/test-ob.el

@@ -277,7 +277,7 @@ at the beginning of a line."
 	(org-babel-execute-src-block)))))
 	(org-babel-execute-src-block)))))
 
 
 (ert-deftest test-ob/inline-src_blk-default-results-replace-line-1 ()
 (ert-deftest test-ob/inline-src_blk-default-results-replace-line-1 ()
-  (let ((test-line "src_sh{echo 1}")
+  (let ((test-line "src_sh[:results output]{echo 1}")
 	(org-babel-inline-result-wrap "=%s="))
 	(org-babel-inline-result-wrap "=%s="))
     ;; src_ at bol line 1...
     ;; src_ at bol line 1...
     (org-test-with-temp-text
     (org-test-with-temp-text
@@ -548,7 +548,7 @@ echo \"[[file:./cv.cls]]\"
 (ert-deftest test-ob/just-one-results-block ()
 (ert-deftest test-ob/just-one-results-block ()
   "Test that evaluating two times the same code block does not result in a
   "Test that evaluating two times the same code block does not result in a
 duplicate results block."
 duplicate results block."
-  (org-test-with-temp-text "#+begin_src sh\necho Hello\n#+end_src\n"
+  (org-test-with-temp-text "#+begin_src sh :results output\necho Hello\n#+end_src\n"
     (org-babel-execute-src-block)
     (org-babel-execute-src-block)
     (org-babel-execute-src-block)     ; second code block execution
     (org-babel-execute-src-block)     ; second code block execution
     (should (search-forward "Hello")) ; the string inside the source code block
     (should (search-forward "Hello")) ; the string inside the source code block
@@ -1055,7 +1055,7 @@ x
 #+end_src
 #+end_src
 
 
 * next heading")))
 * next heading")))
-	  '("sh" "emacs-lisp")))
+	  '("emacs-lisp")))
 
 
 (ert-deftest test-ob/org-babel-results-indented-wrap ()
 (ert-deftest test-ob/org-babel-results-indented-wrap ()
   "Ensure that wrapped results are inserted correction when indented.
   "Ensure that wrapped results are inserted correction when indented.
@@ -1487,7 +1487,7 @@ Paragraph"
 |  1 | bar  |
 |  1 | bar  |
 |  2 | baz  |
 |  2 | baz  |
 
 
-#+begin_src sh :var data=input-table :exports results :colnames '(Rev Author)
+#+begin_src sh :var data=input-table :results table :exports results :colnames '(Rev Author)
 echo \"$data\"
 echo \"$data\"
 #+end_src
 #+end_src
 
 
@@ -1504,7 +1504,7 @@ echo \"$data\"
 |  1 | bar  |
 |  1 | bar  |
 |  2 | baz  |
 |  2 | baz  |
 
 
-#+begin_src sh :var data=input-table :exports results :colnames '(Rev Author)
+#+begin_src sh :var data=input-table :results table :exports results :colnames '(Rev Author)
 echo \"$data\"
 echo \"$data\"
 #+end_src
 #+end_src
 "
 "