From 72c9d4bee112a7e44316b04f361cc4ad3b16cf76 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 23 Oct 2020 21:07:26 +0200 Subject: [PATCH] Move more test data to follow our conventions * test/data/minibuffer-test-cttq$tion: Move from here... * test/lisp/minibuffer-resources/data/minibuffer-test-cttq$tion: ...to here. * test/lisp/minibuffer-resources/lisp/cedet/semantic-utest-c.test: * test/lisp/minibuffer-resources/lisp/cedet/semantic-utest.test: New files. * test/lisp/minibuffer-tests.el (ert, ert-x): Require. (completion-table-test-quoting): Use ert-resource-directory. * test/data/net/cert.pem: * test/data/net/key.pem: Move frome here... * test/lisp/net/network-stream-resources/cert.pem: * test/lisp/net/network-stream-resources/key.pem: ...to here. * test/lisp/net/network-stream-tests.el (ert, ert-x): Require. (network-stream-tests--datadir): Remove variable. (make-tls-server): Use ert-resource-file. * test/data/vc/diff-mode/hello_emacs.c: * test/data/vc/diff-mode/hello_emacs_1.c: * test/data/vc/diff-mode/hello_world.c: * test/data/vc/diff-mode/hello_world_1.c: Move from here... * test/lisp/vc/diff-mode-resources/hello_emacs.c: * test/lisp/vc/diff-mode-resources/hello_emacs_1.c: * test/lisp/vc/diff-mode-resources/hello_world.c: * test/lisp/vc/diff-mode-resources/hello_world_1.c: ...to here. * test/lisp/vc/diff-mode-tests.el (ert, ert-x): Require. (diff-mode-tests--datadir): Remove variable. (diff-mode-test-font-lock-syntax-one-line) (diff-mode-test-font-lock): Use ert-resource-directory. * test/data/xdg/l10n.desktop: * test/data/xdg/malformed.desktop: * test/data/xdg/mimeapps.list: * test/data/xdg/mimeinfo.cache: * test/data/xdg/test.desktop: Move from here... * test/lisp/xdg-resources/l10n.desktop: * test/lisp/xdg-resources/malformed.desktop: * test/lisp/xdg-resources/mimeapps.list: * test/lisp/xdg-resources/mimeinfo.cache: * test/lisp/xdg-resources/test.desktop: ...to here. * test/lisp/xdg-tests.el (ert-x): Require. (xdg-tests-data-dir): Remove variable. (xdg-desktop-parsing, xdg-mime-associations): Use ert-resource-file. --- .../data/minibuffer-test-cttq$tion | 0 .../lisp/cedet/semantic-utest-c.test | 0 .../lisp/cedet/semantic-utest.test | 0 test/lisp/minibuffer-tests.el | 5 ++++- .../net/network-stream-resources}/cert.pem | 0 .../net/network-stream-resources}/key.pem | 0 test/lisp/net/network-stream-tests.el | 9 ++++----- .../vc/diff-mode-resources}/hello_emacs.c | 0 .../vc/diff-mode-resources}/hello_emacs_1.c | 0 .../vc/diff-mode-resources}/hello_world.c | 0 .../vc/diff-mode-resources}/hello_world_1.c | 0 test/lisp/vc/diff-mode-tests.el | 13 ++++++------ .../xdg => lisp/xdg-resources}/l10n.desktop | 0 .../xdg-resources}/malformed.desktop | 0 .../xdg => lisp/xdg-resources}/mimeapps.list | 0 .../xdg => lisp/xdg-resources}/mimeinfo.cache | 0 .../xdg => lisp/xdg-resources}/test.desktop | 0 .../xdg => lisp/xdg-resources}/wrong.desktop | 0 test/lisp/xdg-tests.el | 20 +++++++------------ 19 files changed, 21 insertions(+), 26 deletions(-) rename test/{ => lisp/minibuffer-resources}/data/minibuffer-test-cttq$tion (100%) create mode 100644 test/lisp/minibuffer-resources/lisp/cedet/semantic-utest-c.test create mode 100644 test/lisp/minibuffer-resources/lisp/cedet/semantic-utest.test rename test/{data/net => lisp/net/network-stream-resources}/cert.pem (100%) rename test/{data/net => lisp/net/network-stream-resources}/key.pem (100%) rename test/{data/vc/diff-mode => lisp/vc/diff-mode-resources}/hello_emacs.c (100%) rename test/{data/vc/diff-mode => lisp/vc/diff-mode-resources}/hello_emacs_1.c (100%) rename test/{data/vc/diff-mode => lisp/vc/diff-mode-resources}/hello_world.c (100%) rename test/{data/vc/diff-mode => lisp/vc/diff-mode-resources}/hello_world_1.c (100%) rename test/{data/xdg => lisp/xdg-resources}/l10n.desktop (100%) rename test/{data/xdg => lisp/xdg-resources}/malformed.desktop (100%) rename test/{data/xdg => lisp/xdg-resources}/mimeapps.list (100%) rename test/{data/xdg => lisp/xdg-resources}/mimeinfo.cache (100%) rename test/{data/xdg => lisp/xdg-resources}/test.desktop (100%) rename test/{data/xdg => lisp/xdg-resources}/wrong.desktop (100%) diff --git a/test/data/minibuffer-test-cttq$tion b/test/lisp/minibuffer-resources/data/minibuffer-test-cttq$tion similarity index 100% rename from test/data/minibuffer-test-cttq$tion rename to test/lisp/minibuffer-resources/data/minibuffer-test-cttq$tion diff --git a/test/lisp/minibuffer-resources/lisp/cedet/semantic-utest-c.test b/test/lisp/minibuffer-resources/lisp/cedet/semantic-utest-c.test new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/lisp/minibuffer-resources/lisp/cedet/semantic-utest.test b/test/lisp/minibuffer-resources/lisp/cedet/semantic-utest.test new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index 5da86f36148..32734794413 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -26,6 +26,9 @@ ;;; Code: +(require 'ert) +(require 'ert-x) + (eval-when-compile (require 'cl-lib)) (ert-deftest completion-test1 () @@ -85,7 +88,7 @@ (ert-deftest completion-table-test-quoting () (let ((process-environment `("CTTQ1=ed" "CTTQ2=et/" ,@process-environment)) - (default-directory (expand-file-name "test" source-directory))) + (default-directory (ert-resource-directory))) (pcase-dolist (`(,input ,output) '( ;; Test that $ in files is properly $$ quoted. diff --git a/test/data/net/cert.pem b/test/lisp/net/network-stream-resources/cert.pem similarity index 100% rename from test/data/net/cert.pem rename to test/lisp/net/network-stream-resources/cert.pem diff --git a/test/data/net/key.pem b/test/lisp/net/network-stream-resources/key.pem similarity index 100% rename from test/data/net/key.pem rename to test/lisp/net/network-stream-resources/key.pem diff --git a/test/lisp/net/network-stream-tests.el b/test/lisp/net/network-stream-tests.el index cf416155e50..07eb2823282 100644 --- a/test/lisp/net/network-stream-tests.el +++ b/test/lisp/net/network-stream-tests.el @@ -24,6 +24,8 @@ ;;; Code: +(require 'ert) +(require 'ert-x) (require 'gnutls) (require 'network-stream) ;; The require above is needed for 'open-network-stream' to work, but @@ -239,16 +241,13 @@ (should (equal (buffer-string) "foo\n"))) (delete-process server))) -(defconst network-stream-tests--datadir - (expand-file-name "test/data/net" source-directory)) - (defun make-tls-server (port) (start-process "gnutls" (generate-new-buffer "*tls*") "gnutls-serv" "--http" "--x509keyfile" - (concat network-stream-tests--datadir "/key.pem") + (ert-resource-file "key.pem") "--x509certfile" - (concat network-stream-tests--datadir "/cert.pem") + (ert-resource-file "cert.pem") "--port" (format "%s" port))) (ert-deftest connect-to-tls-ipv4-wait () diff --git a/test/data/vc/diff-mode/hello_emacs.c b/test/lisp/vc/diff-mode-resources/hello_emacs.c similarity index 100% rename from test/data/vc/diff-mode/hello_emacs.c rename to test/lisp/vc/diff-mode-resources/hello_emacs.c diff --git a/test/data/vc/diff-mode/hello_emacs_1.c b/test/lisp/vc/diff-mode-resources/hello_emacs_1.c similarity index 100% rename from test/data/vc/diff-mode/hello_emacs_1.c rename to test/lisp/vc/diff-mode-resources/hello_emacs_1.c diff --git a/test/data/vc/diff-mode/hello_world.c b/test/lisp/vc/diff-mode-resources/hello_world.c similarity index 100% rename from test/data/vc/diff-mode/hello_world.c rename to test/lisp/vc/diff-mode-resources/hello_world.c diff --git a/test/data/vc/diff-mode/hello_world_1.c b/test/lisp/vc/diff-mode-resources/hello_world_1.c similarity index 100% rename from test/data/vc/diff-mode/hello_world_1.c rename to test/lisp/vc/diff-mode-resources/hello_world_1.c diff --git a/test/lisp/vc/diff-mode-tests.el b/test/lisp/vc/diff-mode-tests.el index f17ec3648f1..b25836405cc 100644 --- a/test/lisp/vc/diff-mode-tests.el +++ b/test/lisp/vc/diff-mode-tests.el @@ -22,12 +22,11 @@ ;;; Code: +(require 'ert) +(require 'ert-x) (require 'diff-mode) (require 'diff) -(defconst diff-mode-tests--datadir - (expand-file-name "test/data/vc/diff-mode" source-directory)) - (ert-deftest diff-mode-test-ignore-trailing-dashes () "Check to make sure we successfully ignore trailing -- made by 'git format-patch'. This is bug #9597" @@ -209,11 +208,11 @@ youthfulness ;; See comments in diff-hunk-file-names about nonascii. ;; In such cases, the diff-font-lock-syntax portion of this fails. :expected-result (if (string-match-p "[[:nonascii:]]" - diff-mode-tests--datadir) + (ert-resource-directory)) :failed :passed) (skip-unless (executable-find shell-file-name)) (skip-unless (executable-find diff-command)) - (let ((default-directory diff-mode-tests--datadir) + (let ((default-directory (ert-resource-directory)) (old "hello_world.c") (new "hello_emacs.c") (diff-buffer (get-buffer-create "*Diff*")) @@ -274,11 +273,11 @@ youthfulness (ert-deftest diff-mode-test-font-lock-syntax-one-line () "Check diff syntax highlighting for one line with no newline at end." :expected-result (if (string-match-p "[[:nonascii:]]" - diff-mode-tests--datadir) + (ert-resource-directory)) :failed :passed) (skip-unless (executable-find shell-file-name)) (skip-unless (executable-find diff-command)) - (let ((default-directory diff-mode-tests--datadir) + (let ((default-directory (ert-resource-directory)) (old "hello_world_1.c") (new "hello_emacs_1.c") (diff-buffer (get-buffer-create "*Diff*")) diff --git a/test/data/xdg/l10n.desktop b/test/lisp/xdg-resources/l10n.desktop similarity index 100% rename from test/data/xdg/l10n.desktop rename to test/lisp/xdg-resources/l10n.desktop diff --git a/test/data/xdg/malformed.desktop b/test/lisp/xdg-resources/malformed.desktop similarity index 100% rename from test/data/xdg/malformed.desktop rename to test/lisp/xdg-resources/malformed.desktop diff --git a/test/data/xdg/mimeapps.list b/test/lisp/xdg-resources/mimeapps.list similarity index 100% rename from test/data/xdg/mimeapps.list rename to test/lisp/xdg-resources/mimeapps.list diff --git a/test/data/xdg/mimeinfo.cache b/test/lisp/xdg-resources/mimeinfo.cache similarity index 100% rename from test/data/xdg/mimeinfo.cache rename to test/lisp/xdg-resources/mimeinfo.cache diff --git a/test/data/xdg/test.desktop b/test/lisp/xdg-resources/test.desktop similarity index 100% rename from test/data/xdg/test.desktop rename to test/lisp/xdg-resources/test.desktop diff --git a/test/data/xdg/wrong.desktop b/test/lisp/xdg-resources/wrong.desktop similarity index 100% rename from test/data/xdg/wrong.desktop rename to test/lisp/xdg-resources/wrong.desktop diff --git a/test/lisp/xdg-tests.el b/test/lisp/xdg-tests.el index 294996af5f8..c2a16006c35 100644 --- a/test/lisp/xdg-tests.el +++ b/test/lisp/xdg-tests.el @@ -25,26 +25,20 @@ ;;; Code: (require 'ert) +(require 'ert-x) (require 'xdg) -(defconst xdg-tests-data-dir - (expand-file-name "test/data/xdg" source-directory)) - (ert-deftest xdg-desktop-parsing () "Test `xdg-desktop-read-file' parsing of .desktop files." - (let ((tab1 (xdg-desktop-read-file - (expand-file-name "test.desktop" xdg-tests-data-dir))) - (tab2 (xdg-desktop-read-file - (expand-file-name "test.desktop" xdg-tests-data-dir) + (let ((tab1 (xdg-desktop-read-file (ert-resource-file "test.desktop"))) + (tab2 (xdg-desktop-read-file (ert-resource-file "test.desktop") "Another Section"))) (should (equal (gethash "Name" tab1) "Test")) (should (eq 'default (gethash "Exec" tab1 'default))) (should (equal "frobnicate" (gethash "Exec" tab2)))) (should-error - (xdg-desktop-read-file - (expand-file-name "malformed.desktop" xdg-tests-data-dir))) - (let ((tab (xdg-desktop-read-file - (expand-file-name "l10n.desktop" xdg-tests-data-dir))) + (xdg-desktop-read-file (ert-resource-file "malformed.desktop"))) + (let ((tab (xdg-desktop-read-file (ert-resource-file "l10n.desktop"))) (env (getenv "LC_MESSAGES"))) (unwind-protect (progn @@ -67,8 +61,8 @@ (ert-deftest xdg-mime-associations () "Test reading MIME associations from files." - (let* ((apps (expand-file-name "mimeapps.list" xdg-tests-data-dir)) - (cache (expand-file-name "mimeinfo.cache" xdg-tests-data-dir)) + (let* ((apps (ert-resource-file "mimeapps.list")) + (cache (ert-resource-file "mimeinfo.cache")) (fs (list apps cache))) (should (equal (xdg-mime-collect-associations "x-test/foo" fs) '("a.desktop" "b.desktop"))) -- 2.39.2