| 1 |
;;; -*- lexical-binding: t; -*- |
| 2 |
|
| 3 |
;; This file is part of GCC. |
| 4 |
|
| 5 |
;; GCC is free software: you can redistribute it and/or modify it |
| 6 |
;; under the terms of the GNU General Public License as published by |
| 7 |
;; the Free Software Foundation, either version 3 of the License, or |
| 8 |
;; (at your option) any later version. |
| 9 |
|
| 10 |
;; GCC is distributed in the hope that it will be useful, but WITHOUT |
| 11 |
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 12 |
;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
| 13 |
;; License for more details. |
| 14 |
|
| 15 |
;; You should have received a copy of the GNU General Public License |
| 16 |
;; along with GCC. If not, see <https://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
;;; Commentary: |
| 19 |
|
| 20 |
;;; Usage: |
| 21 |
;; $ emacs -batch -l mdcompact.el -l mdcompact-testsuite.el -f ert-run-tests-batch-and-exit |
| 22 |
|
| 23 |
;;; Code: |
| 24 |
|
| 25 |
(require 'mdcompact) |
| 26 |
(require 'ert) |
| 27 |
|
| 28 |
(defconst mdcompat-test-directory (concat (file-name-directory |
| 29 |
(or load-file-name |
| 30 |
buffer-file-name)) |
| 31 |
"tests/")) |
| 32 |
|
| 33 |
(defun mdcompat-test-run (f) |
| 34 |
(with-temp-buffer |
| 35 |
(insert-file-contents f) |
| 36 |
(mdcomp-run-at-point) |
| 37 |
(let ((a (buffer-string)) |
| 38 |
(b (with-temp-buffer |
| 39 |
(insert-file-contents (concat f ".out")) |
| 40 |
(buffer-string)))) |
| 41 |
(should (string= a b))))) |
| 42 |
|
| 43 |
(defmacro mdcompat-gen-tests () |
| 44 |
`(progn |
| 45 |
,@(cl-loop |
| 46 |
for f in (directory-files mdcompat-test-directory t "md$") |
| 47 |
collect |
| 48 |
`(ert-deftest ,(intern (concat "mdcompat-test-" |
| 49 |
(file-name-sans-extension |
| 50 |
(file-name-nondirectory f)))) |
| 51 |
() |
| 52 |
(mdcompat-test-run ,f))))) |
| 53 |
|
| 54 |
(mdcompat-gen-tests) |
| 55 |
|
| 56 |
;;; mdcompact-testsuite.el ends here |