emacs-diffs
[Top][All Lists]
Advanced

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

master 6a2f56d: Make last change in tramp-archive-tests.el backward comp


From: Michael Albinus
Subject: master 6a2f56d: Make last change in tramp-archive-tests.el backward compatible
Date: Fri, 16 Oct 2020 10:51:34 -0400 (EDT)

branch: master
commit 6a2f56db4e602372e33f35326a73cffa03586479
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Make last change in tramp-archive-tests.el backward compatible
    
    * test/lisp/net/tramp-archive-tests.el (ert-resource-directory-format)
    (ert-resource-directory-trim-left-regexp)
    (ert-resource-directory-trim-right-regexp, ert-resource-directory)
    (ert-resource-file): Define if they don't exist.
---
 test/lisp/net/tramp-archive-tests.el | 46 ++++++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/test/lisp/net/tramp-archive-tests.el 
b/test/lisp/net/tramp-archive-tests.el
index 4750852..988288c 100644
--- a/test/lisp/net/tramp-archive-tests.el
+++ b/test/lisp/net/tramp-archive-tests.el
@@ -32,6 +32,49 @@
 (defvar tramp-copy-size-limit)
 (defvar tramp-persistency-file-name)
 
+;; `ert-resource-file' was introduced in Emacs 28.1.
+(unless (macrop 'ert-resource-file)
+  (eval-and-compile
+    (defvar ert-resource-directory-format "%s-resources/"
+      "Format for `ert-resource-directory'.")
+    (defvar ert-resource-directory-trim-left-regexp ""
+      "Regexp for `string-trim' (left) used by `ert-resource-directory'.")
+    (defvar ert-resource-directory-trim-right-regexp "\\(-tests?\\)?\\.el"
+      "Regexp for `string-trim' (right) used by `ert-resource-directory'.")
+
+    (defmacro ert-resource-directory ()
+      "Return absolute file name of the resource directory for this file.
+
+The path to the resource directory is the \"resources\" directory
+in the same directory as the test file.
+
+If that directory doesn't exist, use the directory named like the
+test file but formatted by `ert-resource-directory-format' and trimmed
+using `string-trim' with arguments
+`ert-resource-directory-trim-left-regexp' and
+`ert-resource-directory-trim-right-regexp'.  The default values mean
+that if called from a test file named \"foo-tests.el\", return
+the absolute file name for \"foo-resources\"."
+      `(let* ((testfile ,(or (bound-and-true-p byte-compile-current-file)
+                             (and load-in-progress load-file-name)
+                             buffer-file-name))
+              (default-directory (file-name-directory testfile)))
+        (file-truename
+         (if (file-accessible-directory-p "resources/")
+              (expand-file-name "resources/")
+            (expand-file-name
+             (format
+             ert-resource-directory-format
+              (string-trim testfile
+                          ert-resource-directory-trim-left-regexp
+                          ert-resource-directory-trim-right-regexp)))))))
+
+    (defmacro ert-resource-file (file)
+      "Return file name of resource file named FILE.
+A resource file is in the resource directory as per
+`ert-resource-directory'."
+      `(expand-file-name ,file (ert-resource-directory)))))
+
 (defconst tramp-archive-test-file-archive (ert-resource-file "foo.tar.gz")
   "The test file archive.")
 
@@ -46,8 +89,7 @@ Do not hexlify \"/\".  This hexlified string is used in 
`file:///' URLs."
   "The test archive.")
 
 (defconst tramp-archive-test-directory
-  (file-truename
-   (ert-resource-file "foo.iso"))
+  (file-truename (ert-resource-file "foo.iso"))
   "A directory file name, which looks like an archive.")
 
 (setq password-cache-expiry nil



reply via email to

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