;;; 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
,@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'
(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)
(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
"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))
;;; 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))
(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
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))))
(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
(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))
(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'.
(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))))
(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
(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)
(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)
(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)
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)
(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)
(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)
;;; 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.
;;; 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
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"
;;; 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.")
;;; 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))
(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
;; 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 ()
(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
;;; 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"
(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."
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))
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)
;;; 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
;;
;;
"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))
;;; 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
(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)))
;;; 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)
(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
(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)))))
(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