summaryrefslogtreecommitdiff
path: root/test/lisp/cedet/semantic/format-tests.el
diff options
context:
space:
mode:
authorStefan Kangas <stefan@marxist.se>2021-02-10 06:40:13 +0100
committerStefan Kangas <stefan@marxist.se>2021-02-10 06:43:39 +0100
commitdef546679fd93a4a1d049d9d3021166bf66a0e26 (patch)
tree4872a255d1d9824165a968d9ac1c8c65c6b13708 /test/lisp/cedet/semantic/format-tests.el
parentc735ec94545d1ca726d6cdcfdf4b0847e55330d9 (diff)
downloademacs-def546679fd93a4a1d049d9d3021166bf66a0e26.tar.gz
; * test/lisp/cedet/semantic/format-tests.el: Minor cleanup.
Diffstat (limited to 'test/lisp/cedet/semantic/format-tests.el')
-rw-r--r--test/lisp/cedet/semantic/format-tests.el108
1 files changed, 46 insertions, 62 deletions
diff --git a/test/lisp/cedet/semantic/format-tests.el b/test/lisp/cedet/semantic/format-tests.el
index a9eb4489d59..e82c97b4c43 100644
--- a/test/lisp/cedet/semantic/format-tests.el
+++ b/test/lisp/cedet/semantic/format-tests.el
@@ -20,7 +20,7 @@
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
-;;
+
;; Unit tests for the formatting feature.
;;
;; Using test code from the tests source directory, parse the source
@@ -40,71 +40,55 @@
)
"List of files to run unit tests in.")
-(defvar semantic-fmt-utest-error-log-list nil
- "Log errors during testing in this variable.")
-
(ert-deftest semantic-fmt-utest ()
- "Visit all file entries, and run formatting test.
-Files to visit are in `semantic-fmt-utest-file-list'."
+ "Visit all file entries, and run formatting test. "
(save-current-buffer
(semantic-mode 1)
- (let ((fl semantic-fmt-utest-file-list))
- (dolist (fname fl)
+ (dolist (fname semantic-fmt-utest-file-list)
+ (let ((fb (find-buffer-visiting fname))
+ (b (semantic-find-file-noselect fname))
+ (tags nil))
(save-current-buffer
- (let ((fb (find-buffer-visiting fname))
- (b (semantic-find-file-noselect fname))
- (tags nil))
-
- (save-current-buffer
- (set-buffer b)
- (should (semantic-active-p))
- ;;(error "Cannot open %s for format tests" fname))
-
- ;; This will force a reparse, removing any chance of semanticdb cache
- ;; using stale data.
- (semantic-clear-toplevel-cache)
- ;; Force the reparse
- (setq tags (semantic-fetch-tags))
-
- (save-excursion
- (while tags
- (let* ((T (car tags))
- (start (semantic-tag-end T))
- (end (if (cdr tags)
- (semantic-tag-start (car (cdr tags)))
- (point-max)))
- (TESTS nil)
- )
- (goto-char start)
- ;; Scan the space between tags for all test condition matches.
- (while (re-search-forward "## \\([a-z-]+\\) \"\\([^\n\"]+\\)\"$" end t)
- (push (cons (match-string 1) (match-string 2)) TESTS))
- (setq TESTS (nreverse TESTS))
-
- (dolist (TST TESTS)
- (let* ( ;; For each test, convert CAR into a semantic-format-tag* fcn
- (sym (intern (concat "semantic-format-tag-" (car TST))))
- ;; Convert the desired result from a string syntax to a string.
- (desired (cdr TST))
- ;; What does the fmt function do?
- (actual (funcall sym T))
- )
- (when (not (string= desired actual))
- (should-not (list "Desired" desired
- "Actual" actual
- "Formatter" (car TST))))
- )))
- (setq tags (cdr tags)))
-
- ))
-
- ;; If it wasn't already in memory, whack it.
- (when (and b (not fb))
- (kill-buffer b)))
- ))
-
- )))
-
+ (set-buffer b)
+ (should (semantic-active-p))
+ ;;(error "Cannot open %s for format tests" fname))
+
+ ;; This will force a reparse, removing any chance of semanticdb cache
+ ;; using stale data.
+ (semantic-clear-toplevel-cache)
+ ;; Force the reparse
+ (setq tags (semantic-fetch-tags))
+
+ (save-excursion
+ (while tags
+ (let* ((T (car tags))
+ (start (semantic-tag-end T))
+ (end (if (cdr tags)
+ (semantic-tag-start (car (cdr tags)))
+ (point-max)))
+ (TESTS nil))
+ (goto-char start)
+ ;; Scan the space between tags for all test condition matches.
+ (while (re-search-forward "## \\([a-z-]+\\) \"\\([^\n\"]+\\)\"$" end t)
+ (push (cons (match-string 1) (match-string 2)) TESTS))
+ (setq TESTS (nreverse TESTS))
+
+ (dolist (TST TESTS)
+ (let* ( ;; For each test, convert CAR into a semantic-format-tag* fcn
+ (sym (intern (concat "semantic-format-tag-" (car TST))))
+ ;; Convert the desired result from a string syntax to a string.
+ (desired (cdr TST))
+ ;; What does the fmt function do?
+ (actual (funcall sym T)))
+ (when (not (string= desired actual))
+ (should-not (list "Desired" desired
+ "Actual" actual
+ "Formatter" (car TST)))))))
+ (setq tags (cdr tags)))))
+
+ ;; If it wasn't already in memory, whack it.
+ (when (and b (not fb))
+ (kill-buffer b))))))
(provide 'format-tests)