On 28/04/2024 20:11, Ihor Radchenko wrote:
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e4ab416fc
Max Nikulin <maniku...@gmail.com> writes:
Feature detection should be more reliable.
[...]
Feel free to submit a patch.
See the attachment.
From 46db53cebef5644be4abd8dcb18ca777ec0c3be3 Mon Sep 17 00:00:00 2001
From: Max Nikulin <maniku...@gmail.com>
Date: Thu, 2 May 2024 17:09:10 +0700
Subject: [PATCH] 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.
---
testing/lisp/test-ob-shell.el | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el
index f58e85815..b760031b4 100644
--- a/testing/lisp/test-ob-shell.el
+++ b/testing/lisp/test-ob-shell.el
@@ -230,6 +230,10 @@ (ert-deftest test-ob-shell/bash-uses-assoc-arrays ()
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 @@ (ert-deftest test-ob-shell/bash-uses-assoc-arrays ()
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 @@ (ert-deftest test-ob-shell/bash-uses-assoc-arrays-with-lists ()
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 |
--
2.39.2