aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2020-10-16 16:51:25 +0200
committerMichael Albinus2020-10-16 16:51:25 +0200
commit6a2f56db4e602372e33f35326a73cffa03586479 (patch)
treea0d6b0627081553722dacdfb9984d64377856820
parent8ca0b14b1c3b24aa023b239b9f91a89e287dbee0 (diff)
downloademacs-6a2f56db4e602372e33f35326a73cffa03586479.tar.gz
emacs-6a2f56db4e602372e33f35326a73cffa03586479.zip
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.
-rw-r--r--test/lisp/net/tramp-archive-tests.el46
1 files changed, 44 insertions, 2 deletions
diff --git a/test/lisp/net/tramp-archive-tests.el b/test/lisp/net/tramp-archive-tests.el
index 4750852f786..988288c045d 100644
--- a/test/lisp/net/tramp-archive-tests.el
+++ b/test/lisp/net/tramp-archive-tests.el
@@ -32,6 +32,49 @@
32(defvar tramp-copy-size-limit) 32(defvar tramp-copy-size-limit)
33(defvar tramp-persistency-file-name) 33(defvar tramp-persistency-file-name)
34 34
35;; `ert-resource-file' was introduced in Emacs 28.1.
36(unless (macrop 'ert-resource-file)
37 (eval-and-compile
38 (defvar ert-resource-directory-format "%s-resources/"
39 "Format for `ert-resource-directory'.")
40 (defvar ert-resource-directory-trim-left-regexp ""
41 "Regexp for `string-trim' (left) used by `ert-resource-directory'.")
42 (defvar ert-resource-directory-trim-right-regexp "\\(-tests?\\)?\\.el"
43 "Regexp for `string-trim' (right) used by `ert-resource-directory'.")
44
45 (defmacro ert-resource-directory ()
46 "Return absolute file name of the resource directory for this file.
47
48The path to the resource directory is the \"resources\" directory
49in the same directory as the test file.
50
51If that directory doesn't exist, use the directory named like the
52test file but formatted by `ert-resource-directory-format' and trimmed
53using `string-trim' with arguments
54`ert-resource-directory-trim-left-regexp' and
55`ert-resource-directory-trim-right-regexp'. The default values mean
56that if called from a test file named \"foo-tests.el\", return
57the absolute file name for \"foo-resources\"."
58 `(let* ((testfile ,(or (bound-and-true-p byte-compile-current-file)
59 (and load-in-progress load-file-name)
60 buffer-file-name))
61 (default-directory (file-name-directory testfile)))
62 (file-truename
63 (if (file-accessible-directory-p "resources/")
64 (expand-file-name "resources/")
65 (expand-file-name
66 (format
67 ert-resource-directory-format
68 (string-trim testfile
69 ert-resource-directory-trim-left-regexp
70 ert-resource-directory-trim-right-regexp)))))))
71
72 (defmacro ert-resource-file (file)
73 "Return file name of resource file named FILE.
74A resource file is in the resource directory as per
75`ert-resource-directory'."
76 `(expand-file-name ,file (ert-resource-directory)))))
77
35(defconst tramp-archive-test-file-archive (ert-resource-file "foo.tar.gz") 78(defconst tramp-archive-test-file-archive (ert-resource-file "foo.tar.gz")
36 "The test file archive.") 79 "The test file archive.")
37 80
@@ -46,8 +89,7 @@ Do not hexlify \"/\". This hexlified string is used in `file:///' URLs."
46 "The test archive.") 89 "The test archive.")
47 90
48(defconst tramp-archive-test-directory 91(defconst tramp-archive-test-directory
49 (file-truename 92 (file-truename (ert-resource-file "foo.iso"))
50 (ert-resource-file "foo.iso"))
51 "A directory file name, which looks like an archive.") 93 "A directory file name, which looks like an archive.")
52 94
53(setq password-cache-expiry nil 95(setq password-cache-expiry nil