guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] unit-tests/logging.logger: Bugfix: Use "mkstemp!" with Guile 2


From: Artyom V. Poptsov
Subject: [PATCH] unit-tests/logging.logger: Bugfix: Use "mkstemp!" with Guile 2
Date: Mon, 29 Apr 2024 11:34:28 +0300

When tests are run with Guile 2 "logging.logger.scm" would always fail
due to undefined reference to "mkstemp" that was introduced only in
Guile 3.  In Guile 2 the procedure is called "mkstemp!".  This patch
fixes that by adding an additional runtime check.

* unit-tests/logging.logger.scm (call-with-temporary-file): Bugfix:
  Check Guile major version and use "mkstemp!" when Guile 2 is used;
  use "mkstemp" otherwise.
---
 unit-tests/logging.logger.scm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/unit-tests/logging.logger.scm b/unit-tests/logging.logger.scm
index c69a86d..29a3b70 100644
--- a/unit-tests/logging.logger.scm
+++ b/unit-tests/logging.logger.scm
@@ -3,6 +3,7 @@
 ;;;    Copyright (C) 2003 Richard Todd
 ;;;    Copyright (C) 2024 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;    Copyright (C) 2024 David Pirotte <david@altosw.be>
+;;;    Copyright (C) 2024 Artyom V. Poptsov <poptsov.artyom@gmail.com>
 
 ;;;    This program is free software; you can redistribute it and/or modify
 ;;;    it under the terms of the GNU General Public License as published by
@@ -28,7 +29,10 @@
 (define* (call-with-temporary-file proc #:key (mode "w+"))
   "Open a temporary file name and pass it to PROC, a procedure of one
 argument.  The port is automatically closed."
-  (let ((port (mkstemp "/tmp/file-XXXXXX" mode)))
+  (let* ((file-name "/tmp/file-XXXXXX")
+         (port (if (< (string->number (major-version)) 3)
+                   (mkstemp! (string-copy file-name mode))
+                   (mkstemp file-name mode))))
     (call-with-port port proc)))
 
 (define-class <test-logging> (<test-case>))

base-commit: 0e2b6b0ae5cc43c98075386bb4c69defb705f3b3
-- 
2.41.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]