diff options
| author | Michael Albinus | 2017-04-02 11:03:14 +0200 |
|---|---|---|
| committer | Michael Albinus | 2017-04-02 11:03:14 +0200 |
| commit | 40a33a3cb711f894ac61691c03cc13e58bc38145 (patch) | |
| tree | 27fcb032eb04a20bd57b412b2120d357f28ab7fa /test | |
| parent | 59191cd0cbe8463f9095a71cb4048bb138d6e446 (diff) | |
| parent | a184a7edc58e1e053aa317a0f162df7e225597e1 (diff) | |
| download | emacs-40a33a3cb711f894ac61691c03cc13e58bc38145.tar.gz emacs-40a33a3cb711f894ac61691c03cc13e58bc38145.zip | |
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'test')
| -rw-r--r-- | test/Makefile.in | 31 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/cl-lib-tests.el | 25 | ||||
| -rw-r--r-- | test/lisp/progmodes/js-tests.el | 37 | ||||
| -rw-r--r-- | test/lisp/url/url-auth-tests.el | 51 | ||||
| -rw-r--r-- | test/lisp/vc/ediff-ptch-tests.el | 78 | ||||
| -rw-r--r-- | test/make-test-deps.emacs-lisp | 98 |
6 files changed, 159 insertions, 161 deletions
diff --git a/test/Makefile.in b/test/Makefile.in index c0056b6f44d..d218b640057 100644 --- a/test/Makefile.in +++ b/test/Makefile.in | |||
| @@ -124,12 +124,12 @@ endif | |||
| 124 | $(emacs) -l ert -l $$loadfile \ | 124 | $(emacs) -l ert -l $$loadfile \ |
| 125 | --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG} | 125 | --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG} |
| 126 | 126 | ||
| 127 | ELFILES = $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \ | 127 | ELFILES := $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \ |
| 128 | -path "*resources" -prune -o -name "*el" -print) | 128 | -name "*resources" -prune -o -name "*.el" -print) |
| 129 | ## .log files may be in a different directory for out of source builds | 129 | ## .log files may be in a different directory for out of source builds |
| 130 | LOGFILES = $(patsubst %.el,%.log, \ | 130 | LOGFILES := $(patsubst %.el,%.log, \ |
| 131 | $(patsubst $(srcdir)%,.%,$(ELFILES))) | 131 | $(patsubst $(srcdir)%,.%,$(ELFILES))) |
| 132 | TESTS = $(subst ${srcdir}/,,$(LOGFILES:.log=)) | 132 | TESTS := $(subst ${srcdir}/,,$(LOGFILES:.log=)) |
| 133 | 133 | ||
| 134 | ## If we have to interrupt a hanging test, preserve the log so we can | 134 | ## If we have to interrupt a hanging test, preserve the log so we can |
| 135 | ## see what the problem was. | 135 | ## see what the problem was. |
| @@ -141,6 +141,11 @@ TESTS = $(subst ${srcdir}/,,$(LOGFILES:.log=)) | |||
| 141 | ## Define an alias both with and without the directory name for ease | 141 | ## Define an alias both with and without the directory name for ease |
| 142 | ## of use. | 142 | ## of use. |
| 143 | define test_template | 143 | define test_template |
| 144 | ifeq (,$(patsubst $(srcdir)/src/%,,$(1))) | ||
| 145 | $(1): $(srcdir)/../src/$(1:.log=.c) | ||
| 146 | else | ||
| 147 | $(1): $(srcdir)/../lisp/$(1:.log=.el) | ||
| 148 | endif | ||
| 144 | $(1): | 149 | $(1): |
| 145 | @test ! -f ./$(1).log || mv ./$(1).log ./$(1).log~ | 150 | @test ! -f ./$(1).log || mv ./$(1).log ./$(1).log~ |
| 146 | @${MAKE} ./$(1).log WRITE_LOG= | 151 | @${MAKE} ./$(1).log WRITE_LOG= |
| @@ -157,11 +162,6 @@ $(foreach test,${TESTS},$(eval $(call test_template,${test}))) | |||
| 157 | check-no-automated-subdir: | 162 | check-no-automated-subdir: |
| 158 | test ! -d $(srcdir)/automated | 163 | test ! -d $(srcdir)/automated |
| 159 | 164 | ||
| 160 | ## Include dependencies between test files and the files they test. | ||
| 161 | ## We could do this without the file and eval directly, but then we | ||
| 162 | ## would have to run Emacs for every make invocation, and it might not | ||
| 163 | ## be available during clean. | ||
| 164 | -include make-test-deps.mk | ||
| 165 | ## Rerun all default tests. | 165 | ## Rerun all default tests. |
| 166 | check: mostlyclean check-no-automated-subdir | 166 | check: mostlyclean check-no-automated-subdir |
| 167 | @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}" | 167 | @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}" |
| @@ -175,7 +175,7 @@ check-expensive: mostlyclean check-no-automated-subdir | |||
| 175 | ## logfile is out-of-date with either the test file, or the source | 175 | ## logfile is out-of-date with either the test file, or the source |
| 176 | ## files that the tests depend on. The source file dependencies are | 176 | ## files that the tests depend on. The source file dependencies are |
| 177 | ## determined by a heuristic and does not identify the full dependency | 177 | ## determined by a heuristic and does not identify the full dependency |
| 178 | ## graph. See make-test-deps.emacs-lisp for details. | 178 | ## graph. See test_template for details. |
| 179 | .PHONY: check-maybe | 179 | .PHONY: check-maybe |
| 180 | check-maybe: check-no-automated-subdir | 180 | check-maybe: check-no-automated-subdir |
| 181 | @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}" | 181 | @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}" |
| @@ -183,7 +183,7 @@ check-maybe: check-no-automated-subdir | |||
| 183 | ## Run the tests. | 183 | ## Run the tests. |
| 184 | .PHONY: check-doit | 184 | .PHONY: check-doit |
| 185 | check-doit: ${LOGFILES} | 185 | check-doit: ${LOGFILES} |
| 186 | $(emacs) -l ert -f ert-summarize-tests-batch-and-exit $^ | 186 | @$(emacs) -l ert -f ert-summarize-tests-batch-and-exit $^ |
| 187 | 187 | ||
| 188 | .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean | 188 | .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean |
| 189 | 189 | ||
| @@ -193,7 +193,6 @@ mostlyclean: | |||
| 193 | 193 | ||
| 194 | clean: | 194 | clean: |
| 195 | find . '(' -name '*.log' -o -name '*.log~' ')' $(FIND_DELETE) | 195 | find . '(' -name '*.log' -o -name '*.log~' ')' $(FIND_DELETE) |
| 196 | rm -f make-test-deps.mk | ||
| 197 | 196 | ||
| 198 | bootstrap-clean: clean | 197 | bootstrap-clean: clean |
| 199 | find $(srcdir) -name '*.elc' $(FIND_DELETE) | 198 | find $(srcdir) -name '*.elc' $(FIND_DELETE) |
| @@ -202,11 +201,3 @@ distclean: clean | |||
| 202 | rm -f Makefile | 201 | rm -f Makefile |
| 203 | 202 | ||
| 204 | maintainer-clean: distclean bootstrap-clean | 203 | maintainer-clean: distclean bootstrap-clean |
| 205 | |||
| 206 | make-test-deps.mk: $(ELFILES) make-test-deps.emacs-lisp | ||
| 207 | $(EMACS) --batch -l $(srcdir)/make-test-deps.emacs-lisp \ | ||
| 208 | --eval "(make-test-deps \"$(srcdir)\")" \ | ||
| 209 | 2> $@.tmp | ||
| 210 | # Hack to elide any CANNOT_DUMP=yes chatter. | ||
| 211 | sed '/\.log: /!d' $@.tmp >$@ | ||
| 212 | rm -f $@.tmp | ||
diff --git a/test/lisp/emacs-lisp/cl-lib-tests.el b/test/lisp/emacs-lisp/cl-lib-tests.el index b5946208f10..093cb3476c1 100644 --- a/test/lisp/emacs-lisp/cl-lib-tests.el +++ b/test/lisp/emacs-lisp/cl-lib-tests.el | |||
| @@ -494,12 +494,29 @@ | |||
| 494 | (should-not (cl-typep 1 'cl-lib-test-type))) | 494 | (should-not (cl-typep 1 'cl-lib-test-type))) |
| 495 | 495 | ||
| 496 | (ert-deftest cl-lib-symbol-macrolet () | 496 | (ert-deftest cl-lib-symbol-macrolet () |
| 497 | ;; bug#26325 | ||
| 498 | :expected-result :failed | ||
| 497 | (should (equal (cl-flet ((f (x) (+ x 5))) | 499 | (should (equal (cl-flet ((f (x) (+ x 5))) |
| 498 | (let ((x 5)) | 500 | (let ((x 5)) |
| 499 | (f (+ x 6)))) | 501 | (f (+ x 6)))) |
| 500 | (cl-symbol-macrolet ((f (+ x 6))) | 502 | ;; Go through `eval', otherwise the macro-expansion |
| 501 | (cl-flet ((f (x) (+ x 5))) | 503 | ;; error prevents running the whole test suite :-( |
| 502 | (let ((x 5)) | 504 | (eval '(cl-symbol-macrolet ((f (+ x 6))) |
| 503 | (f f))))))) | 505 | (cl-flet ((f (x) (+ x 5))) |
| 506 | (let ((x 5)) | ||
| 507 | (f f)))) | ||
| 508 | t)))) | ||
| 509 | |||
| 510 | (defmacro cl-lib-symbol-macrolet-4+5 () | ||
| 511 | ;; bug#26068 | ||
| 512 | (let* ((sname "x") | ||
| 513 | (s1 (make-symbol sname)) | ||
| 514 | (s2 (make-symbol sname))) | ||
| 515 | `(cl-symbol-macrolet ((,s1 4) | ||
| 516 | (,s2 5)) | ||
| 517 | (+ ,s1 ,s2)))) | ||
| 518 | |||
| 519 | (ert-deftest cl-lib-symbol-macrolet-2 () | ||
| 520 | (should (equal (cl-lib-symbol-macrolet-4+5) (+ 4 5)))) | ||
| 504 | 521 | ||
| 505 | ;;; cl-lib.el ends here | 522 | ;;; cl-lib.el ends here |
diff --git a/test/lisp/progmodes/js-tests.el b/test/lisp/progmodes/js-tests.el index e030675e07c..8e1bac10cd1 100644 --- a/test/lisp/progmodes/js-tests.el +++ b/test/lisp/progmodes/js-tests.el | |||
| @@ -140,6 +140,43 @@ if (!/[ (:,='\"]/.test(value)) { | |||
| 140 | (font-lock-ensure) | 140 | (font-lock-ensure) |
| 141 | (should (eq (get-text-property (point) 'face) (caddr test)))))) | 141 | (should (eq (get-text-property (point) 'face) (caddr test)))))) |
| 142 | 142 | ||
| 143 | (ert-deftest js-mode-propertize-bug-1 () | ||
| 144 | (with-temp-buffer | ||
| 145 | (js-mode) | ||
| 146 | (save-excursion (insert "x")) | ||
| 147 | (insert "/") | ||
| 148 | ;; The bug was a hang. | ||
| 149 | (should t))) | ||
| 150 | |||
| 151 | (ert-deftest js-mode-propertize-bug-2 () | ||
| 152 | (with-temp-buffer | ||
| 153 | (js-mode) | ||
| 154 | (insert "function f() { | ||
| 155 | function g() | ||
| 156 | { | ||
| 157 | 1 / 2; | ||
| 158 | } | ||
| 159 | |||
| 160 | function h() { | ||
| 161 | ") | ||
| 162 | (save-excursion | ||
| 163 | (insert " | ||
| 164 | 00000000000000000000000000000000000000000000000000; | ||
| 165 | 00000000000000000000000000000000000000000000000000; | ||
| 166 | 00000000000000000000000000000000000000000000000000; | ||
| 167 | 00000000000000000000000000000000000000000000000000; | ||
| 168 | 00000000000000000000000000000000000000000000000000; | ||
| 169 | 00000000000000000000000000000000000000000000000000; | ||
| 170 | 00000000000000000000000000000000000000000000000000; | ||
| 171 | 00000000000000000000000000000000000000000000000000; | ||
| 172 | 00; | ||
| 173 | } | ||
| 174 | } | ||
| 175 | ")) | ||
| 176 | (insert "/") | ||
| 177 | ;; The bug was a hang. | ||
| 178 | (should t))) | ||
| 179 | |||
| 143 | (provide 'js-tests) | 180 | (provide 'js-tests) |
| 144 | 181 | ||
| 145 | ;;; js-tests.el ends here | 182 | ;;; js-tests.el ends here |
diff --git a/test/lisp/url/url-auth-tests.el b/test/lisp/url/url-auth-tests.el index 11e5a479720..30636db083c 100644 --- a/test/lisp/url/url-auth-tests.el +++ b/test/lisp/url/url-auth-tests.el | |||
| @@ -77,6 +77,49 @@ server's WWW-Authenticate header field.") | |||
| 77 | :expected-ha2 "b44272ea65ee4af7fb26c5dba58f6863" | 77 | :expected-ha2 "b44272ea65ee4af7fb26c5dba58f6863" |
| 78 | :expected-response "0d84884d967e04440efc77e9e2b5b561"))) | 78 | :expected-response "0d84884d967e04440efc77e9e2b5b561"))) |
| 79 | 79 | ||
| 80 | (ert-deftest url-auth-test-colonjoin () | ||
| 81 | "Check joining strings with `:'." | ||
| 82 | (should (string= (url-digest-auth-colonjoin) "")) | ||
| 83 | (should (string= (url-digest-auth-colonjoin nil) "")) | ||
| 84 | (should (string= (url-digest-auth-colonjoin nil nil nil) "::")) | ||
| 85 | (should (string= (url-digest-auth-colonjoin "") "")) | ||
| 86 | (should (string= (url-digest-auth-colonjoin "" "") ":")) | ||
| 87 | (should (string= (url-digest-auth-colonjoin "one") "one")) | ||
| 88 | (should (string= (url-digest-auth-colonjoin "one" "two" "three") "one:two:three"))) | ||
| 89 | |||
| 90 | (ert-deftest url-auth-test-digest-ha1 () | ||
| 91 | "Check HA1 computation." | ||
| 92 | (dolist (row url-auth-test-challenges) | ||
| 93 | (should (string= (url-digest-auth-make-ha1 (plist-get row :username) | ||
| 94 | (plist-get row :realm) | ||
| 95 | (plist-get row :password)) | ||
| 96 | (plist-get row :expected-ha1) | ||
| 97 | )))) | ||
| 98 | |||
| 99 | (ert-deftest url-auth-test-digest-ha2 () | ||
| 100 | "Check HA2 computation." | ||
| 101 | (dolist (row url-auth-test-challenges) | ||
| 102 | (should (string= (url-digest-auth-make-ha2 (plist-get row :method) | ||
| 103 | (plist-get row :uri)) | ||
| 104 | (plist-get row :expected-ha2))))) | ||
| 105 | |||
| 106 | (ert-deftest url-auth-test-digest-request-digest () | ||
| 107 | "Check digest response value." | ||
| 108 | (dolist (row url-auth-test-challenges) | ||
| 109 | (should (string= (plist-get row :expected-response) | ||
| 110 | (if (plist-member row :qop) | ||
| 111 | (url-digest-auth-make-request-digest-qop | ||
| 112 | (plist-get row :qop) | ||
| 113 | (plist-get row :expected-ha1) | ||
| 114 | (plist-get row :expected-ha2) | ||
| 115 | (plist-get row :nonce) | ||
| 116 | (plist-get row :nc) | ||
| 117 | (plist-get row :cnonce)) | ||
| 118 | (url-digest-auth-make-request-digest | ||
| 119 | (plist-get row :expected-ha1) | ||
| 120 | (plist-get row :expected-ha2) | ||
| 121 | (plist-get row :nonce))))))) | ||
| 122 | |||
| 80 | (ert-deftest url-auth-test-digest-create-key () | 123 | (ert-deftest url-auth-test-digest-create-key () |
| 81 | "Check user credentials in their hashed form." | 124 | "Check user credentials in their hashed form." |
| 82 | (dolist (challenge url-auth-test-challenges) | 125 | (dolist (challenge url-auth-test-challenges) |
| @@ -223,14 +266,12 @@ test and cannot be passed by arguments to `url-digest-auth'." | |||
| 223 | (progn | 266 | (progn |
| 224 | ;; We don't know these, just check that they exists. | 267 | ;; We don't know these, just check that they exists. |
| 225 | (should (string-match-p ".*response=\".*?\".*" auth)) | 268 | (should (string-match-p ".*response=\".*?\".*" auth)) |
| 226 | ;; url-digest-auth doesn't return these AFAICS. | 269 | (should (string-match-p ".*nc=\".*?\".*" auth)) |
| 227 | ;;; (should (string-match-p ".*nc=\".*?\".*" auth)) | 270 | (should (string-match-p ".*cnonce=\".*?\".*" auth))) |
| 228 | ;;; (should (string-match-p ".*cnonce=\".*?\".*" auth)) | ||
| 229 | ) | ||
| 230 | (should (string-match ".*response=\"\\(.*?\\)\".*" auth)) | 271 | (should (string-match ".*response=\"\\(.*?\\)\".*" auth)) |
| 231 | (should (string= (match-string 1 auth) | 272 | (should (string= (match-string 1 auth) |
| 232 | (plist-get challenge :expected-response)))) | 273 | (plist-get challenge :expected-response)))) |
| 233 | ))) | 274 | ))) |
| 234 | 275 | ||
| 235 | (ert-deftest url-auth-test-digest-auth-opaque () | 276 | (ert-deftest url-auth-test-digest-auth-opaque () |
| 236 | "Check that `opaque' value is added to result when presented by | 277 | "Check that `opaque' value is added to result when presented by |
diff --git a/test/lisp/vc/ediff-ptch-tests.el b/test/lisp/vc/ediff-ptch-tests.el index 9aacb6bd20f..387786ced06 100644 --- a/test/lisp/vc/ediff-ptch-tests.el +++ b/test/lisp/vc/ediff-ptch-tests.el | |||
| @@ -41,25 +41,31 @@ index 6a07f80..6e8e947 100644 | |||
| 41 | 41 | ||
| 42 | (ert-deftest ediff-ptch-test-bug26084 () | 42 | (ert-deftest ediff-ptch-test-bug26084 () |
| 43 | "Test for http://debbugs.gnu.org/26084 ." | 43 | "Test for http://debbugs.gnu.org/26084 ." |
| 44 | (let* ((tmpdir temporary-file-directory) | 44 | (skip-unless (executable-find "git")) |
| 45 | (foo (expand-file-name "foo" tmpdir)) | 45 | (skip-unless (executable-find ediff-patch-program)) |
| 46 | (patch (expand-file-name "foo.diff" tmpdir)) | 46 | (let* ((tmpdir (make-temp-file "ediff-ptch-test" t)) |
| 47 | (qux (expand-file-name "qux.txt" foo)) | 47 | (default-directory (file-name-as-directory tmpdir)) |
| 48 | (bar (expand-file-name "bar.txt" foo)) | 48 | (patch (make-temp-file "ediff-ptch-test")) |
| 49 | (cmd " | 49 | (qux (expand-file-name "qux.txt" tmpdir)) |
| 50 | mkdir -p foo | 50 | (bar (expand-file-name "bar.txt" tmpdir)) |
| 51 | cd foo | 51 | (git-program (executable-find "git"))) |
| 52 | echo 'qux here' > qux.txt | 52 | ;; Create repository. |
| 53 | echo 'bar here' > bar.txt | 53 | (with-temp-buffer |
| 54 | git init | 54 | (insert "qux here\n") |
| 55 | git add . && git commit -m 'Test repository.' | 55 | (write-region nil nil qux nil 'silent) |
| 56 | echo 'foo here' > qux.txt | 56 | (erase-buffer) |
| 57 | echo 'foo here' > bar.txt | 57 | (insert "bar here\n") |
| 58 | git diff > ../foo.diff | 58 | (write-region nil nil bar nil 'silent)) |
| 59 | git reset --hard HEAD | 59 | (call-process git-program nil nil nil "init") |
| 60 | ")) | 60 | (call-process git-program nil nil nil "add" ".") |
| 61 | (setq default-directory tmpdir) | 61 | (call-process git-program nil nil nil "commit" "-m" "Test repository.") |
| 62 | (call-process-shell-command cmd) | 62 | ;; Update repo., save the diff and reset to initial state. |
| 63 | (with-temp-buffer | ||
| 64 | (insert "foo here\n") | ||
| 65 | (write-region nil nil qux nil 'silent) | ||
| 66 | (write-region nil nil bar nil 'silent)) | ||
| 67 | (call-process git-program nil `(:file ,patch) nil "diff") | ||
| 68 | (call-process git-program nil nil nil "reset" "--hard" "HEAD") | ||
| 63 | (find-file patch) | 69 | (find-file patch) |
| 64 | (unwind-protect | 70 | (unwind-protect |
| 65 | (let* ((info | 71 | (let* ((info |
| @@ -76,23 +82,27 @@ git reset --hard HEAD | |||
| 76 | (dolist (x (list (cons patch1 bar) (cons patch2 qux))) | 82 | (dolist (x (list (cons patch1 bar) (cons patch2 qux))) |
| 77 | (with-temp-buffer | 83 | (with-temp-buffer |
| 78 | (insert (car x)) | 84 | (insert (car x)) |
| 79 | (call-shell-region (point-min) | 85 | (call-process-region (point-min) |
| 80 | (point-max) | 86 | (point-max) |
| 81 | (format "%s %s %s %s" | 87 | ediff-patch-program |
| 82 | ediff-patch-program | 88 | nil nil nil |
| 83 | ediff-patch-options | 89 | "-b" (cdr x)))) |
| 84 | ediff-backup-specs | ||
| 85 | (cdr x))))) | ||
| 86 | ;; Check backup files were saved correctly. | 90 | ;; Check backup files were saved correctly. |
| 87 | (dolist (x (list qux bar)) | 91 | (dolist (x (list qux bar)) |
| 88 | (should-not (string= (with-temp-buffer | 92 | (let ((backup |
| 89 | (insert-file-contents x) | 93 | (car |
| 90 | (buffer-string)) | 94 | (directory-files |
| 91 | (with-temp-buffer | 95 | tmpdir 'full |
| 92 | (insert-file-contents (concat x ediff-backup-extension)) | 96 | (concat (file-name-nondirectory x) "."))))) |
| 93 | (buffer-string)))))) | 97 | (should-not |
| 94 | (delete-directory foo 'recursive) | 98 | (string= (with-temp-buffer |
| 95 | (delete-file patch)))) | 99 | (insert-file-contents x) |
| 100 | (buffer-string)) | ||
| 101 | (with-temp-buffer | ||
| 102 | (insert-file-contents backup) | ||
| 103 | (buffer-string)))))) | ||
| 104 | (delete-directory tmpdir 'recursive) | ||
| 105 | (delete-file patch))))) | ||
| 96 | 106 | ||
| 97 | 107 | ||
| 98 | (provide 'ediff-ptch-tests) | 108 | (provide 'ediff-ptch-tests) |
diff --git a/test/make-test-deps.emacs-lisp b/test/make-test-deps.emacs-lisp deleted file mode 100644 index 609e9276186..00000000000 --- a/test/make-test-deps.emacs-lisp +++ /dev/null | |||
| @@ -1,98 +0,0 @@ | |||
| 1 | ;; -*- emacs-lisp -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2015-2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Commentary: | ||
| 21 | |||
| 22 | ;; This file generates dependencies between test files and the files | ||
| 23 | ;; that they test. | ||
| 24 | |||
| 25 | ;; It has an .emacs-lisp extension because it makes the Makefile easier! | ||
| 26 | |||
| 27 | (require 'seq) | ||
| 28 | |||
| 29 | (defun make-test-deps (src-dir) | ||
| 30 | (let ((src-dir (file-truename src-dir))) | ||
| 31 | (message | ||
| 32 | "%s" | ||
| 33 | (concat | ||
| 34 | (make-test-deps-lisp src-dir) | ||
| 35 | (make-test-deps-src src-dir))))) | ||
| 36 | |||
| 37 | (defun make-test-deps-lisp (src-dir) | ||
| 38 | (mapconcat | ||
| 39 | (lambda (file-without-suffix) | ||
| 40 | (format "./%s-tests.log: %s/../%s.el\n" | ||
| 41 | file-without-suffix | ||
| 42 | src-dir | ||
| 43 | file-without-suffix)) | ||
| 44 | (make-test-test-files src-dir "lisp") "")) | ||
| 45 | |||
| 46 | (defun make-test-deps-src (src-dir) | ||
| 47 | (mapconcat | ||
| 48 | (lambda (file-without-suffix) | ||
| 49 | (format "./%s-tests.log: %s/../%s.c\n" | ||
| 50 | file-without-suffix | ||
| 51 | src-dir | ||
| 52 | file-without-suffix)) | ||
| 53 | (make-test-test-files src-dir "src") "")) | ||
| 54 | |||
| 55 | (defun make-test-test-files (src-dir sub-src-dir) | ||
| 56 | (make-test-munge-files | ||
| 57 | src-dir | ||
| 58 | (directory-files-recursively | ||
| 59 | (concat src-dir "/" sub-src-dir) | ||
| 60 | ".*-tests.el$"))) | ||
| 61 | |||
| 62 | (defun make-test-munge-files (src-dir files) | ||
| 63 | (make-test-sans-suffix | ||
| 64 | (make-test-de-stem | ||
| 65 | src-dir | ||
| 66 | (make-test-no-legacy | ||
| 67 | (make-test-no-test-dir | ||
| 68 | (make-test-no-resources | ||
| 69 | files)))))) | ||
| 70 | |||
| 71 | (defun make-test-sans-suffix (files) | ||
| 72 | (mapcar | ||
| 73 | (lambda (file) | ||
| 74 | (substring file 0 -9)) | ||
| 75 | files)) | ||
| 76 | |||
| 77 | (defun make-test-de-stem (stem files) | ||
| 78 | (mapcar | ||
| 79 | (lambda (file) | ||
| 80 | (substring | ||
| 81 | file | ||
| 82 | (+ 1 (length stem)))) | ||
| 83 | files)) | ||
| 84 | |||
| 85 | (defun make-test-no-legacy (list) | ||
| 86 | (make-test-remove list "legacy/")) | ||
| 87 | |||
| 88 | (defun make-test-no-resources (list) | ||
| 89 | (make-test-remove list "-resources/")) | ||
| 90 | |||
| 91 | (defun make-test-no-test-dir (list) | ||
| 92 | (make-test-remove list "-tests/")) | ||
| 93 | |||
| 94 | (defun make-test-remove (list match) | ||
| 95 | (seq-remove | ||
| 96 | (lambda (file) | ||
| 97 | (string-match-p match file)) | ||
| 98 | list)) | ||