diff options
| author | Ken Brown | 2016-05-24 11:33:24 -0400 |
|---|---|---|
| committer | Ken Brown | 2016-05-24 11:33:24 -0400 |
| commit | e882e7a35673204397c295b6e92e66e3207a901e (patch) | |
| tree | f7ee516a02a8c12213cd3bc8e6d0086447d3292b | |
| parent | 4aa55338ff3af1cd4e87802e02156e636d212241 (diff) | |
| download | emacs-e882e7a35673204397c295b6e92e66e3207a901e.tar.gz emacs-e882e7a35673204397c295b6e92e66e3207a901e.zip | |
Allow shr-tests to work for out-of-tree builds
* test/lisp/net/shr-tests.el (shr-tests--datadir): New defconst.
(shr-test, rendering): Use it.
| -rw-r--r-- | test/lisp/net/shr-tests.el | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/test/lisp/net/shr-tests.el b/test/lisp/net/shr-tests.el index ab6fc93d1a0..501916fc8bf 100644 --- a/test/lisp/net/shr-tests.el +++ b/test/lisp/net/shr-tests.el | |||
| @@ -25,9 +25,12 @@ | |||
| 25 | 25 | ||
| 26 | (require 'shr) | 26 | (require 'shr) |
| 27 | 27 | ||
| 28 | (defconst shr-tests--datadir | ||
| 29 | (expand-file-name "test/data/shr" source-directory)) | ||
| 30 | |||
| 28 | (defun shr-test (name) | 31 | (defun shr-test (name) |
| 29 | (with-temp-buffer | 32 | (with-temp-buffer |
| 30 | (insert-file-contents (format "data/shr/%s.html" name)) | 33 | (insert-file-contents (format (concat shr-tests--datadir "/%s.html") name)) |
| 31 | (let ((dom (libxml-parse-html-region (point-min) (point-max))) | 34 | (let ((dom (libxml-parse-html-region (point-min) (point-max))) |
| 32 | (shr-width 80) | 35 | (shr-width 80) |
| 33 | (shr-use-fonts nil)) | 36 | (shr-use-fonts nil)) |
| @@ -35,7 +38,8 @@ | |||
| 35 | (shr-insert-document dom) | 38 | (shr-insert-document dom) |
| 36 | (cons (buffer-substring-no-properties (point-min) (point-max)) | 39 | (cons (buffer-substring-no-properties (point-min) (point-max)) |
| 37 | (with-temp-buffer | 40 | (with-temp-buffer |
| 38 | (insert-file-contents (format "data/shr/%s.txt" name)) | 41 | (insert-file-contents |
| 42 | (format (concat shr-tests--datadir "/%s.txt") name)) | ||
| 39 | (while (re-search-forward "%\\([0-9A-F][0-9A-F]\\)" nil t) | 43 | (while (re-search-forward "%\\([0-9A-F][0-9A-F]\\)" nil t) |
| 40 | (replace-match (string (string-to-number (match-string 1) 16)) | 44 | (replace-match (string (string-to-number (match-string 1) 16)) |
| 41 | t t)) | 45 | t t)) |
| @@ -43,7 +47,7 @@ | |||
| 43 | 47 | ||
| 44 | (ert-deftest rendering () | 48 | (ert-deftest rendering () |
| 45 | (skip-unless (fboundp 'libxml-parse-html-region)) | 49 | (skip-unless (fboundp 'libxml-parse-html-region)) |
| 46 | (dolist (file (directory-files "data/shr" nil "\\.html\\'")) | 50 | (dolist (file (directory-files shr-tests--datadir nil "\\.html\\'")) |
| 47 | (let* ((name (replace-regexp-in-string "\\.html\\'" "" file)) | 51 | (let* ((name (replace-regexp-in-string "\\.html\\'" "" file)) |
| 48 | (result (shr-test name))) | 52 | (result (shr-test name))) |
| 49 | (unless (equal (car result) (cdr result)) | 53 | (unless (equal (car result) (cdr result)) |