test-ob-shell.el: Skip based on feature detection

* testing/lisp/test-ob-shell.el (test-ob-shell/bash-uses-assoc-arrays)
(test-ob-shell/bash-uses-assoc-arrays-with-lists): Use feature detection
shell command instead of version comparison to skip tests for
associative arrays.

It affects macOS since Apple ships BASH 3.2 licensed as GPLv2.
This commit is contained in:
Max Nikulin 2024-05-02 17:09:10 +07:00 committed by Ihor Radchenko
parent dd12e9c763
commit ac7c5c5d88
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 7 additions and 13 deletions

View File

@ -230,6 +230,10 @@ echo ${table}
Bash will see a table that contains the first column as the
'index' of the associative array, and the second column as the
value. "
(skip-unless
;; Old GPLv2 BASH in macOSX does not support associative arrays.
(if-let ((bash (executable-find "bash")))
(eq 0 (process-file bash nil nil nil "-c" "declare -A assoc_array"))))
(org-test-with-temp-text
"#+NAME: sample_mapping_table
| first | one |
@ -240,13 +244,6 @@ 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))))))
@ -256,13 +253,10 @@ 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)))
;; Old GPLv2 BASH in macOSX does not support associative arrays.
(if-let ((bash (executable-find "bash")))
(eq 0 (process-file bash nil nil nil "-c" "declare -A assoc_array"))))
(org-test-with-temp-text
"#+NAME: sample_big_table
| bread | 2 | kg |