From 49bc8586b7abc8e1e36027ca5eec0d0488a27474 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 23 Oct 2020 16:29:46 +0200 Subject: [PATCH] Move some test data to follow our conventions * test/data/emacs-module/mod-test.c: Move from here... * test/src/emacs-module-resources/mod-test.c: ...to here. * test/src/emacs-module-tests.el (ert-x): Require. (mod-test-file, module/describe-function-1): * test/Makefile.in (test_module_dir): Adjust for move. * test/data/files-bug18141.el.gz: Move from here... * test/lisp/files-resources/files-bug18141.el.gz: ... to here. * test/lisp/files-tests.el (ert-x): Require. (files-test-bug-18141-file): Use ert-resource-file. * test/data/mailcap/mime.types: Move from here... * test/lisp/net/mailcap-resources/mime.types: ...to here. * test/lisp/net/mailcap-tests.el (ert-x): Require. (mailcap-tests-path): Use ert-resource-file. * test/data/somelib.el: * test/data/somelib2.el: Move from here... * test/src/lread-resources/somelib.el: * test/src/lread-resources/somelib2.el: ...to here. * test/src/lread-tests.el (ert, ert-x): Require. (lread-test-bug26837): Use ert-resource-directory. * test/data/syntax-comments.txt: Move from here.... * test/src/syntax-resources/syntax-comments.txt: ...to here. * test/src/syntax-tests.el (ert-x): Require. (syntax-comments, syntax-br-comments, syntax-pps-comments): Use ert-resource-file. * test/data/xref/file1.txt: * test/data/xref/file2.txt: Move from here... * test/lisp/progmodes/xref-resources/file1.txt: * test/lisp/progmodes/xref-resources/file2.txt: ...to here. * test/lisp/progmodes/xref-tests.el (ert, ert-x): Require. (xref-tests-data-dir): Use ert-resource-directory. --- test/Makefile.in | 2 +- .../files-resources}/files-bug18141.el.gz | Bin test/lisp/files-tests.el | 3 ++- .../net/mailcap-resources}/mime.types | 0 test/lisp/net/mailcap-tests.el | 7 ++----- .../progmodes/xref-resources}/file1.txt | 0 .../progmodes/xref-resources}/file2.txt | 0 test/lisp/progmodes/xref-tests.el | 7 +++---- .../emacs-module-resources}/mod-test.c | 0 test/src/emacs-module-tests.el | 12 ++++++------ test/{data => src/lread-resources}/somelib.el | 0 test/{data => src/lread-resources}/somelib2.el | 0 test/src/lread-tests.el | 8 ++++---- .../syntax-resources}/syntax-comments.txt | 0 test/src/syntax-tests.el | 12 +++++------- 15 files changed, 23 insertions(+), 28 deletions(-) rename test/{data => lisp/files-resources}/files-bug18141.el.gz (100%) rename test/{data/mailcap => lisp/net/mailcap-resources}/mime.types (100%) rename test/{data/xref => lisp/progmodes/xref-resources}/file1.txt (100%) rename test/{data/xref => lisp/progmodes/xref-resources}/file2.txt (100%) rename test/{data/emacs-module => src/emacs-module-resources}/mod-test.c (100%) rename test/{data => src/lread-resources}/somelib.el (100%) rename test/{data => src/lread-resources}/somelib2.el (100%) rename test/{data => src/syntax-resources}/syntax-comments.txt (100%) diff --git a/test/Makefile.in b/test/Makefile.in index 9974eb54b03..67d203df297 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -132,7 +132,7 @@ emacs = EMACSLOADPATH= \ # exists, or writing to ~/.bzr.log when running bzr commands). TEST_HOME = /nonexistent -test_module_dir := data/emacs-module +test_module_dir := src/emacs-module-resources .PHONY: all check diff --git a/test/data/files-bug18141.el.gz b/test/lisp/files-resources/files-bug18141.el.gz similarity index 100% rename from test/data/files-bug18141.el.gz rename to test/lisp/files-resources/files-bug18141.el.gz diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 1b964af6887..8818099a223 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -20,6 +20,7 @@ ;;; Code: (require 'ert) +(require 'ert-x) (require 'nadvice) (eval-when-compile (require 'cl-lib)) (require 'bytecomp) ; `byte-compiler-base-file-name'. @@ -151,7 +152,7 @@ form.") (should (file-test--do-local-variables-test str subtest))))))) (defvar files-test-bug-18141-file - (expand-file-name "data/files-bug18141.el.gz" (getenv "EMACS_TEST_DIRECTORY")) + (ert-resource-file "files-bug18141.el.gz") "Test file for bug#18141.") (ert-deftest files-tests-bug-18141 () diff --git a/test/data/mailcap/mime.types b/test/lisp/net/mailcap-resources/mime.types similarity index 100% rename from test/data/mailcap/mime.types rename to test/lisp/net/mailcap-resources/mime.types diff --git a/test/lisp/net/mailcap-tests.el b/test/lisp/net/mailcap-tests.el index 8354d8e5e23..0ebbec61159 100644 --- a/test/lisp/net/mailcap-tests.el +++ b/test/lisp/net/mailcap-tests.el @@ -24,13 +24,10 @@ ;;; Code: (require 'ert) +(require 'ert-x) (require 'mailcap) -(defconst mailcap-tests-data-dir - (expand-file-name "test/data/mailcap" source-directory)) - -(defconst mailcap-tests-path - (expand-file-name "mime.types" mailcap-tests-data-dir) +(defconst mailcap-tests-path (ert-resource-file "mime.types") "String used as PATH argument of `mailcap-parse-mimetypes'.") (defconst mailcap-tests-mime-extensions (copy-alist mailcap-mime-extensions)) diff --git a/test/data/xref/file1.txt b/test/lisp/progmodes/xref-resources/file1.txt similarity index 100% rename from test/data/xref/file1.txt rename to test/lisp/progmodes/xref-resources/file1.txt diff --git a/test/data/xref/file2.txt b/test/lisp/progmodes/xref-resources/file2.txt similarity index 100% rename from test/data/xref/file2.txt rename to test/lisp/progmodes/xref-resources/file2.txt diff --git a/test/lisp/progmodes/xref-tests.el b/test/lisp/progmodes/xref-tests.el index a4980b2acb1..060c9cb5d1c 100644 --- a/test/lisp/progmodes/xref-tests.el +++ b/test/lisp/progmodes/xref-tests.el @@ -23,13 +23,12 @@ ;;; Code: +(require 'ert) +(require 'ert-x) (require 'xref) (require 'cl-lib) -(defvar xref-tests-data-dir - (expand-file-name "../../../data/xref/" - (or load-file-name - buffer-file-name))) +(defvar xref-tests-data-dir (ert-resource-directory)) (ert-deftest xref-matches-in-directory-finds-none-for-some-regexp () (should (null (xref-matches-in-directory "zzz" "*" xref-tests-data-dir nil)))) diff --git a/test/data/emacs-module/mod-test.c b/test/src/emacs-module-resources/mod-test.c similarity index 100% rename from test/data/emacs-module/mod-test.c rename to test/src/emacs-module-resources/mod-test.c diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el index 621229c62aa..fb4ed4a6842 100644 --- a/test/src/emacs-module-tests.el +++ b/test/src/emacs-module-tests.el @@ -21,13 +21,14 @@ ;; Unit tests for the dynamic module facility. See Info node `(elisp) ;; Writing Dynamic Modules'. These tests make use of a small test -;; module in test/data/emacs-module. +;; module in the "emacs-module-resources" directory. ;;; Code: ;;; Prelude (require 'cl-lib) (require 'ert) +(require 'ert-x) (require 'help-fns) (defconst mod-test-emacs @@ -35,8 +36,7 @@ "File name of the Emacs binary currently running.") (eval-and-compile - (defconst mod-test-file - (expand-file-name "../test/data/emacs-module/mod-test" invocation-directory) + (defconst mod-test-file (ert-resource-file "mod-test") "File name of the module test file.")) (require 'mod-test mod-test-file) @@ -313,11 +313,11 @@ local reference." (text-quoting-style 'grave)) (describe-function-1 #'mod-test-sum) (goto-char (point-min)) - (while (re-search-forward "`[^']*/data/emacs-module/" nil t) - (replace-match "`data/emacs-module/")) + (while (re-search-forward "`[^']*/src/emacs-module-resources/" nil t) + (replace-match "`src/emacs-module-resources/")) (should (equal (buffer-substring-no-properties 1 (point-max)) - (format "a module function in `data/emacs-module/mod-test%s'. + (format "a module function in `src/emacs-module-resources/mod-test%s'. (mod-test-sum a b) diff --git a/test/data/somelib.el b/test/src/lread-resources/somelib.el similarity index 100% rename from test/data/somelib.el rename to test/src/lread-resources/somelib.el diff --git a/test/data/somelib2.el b/test/src/lread-resources/somelib2.el similarity index 100% rename from test/data/somelib2.el rename to test/src/lread-resources/somelib2.el diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index 26fd6aa22a1..825b74e6234 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el @@ -25,6 +25,9 @@ ;;; Code: +(require 'ert) +(require 'ert-x) + (ert-deftest lread-char-number () (should (equal (read "?\\N{U+A817}") #xA817))) @@ -146,10 +149,7 @@ literals (Bug#20852)." (ert-deftest lread-test-bug26837 () "Test for https://debbugs.gnu.org/26837 ." - (let ((load-path (cons - (file-name-as-directory - (expand-file-name "data" (getenv "EMACS_TEST_DIRECTORY"))) - load-path))) + (let ((load-path (cons (ert-resource-directory) load-path))) (load "somelib" nil t) (should (string-suffix-p "/somelib.el" (caar load-history))) (load "somelib2" nil t) diff --git a/test/data/syntax-comments.txt b/test/src/syntax-resources/syntax-comments.txt similarity index 100% rename from test/data/syntax-comments.txt rename to test/src/syntax-resources/syntax-comments.txt diff --git a/test/src/syntax-tests.el b/test/src/syntax-tests.el index 56e03380579..4b9c3f277aa 100644 --- a/test/src/syntax-tests.el +++ b/test/src/syntax-tests.el @@ -20,6 +20,7 @@ ;;; Code: (require 'ert) +(require 'ert-x) (ert-deftest parse-partial-sexp-continue-over-comment-marker () "Continue a parse that stopped in the middle of a comment marker." @@ -91,7 +92,7 @@ also has open paren syntax (see Bug#24870)." ;; It is intended to enhance this bit to test nested comments ;; (2020-10-01). -;; This bit uses the data file test/data/syntax-comments.txt. +;; This bit uses the data file syntax-resources/syntax-comments.txt. (defun syntax-comments-point (n forw) "Return the buffer offset corresponding to the \"label\" N. @@ -182,8 +183,7 @@ missing or nil, the value of START is assumed for it." () (with-current-buffer (find-file - ,(expand-file-name "data/syntax-comments.txt" - (getenv "EMACS_TEST_DIRECTORY"))) + ,(ert-resource-file "syntax-comments.txt")) (,(intern (concat (symbol-name type) "-in"))) (goto-char (syntax-comments-point ,start ,forw)) (let ((stop (syntax-comments-point ,(or stop start) ,(not forw)))) @@ -230,8 +230,7 @@ missing or nil, the value of -START- is assumed for it." () (with-current-buffer (find-file - ,(expand-file-name "data/syntax-comments.txt" - (getenv "EMACS_TEST_DIRECTORY"))) + ,(ert-resource-file "syntax-comments.txt")) (,(intern (concat (symbol-name type) "-in"))) (let ((start-pos (syntax-comments-point ,start ,forw)) ,@(if res @@ -285,8 +284,7 @@ the `parse-partial-sexp's are expected to stop. See () (with-current-buffer (find-file - ,(expand-file-name "data/syntax-comments.txt" - (getenv "EMACS_TEST_DIRECTORY"))) + ,(ert-resource-file "syntax-comments.txt")) (,(intern (concat (symbol-name type) "-in"))) (let ((start-pos (syntax-comments-point ,start t)) (open-pos (syntax-comments-midpoint ,open)) -- 2.39.2