]> git.eshelyaron.com Git - emacs.git/commitdiff
Use new resource directory macros in tests (Bug#43792)
authorStefan Kangas <stefan@marxist.se>
Thu, 24 Sep 2020 00:05:58 +0000 (02:05 +0200)
committerStefan Kangas <stefan@marxist.se>
Fri, 16 Oct 2020 09:28:09 +0000 (11:28 +0200)
* test/lisp/bookmark-tests.el (bookmark-tests-data-dir):
* test/lisp/calendar/todo-mode-tests.el (todo-test-data-dir):
* test/lisp/net/dbus-tests.el (dbus--tests-dir):
* test/lisp/emacs-lisp/edebug-tests.el
(edebug-tests-sample-code-file):
* test/lisp/emacs-lisp/package-tests.el
(package-test-fake-contents-file):
* test/lisp/emacs-lisp/shadow-tests.el (shadow-tests-data-directory):
* test/lisp/emacs-lisp/testcover-tests.el
(testcover-tests-file-dir, testcover-tests-test-cases):
* test/lisp/mail/uudecode-tests.el (uudecode-tests-data-dir):
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test-resource-directory):
* test/lisp/pcmpl-linux-tests.el (pcmpl-linux-tests-data-dir):
* test/lisp/progmodes/cperl-mode-tests.el
(cperl-mode-tests-data-directory):
* test/lisp/progmodes/flymake-tests.el
(flymake-tests-data-directory):
* test/lisp/progmodes/ruby-mode-tests.el (ruby-mode-tests-data-dir):
* test/lisp/saveplace-tests.el (saveplace-tests-dir):
* test/lisp/textmodes/css-mode-tests.el (css-mode-tests-data-dir):
Remove.

* test/lisp/bookmark-tests.el (bookmark-tests-bookmark-file)
(bookmark-tests-example-file, bookmark-tests-bookmark-file-list):
* test/lisp/calendar/todo-mode-tests.el (todo-test-file-1)
(todo-test-archive-1, with-todo-test, todo-test--add-file):
* test/lisp/custom-tests.el (custom--test-theme-variables):
* test/lisp/net/dbus-tests.el (dbus--test-introspect):
* test/lisp/emacs-lisp/edebug-tests.el (edebug-tests-setup-code-file):
* test/lisp/emacs-lisp/package-tests.el (package-test-data-dir)
(package-test-desc-from-buffer, package-test-install-single)
(package-test-macro-compilation)
(package-test-install-prioritized)
(package-test-install-multifile, package-test-update-archives)
(package-test-update-archives-async)
(package-test-update-archives/ignore-nil-entry)
(package-test-signed, package-x-test-upload-buffer)
(package-x-test-upload-new-version):
* test/lisp/emacs-lisp/shadow-tests.el (shadow-case-insensitive):
* test/lisp/emacs-lisp/testcover-tests.el
(testcover-tests-build-test-cases):
* test/lisp/mail/uudecode-tests.el (uudecode-tests-encoded-str)
(uudecode-tests-decoded-str):
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test-file-archive)
(tramp-archive-test-directory):
* test/lisp/pcmpl-linux-tests.el (pcmpl-linux-test-fs-types)
(pcmpl-linux-test-mounted-directories):
* test/lisp/progmodes/cperl-mode-tests.el (cperl-mode-test-bug-10483)
(cperl-mode-test-indent-styles):
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture):
* test/lisp/progmodes/ruby-mode-tests.el
(ruby--indent/converted-from-manual-test):
* test/lisp/saveplace-tests.el
(saveplace-test-save-place-to-alist/dir)
(saveplace-test-load-alist-from-file):
* test/lisp/textmodes/css-mode-tests.el (css-mode-test-indent): Adjust
to use new resource directory macros.

17 files changed:
test/lisp/bookmark-tests.el
test/lisp/calendar/todo-mode-tests.el
test/lisp/custom-tests.el
test/lisp/emacs-lisp/edebug-tests.el
test/lisp/emacs-lisp/package-tests.el
test/lisp/emacs-lisp/shadow-tests.el
test/lisp/emacs-lisp/testcover-tests.el
test/lisp/mail/uudecode-tests.el
test/lisp/net/dbus-tests.el
test/lisp/net/tramp-archive-tests.el
test/lisp/pcmpl-linux-tests.el
test/lisp/progmodes/cperl-mode-tests.el
test/lisp/progmodes/flymake-tests.el
test/lisp/progmodes/ruby-mode-tests.el
test/lisp/saveplace-tests.el
test/lisp/textmodes/css-mode-tests.el
test/lisp/url/url-file-tests.el

index c5959e46d80547e6afe1bc78386213f277e18647..7cfd4ac14f124bd5787ed99b487dfd1785ef8621 100644 (file)
 ;;; Code:
 
 (require 'ert)
+(require 'ert-x)
 (require 'bookmark)
 (require 'cl-lib)
 
-(defvar bookmark-tests-data-dir
-  (file-truename
-   (expand-file-name "bookmark-resources/"
-                     (file-name-directory (or load-file-name
-                                              buffer-file-name))))
-  "Base directory of bookmark-tests.el data files.")
-
-(defvar bookmark-tests-bookmark-file
-  (expand-file-name "test.bmk" bookmark-tests-data-dir)
+(defvar bookmark-tests-bookmark-file (ert-resource-file "test.bmk")
   "Bookmark file used for testing.")
 
 (defvar bookmark-tests-example-file
   ;; We use abbreviate-file-name here to match the behavior of
   ;; `bookmark-buffer-file-name'.
-  (abbreviate-file-name (expand-file-name "example.txt" bookmark-tests-data-dir))
+  (abbreviate-file-name (ert-resource-file "example.txt"))
   "Example file used for testing.")
 
 ;; The values below should match `bookmark-tests-bookmark-file'.  We cache
@@ -83,8 +76,7 @@ the lexically-bound variable `buffer'."
           ,@body)
        (kill-buffer buffer))))
 
-(defvar bookmark-tests-bookmark-file-list
-  (expand-file-name "test-list.bmk" bookmark-tests-data-dir)
+(defvar bookmark-tests-bookmark-file-list (ert-resource-file "test-list.bmk")
   "Bookmark file used for testing a list of bookmarks.")
 
 ;; The values below should match `bookmark-tests-bookmark-file-list'
index 1fbd39478c5c025dae68fb6f889ef54d2721ade4..6ed55121988c5faf7c84c90b0cb66b958be07a01 100644 (file)
 (require 'ert-x)
 (require 'todo-mode)
 
-(defvar todo-test-data-dir
-  (file-truename
-   (expand-file-name "todo-mode-resources/"
-                     (file-name-directory (or load-file-name
-                                              buffer-file-name))))
-  "Base directory of todo-mode.el test data files.")
-
-(defvar todo-test-file-1 (expand-file-name "todo-test-1.todo"
-                                           todo-test-data-dir)
+(defvar todo-test-file-1 (ert-resource-file "todo-test-1.todo")
   "Todo mode test file.")
 
-(defvar todo-test-archive-1 (expand-file-name "todo-test-1.toda"
-                                              todo-test-data-dir)
+(defvar todo-test-archive-1 (ert-resource-file "todo-test-1.toda")
   "Todo Archive mode test file.")
 
 (defmacro with-todo-test (&rest body)
@@ -52,7 +43,7 @@
           (abbreviated-home-dir nil)
           (process-environment (cons (format "HOME=%s" todo-test-home)
                                      process-environment))
-          (todo-directory todo-test-data-dir)
+          (todo-directory (ert-resource-directory))
           (todo-default-todo-file (todo-short-file-name
                                   (car (funcall todo-files-function)))))
      (unwind-protect
@@ -815,7 +806,7 @@ buffer from which the editing command was invoked."
   "Add file FILE with category CAT to todo-files and show it.
 This provides a noninteractive API for todo-add-file for use in
 automatic testing."
-  (let ((file0 (file-truename (concat todo-test-data-dir file ".todo")))
+  (let ((file0 (ert-resource-file (concat file ".todo")))
         todo-add-item-if-new-category)  ; Don't need an item in cat.
     (cl-letf (((symbol-function 'todo-read-file-name)
                (lambda (_prompt) file0))
index 76661dc13b83be28f40de174a183f9d1ff93fe4a..a1451cf0ce69055480d5713b92725ad2e5a2ab3f 100644 (file)
@@ -20,6 +20,7 @@
 ;;; Code:
 
 (require 'ert)
+(require 'ert-x)
 
 (require 'wid-edit)
 (require 'cus-edit)
 (ert-deftest custom--test-theme-variables ()
   "Test variables setting with enabling / disabling a custom theme."
   ;; We load custom-resources/custom--test-theme.el.
-  (let ((custom-theme-load-path
-         `(,(expand-file-name
-            "custom-resources"
-            (expand-file-name "lisp" (getenv "EMACS_TEST_DIRECTORY"))))))
+  (let ((custom-theme-load-path `(,(ert-resource-directory))))
     (load-theme 'custom--test 'no-confirm 'no-enable)
     ;; The variables have still their initial values.
     (should (equal custom--test-user-option 'foo))
index 6db07b1b7078b433beabccd7195e72ed46137531..6993978ac58bc1d6f22b8b85cddeaf9df0709adb 100644 (file)
 (require 'edebug)
 (require 'kmacro)
 
-;; Use `eval-and-compile' because this is used by the macro
-;; `edebug-tests-deftest'.
-(eval-and-compile
-  (defvar edebug-tests-sample-code-file
-    (expand-file-name
-     "edebug-resources/edebug-test-code.el"
-     (file-name-directory (or (bound-and-true-p byte-compile-current-file)
-                              load-file-name
-                              buffer-file-name)))
-    "Name of file containing code samples for Edebug tests."))
-
 (defvar edebug-tests-temp-file nil
   "Name of temp file containing sample code stripped of stop point symbols.")
 (defvar edebug-tests-stop-points nil
@@ -344,7 +333,7 @@ evaluate to \"symbol\", \"symbol-1\", \"symbol-2\", etc."
 Write the loadable code to a buffer for TMPFILE, and set
 `edebug-tests-stop-points' to a map from defined symbols to stop
 point names to positions in the file."
-  (with-current-buffer (find-file-noselect edebug-tests-sample-code-file)
+  (with-current-buffer (find-file-noselect (ert-resource-file "edebug-test-code.el"))
     (let ((marked-up-code (buffer-string)))
       (with-temp-file tmpfile
         (insert marked-up-code))))
index cbb2410f953e78a402f419d85a73d89f13737fa5..155a8e6fce9a4ed2da06672fcebd6780ebd9dbc0 100644 (file)
@@ -39,6 +39,7 @@
 
 (require 'package)
 (require 'ert)
+(require 'ert-x)
 (require 'cl-lib)
 
 (setq package-menu-async nil)
                                (multi-file (0 1))))
   "`package-desc' used for testing dependencies.")
 
-(defvar package-test-data-dir (expand-file-name "package-resources" package-test-file-dir)
+(defvar package-test-data-dir (ert-resource-directory)
   "Base directory of package test files.")
 
-(defvar package-test-fake-contents-file
-  (expand-file-name "archive-contents" package-test-data-dir)
-  "Path to a static copy of \"archive-contents\".")
-
 (cl-defmacro with-package-test ((&optional &key file
                                            basedir
                                            install
@@ -215,20 +212,20 @@ Must called from within a `tar-mode' buffer."
 
 (ert-deftest package-test-desc-from-buffer ()
   "Parse an elisp buffer to get a `package-desc' object."
-  (with-package-test (:basedir "package-resources" :file "simple-single-1.3.el")
+  (with-package-test (:basedir (ert-resource-directory) :file "simple-single-1.3.el")
     (should (package-test--compatible-p
              (package-buffer-info) simple-single-desc 'kind)))
-  (with-package-test (:basedir "package-resources" :file "simple-depend-1.0.el")
+  (with-package-test (:basedir (ert-resource-directory) :file "simple-depend-1.0.el")
     (should (package-test--compatible-p
              (package-buffer-info) simple-depend-desc 'kind)))
-  (with-package-test (:basedir "package-resources"
+  (with-package-test (:basedir (ert-resource-directory)
                                :file "multi-file-0.2.3.tar")
     (tar-mode)
     (should (equal (package-tar-file-info) multi-file-desc))))
 
 (ert-deftest package-test-install-single ()
   "Install a single file without using an archive."
-  (with-package-test (:basedir "package-resources" :file "simple-single-1.3.el")
+  (with-package-test (:basedir (ert-resource-directory) :file "simple-single-1.3.el")
     (should (package-install-from-buffer))
     (package-initialize)
     (should (package-installed-p 'simple-single))
@@ -271,7 +268,7 @@ Must called from within a `tar-mode' buffer."
 
 (ert-deftest package-test-macro-compilation ()
   "Install a package which includes a dependency."
-  (with-package-test (:basedir "package-resources")
+  (with-package-test (:basedir (ert-resource-directory))
     (package-install-file (expand-file-name "macro-problem-package-1.0/"))
     (require 'macro-problem)
     ;; `macro-problem-func' uses a macro from `macro-aux'.
@@ -310,8 +307,7 @@ Must called from within a `tar-mode' buffer."
 (ert-deftest package-test-install-prioritized ()
   "Install a lower version from a higher-prioritized archive."
   (with-package-test ()
-    (let* ((newer-version (expand-file-name "package-resources/newer-versions"
-                                            package-test-file-dir))
+    (let* ((newer-version (ert-resource-file "newer-versions"))
            (package-archives `(("older" . ,package-test-data-dir)
                                ("newer" . ,newer-version)))
            (package-archive-priorities '(("older" . 100))))
@@ -326,7 +322,7 @@ Must called from within a `tar-mode' buffer."
 
 (ert-deftest package-test-install-multifile ()
   "Check properties of the installed multi-file package."
-  (with-package-test (:basedir "package-resources" :install '(multi-file))
+  (with-package-test (:basedir (ert-resource-directory) :install '(multi-file))
     (let ((autoload-file
            (expand-file-name "multi-file-autoloads.el"
                              (expand-file-name
@@ -472,8 +468,7 @@ Must called from within a `tar-mode' buffer."
       (package-menu-mark-install)
       (package-menu-execute)
       (should (package-installed-p 'simple-single))
-      (let ((package-test-data-dir
-             (expand-file-name "package-resources/newer-versions" package-test-file-dir)))
+      (let ((package-test-data-dir (ert-resource-file "newer-versions")))
         (setq package-archives `(("gnu" . ,package-test-data-dir)))
         (revert-buffer)
 
@@ -512,7 +507,7 @@ Must called from within a `tar-mode' buffer."
                  (when (re-search-forward "Server started, \\(.*\\)\n" nil t)
                    (setq addr (match-string 1))))
                addr)))
-          (with-package-test (:basedir package-test-data-dir :location addr)
+          (with-package-test (:basedir (ert-resource-directory) :location addr)
             (list-packages)
             (should package--downloads-in-progress)
             (should mode-line-process)
@@ -532,8 +527,7 @@ Must called from within a `tar-mode' buffer."
 (ert-deftest package-test-update-archives/ignore-nil-entry ()
   "Ignore any packages that are nil.  Test for Bug#28502."
   (with-package-test ()
-    (let* ((with-nil-entry (expand-file-name "package-resources/with-nil-entry"
-                                             package-test-file-dir))
+    (let* ((with-nil-entry (ert-resource-file "with-nil-entry"))
            (package-archives `(("with-nil-entry" . ,with-nil-entry))))
       (package-initialize)
       (package-refresh-contents)
@@ -634,8 +628,7 @@ Must called from within a `tar-mode' buffer."
                           prog-alist)))
                   (delete-directory homedir t))))
   (let* ((keyring (expand-file-name "key.pub" package-test-data-dir))
-        (package-test-data-dir
-          (expand-file-name "package-resources/signed" package-test-file-dir)))
+         (package-test-data-dir (ert-resource-file "signed")))
     (with-package-test ()
       (package-initialize)
       (package-import-keyring keyring)
@@ -696,7 +689,7 @@ Must called from within a `tar-mode' buffer."
 
 (ert-deftest package-x-test-upload-buffer ()
   "Test creating an \"archive-contents\" file"
-  (with-package-test (:basedir "package-resources"
+  (with-package-test (:basedir (ert-resource-directory)
                                :file "simple-single-1.3.el"
                                :upload-base t)
     (package-upload-buffer)
@@ -729,7 +722,7 @@ Must called from within a `tar-mode' buffer."
 
 (ert-deftest package-x-test-upload-new-version ()
   "Test uploading a new version of a package"
-  (with-package-test (:basedir "package-resources"
+  (with-package-test (:basedir (ert-resource-directory)
                                :file "simple-single-1.3.el"
                                :upload-base t)
     (package-upload-buffer)
index 219312a55783faacb07a029320ad66e6b21fa1eb..5d6215ab6f361a73550eb8d3c1616813054b37a5 100644 (file)
 ;;; Code:
 
 (require 'ert)
+(require 'ert-x)
 (require 'shadow)
 (eval-when-compile (require 'cl-lib))
 
-(defconst shadow-tests-data-directory
-  (expand-file-name "lisp/emacs-lisp/shadow-resources"
-                    (or (getenv "EMACS_TEST_DIRECTORY")
-                        (expand-file-name "../../.."
-                                          (or load-file-name
-                                              buffer-file-name))))
-  "Directory for shadow test files.")
-
 (ert-deftest shadow-case-insensitive ()
   "Test shadowing for case insensitive filenames."
   ;; Override `file-name-case-insensitive-p' so we test the same thing
   ;; regardless of what file system we're running on.
   (cl-letf (((symbol-function 'file-name-case-insensitive-p) (lambda (_f) t)))
-    (should (equal (list (expand-file-name "p1/foo" shadow-tests-data-directory)
-                         (expand-file-name "p2/FOO" shadow-tests-data-directory))
+    (should (equal (list (ert-resource-file "p1/foo")
+                         (ert-resource-file "p2/FOO"))
                    (load-path-shadows-find
-                    (list (expand-file-name "p1/" shadow-tests-data-directory)
-                          (expand-file-name "p2/" shadow-tests-data-directory))))))
+                    (list (ert-resource-file "p1/")
+                          (ert-resource-file "p2/"))))))
   (cl-letf (((symbol-function 'file-name-case-insensitive-p) (lambda (_f) nil)))
     (should-not (load-path-shadows-find
-                 (list (expand-file-name "p1/" shadow-tests-data-directory)
-                       (expand-file-name "p2/" shadow-tests-data-directory))))))
+                 (list (ert-resource-file "p1/")
+                       (ert-resource-file "p2/"))))))
 
 ;;; shadow-tests.el ends here.
index 6870d49acb260c7cc9222b2164b170308ff09df3..784367c287ecee27508191213019bbd34814e59c 100644 (file)
 ;;; Code:
 
 (require 'ert)
+(require 'ert-x)
 (require 'testcover)
 (require 'skeleton)
 
-;; Use `eval-and-compile' around all these definitions because they're
-;; used by the macro `testcover-tests-define-tests'.
-
-(eval-and-compile
-  (defvar testcover-tests-file-dir
-    (expand-file-name
-     "testcover-resources/"
-     (file-name-directory (or (bound-and-true-p byte-compile-current-file)
-                              load-file-name
-                              buffer-file-name)))
-    "Directory of the \"testcover-tests.el\" file."))
-
-(eval-and-compile
-  (defvar testcover-tests-test-cases
-    (expand-file-name "testcases.el" testcover-tests-file-dir)
-    "File containing marked up code to instrument and check."))
-
 ;; Convert Testcover's overlays to plain text.
 
 (eval-and-compile
@@ -149,7 +133,7 @@ Construct and return a list of `ert-deftest' forms.  See testcases.el
 for documentation of the test definition format."
     (let (results)
       (with-temp-buffer
-        (insert-file-contents testcover-tests-test-cases)
+        (insert-file-contents (ert-resource-file "testcases.el"))
         (goto-char (point-min))
         (while (re-search-forward
                 (concat "^;; ==== \\([^ ]+?\\) ====\n"
index 4c9650f556c002b2c163c87d205fdfb3eb05e06d..17566250a928c454c940ccad47c428d97ab1d05a 100644 (file)
 ;;; Code:
 
 (require 'ert)
+(require 'ert-x)
 (require 'uudecode)
 
-(defvar uudecode-tests-data-dir
-  (file-truename
-   (expand-file-name "uudecode-resources/"
-                     (file-name-directory (or load-file-name
-                                              buffer-file-name))))
-  "Base directory of uudecode-tests.el test data files.")
-
 (defun uudecode-tests-read-file (file)
   "Read contents of FILE and return as string."
   (with-temp-buffer
     (buffer-string)))
 
 (defvar uudecode-tests-encoded-str
-  (uudecode-tests-read-file
-   (expand-file-name "uuencoded.txt" uudecode-tests-data-dir))
+  (uudecode-tests-read-file (ert-resource-file "uuencoded.txt"))
   "Uuencoded data for bookmark-tests.el
 Same as `uudecode-tests-decoded-str' but uuencoded.")
 (defvar uudecode-tests-decoded-str
-  (uudecode-tests-read-file
-   (expand-file-name "uudecoded.txt" uudecode-tests-data-dir))
+  (uudecode-tests-read-file (ert-resource-file "uudecoded.txt"))
   "Plain text data for bookmark-tests.el
 Same as `uudecode-tests-encoded-str' but plain text.")
 
index 4d34a1afd0e9c371daeba19baac2ca67c5cdc953..2186d454aee00674490998f28c45981639e5eab1 100644 (file)
@@ -22,6 +22,7 @@
 ;;; Code:
 
 (require 'ert)
+(require 'ert-x)
 (require 'dbus)
 
 (defvar dbus-debug nil)
 (defconst dbus--test-interface "org.gnu.Emacs.TestDBus.Interface"
   "Test interface.")
 
-(defconst dbus--tests-dir
-  (file-truename
-   (expand-file-name "dbus-resources"
-                     (file-name-directory (or load-file-name
-                                              buffer-file-name))))
-  "Directory containing introspection test data file.")
-
 (defun dbus--test-availability (bus)
   "Test availability of D-Bus BUS."
   (should (dbus-list-names bus))
@@ -1555,7 +1549,7 @@ Subsequent pairs of the list are tested with `dbus-set-property'."
   (when (string-equal dbus--test-path (dbus-event-path-name last-input-event))
     (with-temp-buffer
       (insert-file-contents-literally
-       (expand-file-name "org.gnu.Emacs.TestDBus.xml" dbus--tests-dir))
+       (ert-resource-file "org.gnu.Emacs.TestDBus.xml"))
       (buffer-string))))
 
 (defsubst dbus--test-validate-interface
index 9a2319126a907fb80f99094523dda05fc9a579f6..4750852f786b83019d1b231e9a0e5000f436b7c8 100644 (file)
 ;; tests in tramp-tests.el.
 
 (require 'ert)
+(require 'ert-x)
 (require 'tramp-archive)
 (defvar tramp-copy-size-limit)
 (defvar tramp-persistency-file-name)
 
-(defconst tramp-archive-test-resource-directory
-  (let ((default-directory
-         (if load-in-progress
-             (file-name-directory load-file-name)
-           default-directory)))
-    (cond
-     ((file-accessible-directory-p (expand-file-name "resources"))
-      (expand-file-name "resources"))
-     ((file-accessible-directory-p (expand-file-name "tramp-archive-resources"))
-      (expand-file-name "tramp-archive-resources"))))
-  "The resources directory test files are located in.")
-
-(defconst tramp-archive-test-file-archive
-  (file-truename
-   (expand-file-name "foo.tar.gz" tramp-archive-test-resource-directory))
+(defconst tramp-archive-test-file-archive (ert-resource-file "foo.tar.gz")
   "The test file archive.")
 
 (defun tramp-archive-test-file-archive-hexlified ()
@@ -60,7 +47,7 @@ Do not hexlify \"/\".  This hexlified string is used in `file:///' URLs."
 
 (defconst tramp-archive-test-directory
   (file-truename
-   (expand-file-name "foo.iso" tramp-archive-test-resource-directory))
+   (ert-resource-file "foo.iso"))
   "A directory file name, which looks like an archive.")
 
 (setq password-cache-expiry nil
index cf7e6288fdb97e6e68bd0fee960aa532f817ae85..91a9965483ac97b9a09d3210680a0f313e8f9229 100644 (file)
 ;;; Code:
 
 (require 'ert)
+(require 'ert-x)
 (require 'pcmpl-linux)
 
-(defvar pcmpl-linux-tests-data-dir
-  (file-truename
-   (expand-file-name "pcmpl-linux-resources/"
-                     (file-name-directory (or load-file-name
-                                              buffer-file-name))))
-  "Base directory of pcmpl-linux-tests.el data files.")
-
 (ert-deftest pcmpl-linux-test-fs-types ()
-  (let ((pcmpl-linux-fs-modules-path-format (expand-file-name "fs"
-                                                   pcmpl-linux-tests-data-dir)))
+  (let ((pcmpl-linux-fs-modules-path-format (ert-resource-file "fs")))
     ;; FIXME: Shouldn't return "." and ".."
     (should (equal (pcmpl-linux-fs-types)
                    '("." ".." "ext4")))))
 
 (ert-deftest pcmpl-linux-test-mounted-directories ()
-  (let ((pcmpl-linux-mtab-file (expand-file-name "mtab"
-                                      pcmpl-linux-tests-data-dir)))
+  (let ((pcmpl-linux-mtab-file (ert-resource-file "mtab")))
     (should (equal (pcmpl-linux-mounted-directories)
                    '("/" "/dev" "/dev/pts" "/dev/shm" "/home/alice/.gvfs"
                      "/lib/modules/2.6.24-16-generic/volatile" "/proc" "/sys"
index 20be7ed68cc5da2f74fc10e5bee29bf9288daef5..e2af2b5b8de850f995a1bdff28ae859c462e2992 100644 (file)
 
 (require 'cperl-mode)
 (require 'ert)
-
-(defvar cperl-mode-tests-data-directory
-  (expand-file-name "lisp/progmodes/cperl-mode-resources"
-                    (or (getenv "EMACS_TEST_DIRECTORY")
-                        (expand-file-name "../../../"
-                                          (or load-file-name
-                                              buffer-file-name))))
-  "Directory containing cperl-mode test data.")
+(require 'ert-x)
 
 (defun cperl-test-ppss (text regexp)
   "Return the `syntax-ppss' of the first character matched by REGEXP in TEXT."
@@ -149,8 +142,7 @@ These exercise some standard blocks and also the special
 treatment for Perl expressions where a closing paren isn't the
 end of the statement."
   (skip-unless (eq cperl-test-mode #'cperl-mode))
-  (let ((file (expand-file-name "cperl-indent-exp.pl"
-                                cperl-mode-tests-data-directory)))
+  (let ((file (ert-resource-file "cperl-indent-exp.pl")))
     (with-temp-buffer
       (insert-file-contents file)
       (goto-char (point-min))
@@ -179,8 +171,7 @@ end of the statement."
 Perl Best Practices sets some indentation values different from
   the defaults, and also wants an \"else\" or \"elsif\" keyword
   to align with the \"if\"."
-  (let ((file (expand-file-name "cperl-indent-styles.pl"
-                                cperl-mode-tests-data-directory)))
+  (let ((file (ert-resource-file "cperl-indent-styles.pl")))
     (with-temp-buffer
       (cperl-set-style "PBP")
       (insert-file-contents file)
index df72b523a9dcd0c9b675d94e4fe6b4788ad9cc0e..c62a2dbde13fa435a9f3f9914ec5aa0a9d474c58 100644 (file)
 
 ;;; Code:
 (require 'ert)
+(require 'ert-x)
 (require 'flymake)
 (eval-when-compile (require 'subr-x)) ; string-trim
 
-(defvar flymake-tests-data-directory
-  (expand-file-name "lisp/progmodes/flymake-resources"
-                    (or (getenv "EMACS_TEST_DIRECTORY")
-                        (expand-file-name "../../.."
-                                          (or load-file-name
-                                              buffer-file-name))))
-  "Directory containing flymake test data.")
-
 \f
 ;;
 ;;
@@ -63,7 +56,7 @@
   "Call FN after flymake setup in FILE, using `flymake-proc`.
 SEVERITY-PREDICATE is used to setup
 `flymake-proc-diagnostic-type-pred'"
-  (let* ((file (expand-file-name file flymake-tests-data-directory))
+  (let* ((file (ert-resource-file file))
          (visiting (find-buffer-visiting file))
          (buffer (or visiting (find-file-noselect file)))
          (process-environment (cons "LC_ALL=C" process-environment))
index 6675fb28f8e61a07d42725620749a56d57dab032..97ac1e1ecd9f8a68894597e7698680075f01c5d4 100644 (file)
 ;;; Code:
 
 (require 'ert)
+(require 'ert-x)
 (require 'ruby-mode)
 
-(defvar ruby-mode-tests-data-dir
-  (file-truename
-   (expand-file-name "ruby-mode-resources/"
-                     (file-name-directory (or load-file-name
-                                              buffer-file-name)))))
-
 (defmacro ruby-with-temp-buffer (contents &rest body)
   (declare (indent 1) (debug t))
   `(with-temp-buffer
@@ -851,8 +846,7 @@ VALUES-PLIST is a list with alternating index and value elements."
 (ert-deftest ruby--indent/converted-from-manual-test ()
   :tags '(:expensive-test)
   ;; Converted from manual test.
-  (let ((buf (find-file-noselect (expand-file-name "ruby.rb"
-                                                   ruby-mode-tests-data-dir))))
+  (let ((buf (find-file-noselect (ert-resource-file "ruby.rb"))))
     (unwind-protect
         (with-current-buffer buf
           (let ((orig (buffer-string)))
index ae7749fe93064f8c5fe351bf5191e531c418d5f1..27aa2ec19246721f52ed8dc8a0644e37b22dd305 100644 (file)
 ;;; Commentary:
 
 (require 'ert)
+(require 'ert-x)
 (require 'saveplace)
 
-(defvar saveplace-tests-dir
-  (file-truename
-   (expand-file-name "saveplace-resources"
-                     (file-name-directory (or load-file-name
-                                              buffer-file-name)))))
-
 (ert-deftest saveplace-test-save-place-to-alist/dir ()
   (save-place-mode)
   (let* ((save-place-alist nil)
          (save-place-loaded t)
-         (loc saveplace-tests-dir))
+         (loc (ert-resource-directory)))
     (save-window-excursion
       (dired loc)
       (save-place-to-alist)
       (should (equal save-place-alist
-                     `((,(concat loc "/")
-                        (dired-filename . ,(concat loc "/saveplace")))))))))
+                     `((,loc
+                        (dired-filename . ,(concat loc "saveplace")))))))))
 
 (ert-deftest saveplace-test-save-place-to-alist/file ()
   (save-place-mode)
@@ -91,7 +86,7 @@
   (save-place-mode)
   (let ((save-place-loaded nil)
         (save-place-file
-         (expand-file-name "saveplace" saveplace-tests-dir))
+         (ert-resource-file "saveplace"))
         (save-place-alist nil))
     (load-save-place-alist-from-file)
     (should (equal save-place-alist
index f627d1c02c9fd5d91204ec6b4b5105dd70b8b6ed..476fd326e66c3e8cb123d0091938fba9e658eee2 100644 (file)
 
 (require 'css-mode)
 (require 'ert)
+(require 'ert-x)
 (require 'seq)
 
-(defvar css-mode-tests-data-dir
-  (file-truename
-   (expand-file-name "css-mode-resources/"
-                     (file-name-directory (or load-file-name
-                                              buffer-file-name)))))
-
 (ert-deftest css-test-property-values ()
   ;; The `float' property has a flat value list.
   (should
 
 (ert-deftest css-mode-test-indent ()
   (with-current-buffer
-      (find-file-noselect (expand-file-name "test-indent.css"
-                                            css-mode-tests-data-dir))
+      (find-file-noselect (ert-resource-file "test-indent.css"))
     (let ((orig (buffer-string)))
       (indent-region (point-min) (point-max))
       (should (equal (buffer-string) orig)))))
index e4a45fb9c82ea7c218e6eb14fdd00f34ed246466..810504faf2c65f3a3d637736103abfe0f8b5582d 100644 (file)
 
 (require 'url-file)
 (require 'ert)
-
-(defconst url-file-tests-data-directory
-  (expand-file-name "lisp/url/url-file-resources"
-                    (or (getenv "EMACS_TEST_DIRECTORY")
-                        (expand-file-name "../../.."
-                                          (or load-file-name
-                                              buffer-file-name))))
-  "Directory for url-file test files.")
+(require 'ert-x)
 
 (ert-deftest url-file ()
   "Test reading file via file:/// URL."
-  (let* ((file (expand-file-name "file.txt" url-file-tests-data-directory))
+  (let* ((file (ert-resource-file "file.txt"))
          (uri-prefix (if (eq (aref file 0) ?/) "file://" "file:///")))
     (should (equal
              (with-current-buffer