From e402887d5d2f7cfc5e3f1cb2a9e629bce782e0a8 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sat, 24 Oct 2020 02:28:45 +0200 Subject: [PATCH] Move shr.el test data to follow our conventions * test/lisp/net/shr-tests.el (ert, ert-x): Require. (shr-tests--datadir): Remove variable. (shr-test, rendering): Use ert-resource-directory. * test/lisp/net/shr-resources/*: Move from test/data/shr/. --- .../{data/shr => lisp/net/shr-resources}/div-div.html | 0 test/{data/shr => lisp/net/shr-resources}/div-div.txt | 0 test/{data/shr => lisp/net/shr-resources}/div-p.html | 0 test/{data/shr => lisp/net/shr-resources}/div-p.txt | 0 test/{data/shr => lisp/net/shr-resources}/li-div.html | 0 test/{data/shr => lisp/net/shr-resources}/li-div.txt | 0 .../shr => lisp/net/shr-resources}/li-empty.html | 0 .../{data/shr => lisp/net/shr-resources}/li-empty.txt | 0 test/{data/shr => lisp/net/shr-resources}/nonbr.html | 0 test/{data/shr => lisp/net/shr-resources}/nonbr.txt | 0 test/{data/shr => lisp/net/shr-resources}/ol.html | 0 test/{data/shr => lisp/net/shr-resources}/ol.txt | 0 .../shr => lisp/net/shr-resources}/ul-empty.html | 0 .../{data/shr => lisp/net/shr-resources}/ul-empty.txt | 0 test/lisp/net/shr-tests.el | 11 +++++------ 15 files changed, 5 insertions(+), 6 deletions(-) rename test/{data/shr => lisp/net/shr-resources}/div-div.html (100%) rename test/{data/shr => lisp/net/shr-resources}/div-div.txt (100%) rename test/{data/shr => lisp/net/shr-resources}/div-p.html (100%) rename test/{data/shr => lisp/net/shr-resources}/div-p.txt (100%) rename test/{data/shr => lisp/net/shr-resources}/li-div.html (100%) rename test/{data/shr => lisp/net/shr-resources}/li-div.txt (100%) rename test/{data/shr => lisp/net/shr-resources}/li-empty.html (100%) rename test/{data/shr => lisp/net/shr-resources}/li-empty.txt (100%) rename test/{data/shr => lisp/net/shr-resources}/nonbr.html (100%) rename test/{data/shr => lisp/net/shr-resources}/nonbr.txt (100%) rename test/{data/shr => lisp/net/shr-resources}/ol.html (100%) rename test/{data/shr => lisp/net/shr-resources}/ol.txt (100%) rename test/{data/shr => lisp/net/shr-resources}/ul-empty.html (100%) rename test/{data/shr => lisp/net/shr-resources}/ul-empty.txt (100%) diff --git a/test/data/shr/div-div.html b/test/lisp/net/shr-resources/div-div.html similarity index 100% rename from test/data/shr/div-div.html rename to test/lisp/net/shr-resources/div-div.html diff --git a/test/data/shr/div-div.txt b/test/lisp/net/shr-resources/div-div.txt similarity index 100% rename from test/data/shr/div-div.txt rename to test/lisp/net/shr-resources/div-div.txt diff --git a/test/data/shr/div-p.html b/test/lisp/net/shr-resources/div-p.html similarity index 100% rename from test/data/shr/div-p.html rename to test/lisp/net/shr-resources/div-p.html diff --git a/test/data/shr/div-p.txt b/test/lisp/net/shr-resources/div-p.txt similarity index 100% rename from test/data/shr/div-p.txt rename to test/lisp/net/shr-resources/div-p.txt diff --git a/test/data/shr/li-div.html b/test/lisp/net/shr-resources/li-div.html similarity index 100% rename from test/data/shr/li-div.html rename to test/lisp/net/shr-resources/li-div.html diff --git a/test/data/shr/li-div.txt b/test/lisp/net/shr-resources/li-div.txt similarity index 100% rename from test/data/shr/li-div.txt rename to test/lisp/net/shr-resources/li-div.txt diff --git a/test/data/shr/li-empty.html b/test/lisp/net/shr-resources/li-empty.html similarity index 100% rename from test/data/shr/li-empty.html rename to test/lisp/net/shr-resources/li-empty.html diff --git a/test/data/shr/li-empty.txt b/test/lisp/net/shr-resources/li-empty.txt similarity index 100% rename from test/data/shr/li-empty.txt rename to test/lisp/net/shr-resources/li-empty.txt diff --git a/test/data/shr/nonbr.html b/test/lisp/net/shr-resources/nonbr.html similarity index 100% rename from test/data/shr/nonbr.html rename to test/lisp/net/shr-resources/nonbr.html diff --git a/test/data/shr/nonbr.txt b/test/lisp/net/shr-resources/nonbr.txt similarity index 100% rename from test/data/shr/nonbr.txt rename to test/lisp/net/shr-resources/nonbr.txt diff --git a/test/data/shr/ol.html b/test/lisp/net/shr-resources/ol.html similarity index 100% rename from test/data/shr/ol.html rename to test/lisp/net/shr-resources/ol.html diff --git a/test/data/shr/ol.txt b/test/lisp/net/shr-resources/ol.txt similarity index 100% rename from test/data/shr/ol.txt rename to test/lisp/net/shr-resources/ol.txt diff --git a/test/data/shr/ul-empty.html b/test/lisp/net/shr-resources/ul-empty.html similarity index 100% rename from test/data/shr/ul-empty.html rename to test/lisp/net/shr-resources/ul-empty.html diff --git a/test/data/shr/ul-empty.txt b/test/lisp/net/shr-resources/ul-empty.txt similarity index 100% rename from test/data/shr/ul-empty.txt rename to test/lisp/net/shr-resources/ul-empty.txt diff --git a/test/lisp/net/shr-tests.el b/test/lisp/net/shr-tests.el index 88a31bcf645..abc4f6a656b 100644 --- a/test/lisp/net/shr-tests.el +++ b/test/lisp/net/shr-tests.el @@ -23,14 +23,13 @@ ;;; Code: +(require 'ert) +(require 'ert-x) (require 'shr) -(defconst shr-tests--datadir - (expand-file-name "test/data/shr" source-directory)) - (defun shr-test (name) (with-temp-buffer - (insert-file-contents (format (concat shr-tests--datadir "/%s.html") name)) + (insert-file-contents (format (concat (ert-resource-directory) "/%s.html") name)) (let ((dom (libxml-parse-html-region (point-min) (point-max))) (shr-width 80) (shr-use-fonts nil)) @@ -39,7 +38,7 @@ (cons (buffer-substring-no-properties (point-min) (point-max)) (with-temp-buffer (insert-file-contents - (format (concat shr-tests--datadir "/%s.txt") name)) + (format (concat (ert-resource-directory) "/%s.txt") name)) (while (re-search-forward "%\\([0-9A-F][0-9A-F]\\)" nil t) (replace-match (string (string-to-number (match-string 1) 16)) t t)) @@ -47,7 +46,7 @@ (ert-deftest rendering () (skip-unless (fboundp 'libxml-parse-html-region)) - (dolist (file (directory-files shr-tests--datadir nil "\\.html\\'")) + (dolist (file (directory-files (ert-resource-directory) nil "\\.html\\'")) (let* ((name (replace-regexp-in-string "\\.html\\'" "" file)) (result (shr-test name))) (unless (equal (car result) (cdr result)) -- 2.39.2