Subject: [PATCH] Fix some tests on OpenBSD
From: Manuel Giraud <[email-masked]>
To: [email-masked]
Date: Thu, 07 Aug 2025 15:21:29 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

Hi,

Here is a patch to fix some of the failing tests on OpenBSD.

In GNU Emacs 31.0.50 (build 9, x86_64-unknown-openbsd7.7) of 2025-08-06
 built on computer
Repository revision: f0da94e2c28fe79b2bb6f16697438fbf3777ebb8
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101018
System Description: OpenBSD computer 7.7 GENERIC.MP#78 amd64

Configured using:
 'configure CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib
 MAKEINFO=gmakeinfo --prefix=/home/manuel/emacs
 --bindir=/home/manuel/bin --with-x-toolkit=no
 --with-toolkit-scroll-bars=no --without-cairo --without-dbus
 --without-gconf --without-gsettings --without-compress-install'

From 7fd23b3d6161b995c2f512a439d8e2180de94c1e Mon Sep 17 00:00:00 2001
From: Manuel Giraud <[email-masked]>
Date: Thu, 7 Aug 2025 15:00:58 +0200
Subject: [PATCH] Fix some tests on OpenBSD

* test/lisp/eshell/em-script-tests.el
(em-script-test/batch-file/shebang): env -S is not supported.
* test/src/fns-tests.el (fns-tests-random): random is
non-deterministic.
---
 test/lisp/eshell/em-script-tests.el | 5 ++++-
 test/src/fns-tests.el               | 6 +++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/test/lisp/eshell/em-script-tests.el b/test/lisp/eshell/em-script-tests.el
index 01dc5fd9a72..30b917baa35 100644
--- a/test/lisp/eshell/em-script-tests.el
+++ b/test/lisp/eshell/em-script-tests.el
@@ -143,7 +143,10 @@ em-script-test/batch-file
 
 (ert-deftest em-script-test/batch-file/shebang ()
   "Test running an Eshell script file as a batch script via a shebang."
-  (skip-unless (not (memq system-type '(windows-nt ms-dos))))
+  (skip-when (or (memq system-type '(windows-nt ms-dos))
+                 ;; OpenBSD's env does not support -S
+                 (and (eq system-type 'berkeley-unix)
+                      (string-match-p "openbsd" system-configuration))))
   (ert-with-temp-file temp-file
     :text (format
            "#!/usr/bin/env -S %s --batch -f eshell-batch-file\necho hi"
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el
index 6a50d89c778..6f0155cd5df 100644
--- a/test/src/fns-tests.el
+++ b/test/src/fns-tests.el
@@ -38,7 +38,11 @@ fns-tests-random
         (should (= (random 1) 0))
         (should (>= (random 10) 0))
         (should (< (random 10) 10))
-        (should (equal (random "seed") (random "seed")))
+        ;; On OpenBSD random is non-deterministic.
+        (if (and (eq system-type 'berkeley-unix)
+                 (string-match-p "openbsd" system-configuration))
+            (should (not (equal (random "seed") (random "seed"))))
+          (should (equal (random "seed") (random "seed"))))
         ;; The probability of four calls being the same is low.
         ;; This makes sure that the value isn't constant.
         (should (not (= (random t) (random t) (random t) (random t))))
-- 
2.50.1

-- 
Manuel Giraud