emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] test-ob-shell.el: Skip based on feature detection
Date: Thu, 2 May 2024 17:20:39 +0700	[thread overview]
Message-ID: <v0vpdn$bhl$1@ciao.gmane.io> (raw)
In-Reply-To: <871q6pk4x3.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 273 bytes --]

On 28/04/2024 20:11, Ihor Radchenko wrote:
>>> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e4ab416fc

> Max Nikulin <manikulin@gmail.com> writes:
>> Feature detection should be more reliable.
[...]
> 
> Feel free to submit a patch.

See the attachment.

[-- Attachment #2: 0001-test-ob-shell.el-Skip-based-on-feature-detection.patch --]
[-- Type: text/x-patch, Size: 2781 bytes --]

From 46db53cebef5644be4abd8dcb18ca777ec0c3be3 Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@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


  reply	other threads:[~2024-05-02 10:21 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08 21:08 columnview dynamic block - different time summing behaviour for EFFORT and CLOCKSUM Alexander Adolf
2024-04-11 13:44 ` Ihor Radchenko
2024-04-12 12:13   ` Alexander Adolf
2024-04-13 14:19     ` Ihor Radchenko
2024-04-13 16:37       ` Alexander Adolf
2024-04-13 16:55         ` Ihor Radchenko
2024-04-15 16:46           ` Alexander Adolf
2024-04-19 10:49             ` Ihor Radchenko
2024-04-19 15:35               ` Alexander Adolf
2024-04-19 17:09                 ` Ihor Radchenko
2024-04-20 14:30                   ` Alexander Adolf
2024-04-21 13:42                     ` Ihor Radchenko
2024-04-22 20:41                       ` Alexander Adolf
2024-04-23 11:28                         ` Ihor Radchenko
2024-04-23 16:27                           ` Alexander Adolf
2024-04-23 16:35                             ` Ihor Radchenko
2024-04-24 17:29                               ` Alexander Adolf
2024-04-26 12:21                                 ` Ihor Radchenko
2024-04-26 12:38                                   ` Bastien Guerry
2024-04-26 12:47                                     ` Ihor Radchenko
2024-04-26 16:07                                       ` Alexander Adolf
2024-04-28 13:13                                         ` Ihor Radchenko
2024-04-19 17:26               ` Alexander Adolf
2024-04-24 10:51             ` FAILED test-ob-shell/bash-uses-assoc-arrays Max Nikulin
2024-04-24 12:54               ` Ihor Radchenko
2024-04-24 16:04                 ` Max Nikulin
2024-04-26 11:08                   ` Ihor Radchenko
2024-04-26 16:41                     ` Max Nikulin
2024-04-28 13:11                       ` Ihor Radchenko
2024-05-02 10:20                         ` Max Nikulin [this message]
2024-05-02 12:57                           ` [PATCH] test-ob-shell.el: Skip based on feature detection Ihor Radchenko
2024-05-02 12:09             ` columnview dynamic block - different time summing behaviour for EFFORT and CLOCKSUM Ihor Radchenko
2024-05-02 12:36               ` Alexander Adolf
2024-05-02 12:59                 ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='v0vpdn$bhl$1@ciao.gmane.io' \
    --to=manikulin@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).