Only run Bash tests when relevant features are supported

* testing/lisp/test-ob-shell.el (test-ob-shell/bash-uses-arrays): Do
not run when Bash is not available.
(test-ob-shell/bash-uses-assoc-arrays):
(test-ob-shell/bash-uses-assoc-arrays-with-lists): Do not run when
Bash is not available or has <4.0 version without associative array
support.

Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://orgmode.org/list/ef03d3ca-a184-4398-8edb-35f84b48e850@gmail.com
This commit is contained in:
Ihor Radchenko 2024-04-26 14:02:06 +03:00
parent 510e8f9cc8
commit e4ab416fcc
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 15 additions and 0 deletions

View File

@ -183,6 +183,7 @@ that will return all elements of the array as a single string."
echo ${array}
<point>
#+end_src"
(skip-unless (executable-find "bash"))
(should (equal "one" (org-trim (org-babel-execute-src-block))))))
(ert-deftest test-ob-shell/generic-uses-no-assoc-arrays-simple-map ()
@ -239,6 +240,13 @@ value. "
echo ${table[second]}
<point>
#+end_src "
(skip-unless (executable-find "bash"))
(skip-unless
(let* ((version-string (shell-command-to-string "bash -c 'echo $BASH_VERSION'"))
(major-version (and (string-match "^\\([0-9]+\\)\\." version-string)
(string-to-number (match-string 1 version-string)))))
;; Bash 4.0 introduced associative arrays support.
(>= major-version 4)))
(should
(equal "two"
(org-trim (org-babel-execute-src-block))))))
@ -248,6 +256,13 @@ echo ${table[second]}
Bash will see an associative array that contains each row as a single
string. Bash cannot handle lists in associative arrays."
(skip-unless (executable-find "bash"))
(skip-unless
(let* ((version-string (shell-command-to-string "bash -c 'echo $BASH_VERSION'"))
(major-version (and (string-match "^\\([0-9]+\\)\\." version-string)
(string-to-number (match-string 1 version-string)))))
;; Bash 4.0 introduced associative arrays support.
(>= major-version 4)))
(org-test-with-temp-text
"#+NAME: sample_big_table
| bread | 2 | kg |