diff options
| author | Eric Ludlam | 2019-10-27 21:01:54 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2019-10-31 19:05:35 -0400 |
| commit | cf59afb7e1403365a9cea4655e1c0c92fade2304 (patch) | |
| tree | 6b9cdc5a58f2c2174cfba5c1c3a7b4d46d7d399c | |
| parent | f69e2aa104209090d5487a7382473ec38b43e9c7 (diff) | |
| download | emacs-cf59afb7e1403365a9cea4655e1c0c92fade2304.tar.gz emacs-cf59afb7e1403365a9cea4655e1c0c92fade2304.zip | |
* test/lisp/cedet/semantic-utest-ia.el: Update from upstream
Merge content from CEDET on SF to bring in additional test points
and support more types of languages.
(semantic-utest-ia-struct.cpp, semantic-utest-ia-templates.cpp)
(semantic-utest-ia-using.cpp, semantic-utest-ia-nsp.cpp)
(semantic-utest-ia-localvars.cpp, semantic-utest-ia-varnamse.java)
(semantic-utest-ia-wisent.wy, semantic-utest-ia-texi)
(semantic-utest-ia-make, semantic-utest-ia-srecoder): New test points
(semantic-ia-utest-buffer): Use comment-start-skip when looking
for test point tokens.
Capture errors ignoring debugger to enable test for empty results.
Improve output from test diagnostics.
(semantic-ia-utest-buffer-refs): Use comment-start-skip to find
test point tokens.
Author: Eric Ludlam <zappo@gnu.org>
| -rw-r--r-- | test/lisp/cedet/semantic-utest-ia.el | 107 |
1 files changed, 92 insertions, 15 deletions
diff --git a/test/lisp/cedet/semantic-utest-ia.el b/test/lisp/cedet/semantic-utest-ia.el index f83a89a8683..61d7ea370e2 100644 --- a/test/lisp/cedet/semantic-utest-ia.el +++ b/test/lisp/cedet/semantic-utest-ia.el | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | ;; Each file has cursor keys in them of the form: | 27 | ;; Each file has cursor keys in them of the form: |
| 28 | ;; // -#- ("ans1" "ans2" ) | 28 | ;; // -#- ("ans1" "ans2" ) |
| 29 | ;; where # is 1, 2, 3, etc, and some sort of answer list. | 29 | ;; where # is 1, 2, 3, etc, and some sort of answer list. |
| 30 | ;; (Replace // with contents of comment-start for the language being tested.) | ||
| 30 | 31 | ||
| 31 | ;;; Code: | 32 | ;;; Code: |
| 32 | (require 'semantic) | 33 | (require 'semantic) |
| @@ -59,8 +60,38 @@ | |||
| 59 | (should (file-exists-p tst)) | 60 | (should (file-exists-p tst)) |
| 60 | (should-not (semantic-ia-utest tst)))) | 61 | (should-not (semantic-ia-utest tst)))) |
| 61 | 62 | ||
| 62 | (ert-deftest semantic-utest-ia-friends.cpp () | 63 | (ert-deftest semantic-utest-ia-struct.cpp () |
| 63 | (let ((tst (expand-file-name "testfriends.cpp" semantic-utest-test-directory))) | 64 | (let ((tst (expand-file-name "teststruct.cpp" semantic-utest-test-directory))) |
| 65 | (should (file-exists-p tst)) | ||
| 66 | (should-not (semantic-ia-utest tst)))) | ||
| 67 | |||
| 68 | ;;(ert-deftest semantic-utest-ia-union.cpp () | ||
| 69 | ;; (let ((tst (expand-file-name "testunion.cpp" semantic-utest-test-directory))) | ||
| 70 | ;; (should (file-exists-p tst)) | ||
| 71 | ;; (should-not (semantic-ia-utest tst)))) | ||
| 72 | |||
| 73 | (ert-deftest semantic-utest-ia-templates.cpp () | ||
| 74 | (let ((tst (expand-file-name "testtemplates.cpp" semantic-utest-test-directory))) | ||
| 75 | (should (file-exists-p tst)) | ||
| 76 | (should-not (semantic-ia-utest tst)))) | ||
| 77 | |||
| 78 | ;;(ert-deftest semantic-utest-ia-friends.cpp () | ||
| 79 | ;; (let ((tst (expand-file-name "testfriends.cpp" semantic-utest-test-directory))) | ||
| 80 | ;; (should (file-exists-p tst)) | ||
| 81 | ;; (should-not (semantic-ia-utest tst)))) | ||
| 82 | |||
| 83 | (ert-deftest semantic-utest-ia-using.cpp () | ||
| 84 | (let ((tst (expand-file-name "testusing.cpp" semantic-utest-test-directory))) | ||
| 85 | (should (file-exists-p tst)) | ||
| 86 | (should-not (semantic-ia-utest tst)))) | ||
| 87 | |||
| 88 | (ert-deftest semantic-utest-ia-nsp.cpp () | ||
| 89 | (let ((tst (expand-file-name "testnsp.cpp" semantic-utest-test-directory))) | ||
| 90 | (should (file-exists-p tst)) | ||
| 91 | (should-not (semantic-ia-utest tst)))) | ||
| 92 | |||
| 93 | (ert-deftest semantic-utest-ia-localvars.cpp () | ||
| 94 | (let ((tst (expand-file-name "testlocalvars.cpp" semantic-utest-test-directory))) | ||
| 64 | (should (file-exists-p tst)) | 95 | (should (file-exists-p tst)) |
| 65 | (should-not (semantic-ia-utest tst)))) | 96 | (should-not (semantic-ia-utest tst)))) |
| 66 | 97 | ||
| @@ -84,6 +115,36 @@ | |||
| 84 | (should (file-exists-p tst)) | 115 | (should (file-exists-p tst)) |
| 85 | (should-not (semantic-ia-utest tst)))) | 116 | (should-not (semantic-ia-utest tst)))) |
| 86 | 117 | ||
| 118 | (ert-deftest semantic-utest-ia-varnamse.java () | ||
| 119 | (let ((tst (expand-file-name "testvarnames.java" semantic-utest-test-directory))) | ||
| 120 | (should (file-exists-p tst)) | ||
| 121 | (should-not (semantic-ia-utest tst)))) | ||
| 122 | |||
| 123 | ;;(ert-deftest semantic-utest-ia-f90.f90 () | ||
| 124 | ;; (let ((tst (expand-file-name "testf90.f90" semantic-utest-test-directory))) | ||
| 125 | ;; (should (file-exists-p tst)) | ||
| 126 | ;; (should-not (semantic-ia-utest tst)))) | ||
| 127 | |||
| 128 | (ert-deftest semantic-utest-ia-wisent.wy () | ||
| 129 | (let ((tst (expand-file-name "testwisent.wy" semantic-utest-test-directory))) | ||
| 130 | (should (file-exists-p tst)) | ||
| 131 | (should-not (semantic-ia-utest tst)))) | ||
| 132 | |||
| 133 | (ert-deftest semantic-utest-ia-texi () | ||
| 134 | (let ((tst (expand-file-name "test.texi" semantic-utest-test-directory))) | ||
| 135 | (should (file-exists-p tst)) | ||
| 136 | (should-not (semantic-ia-utest tst)))) | ||
| 137 | |||
| 138 | (ert-deftest semantic-utest-ia-make () | ||
| 139 | (let ((tst (expand-file-name "test.mk" semantic-utest-test-directory))) | ||
| 140 | (should (file-exists-p tst)) | ||
| 141 | (should-not (semantic-ia-utest tst)))) | ||
| 142 | |||
| 143 | (ert-deftest semantic-utest-ia-srecoder () | ||
| 144 | (let ((tst (expand-file-name "test.srt" semantic-utest-test-directory))) | ||
| 145 | (should (file-exists-p tst)) | ||
| 146 | (should-not (semantic-ia-utest tst)))) | ||
| 147 | |||
| 87 | ;;; Core testing utility | 148 | ;;; Core testing utility |
| 88 | (defun semantic-ia-utest (testfile) | 149 | (defun semantic-ia-utest (testfile) |
| 89 | "Run the semantic ia unit test against stored sources." | 150 | "Run the semantic ia unit test against stored sources." |
| @@ -127,8 +188,10 @@ | |||
| 127 | 188 | ||
| 128 | ;; Keep looking for test points until we run out. | 189 | ;; Keep looking for test points until we run out. |
| 129 | (while (save-excursion | 190 | (while (save-excursion |
| 130 | (setq regex-p (concat "//\\s-*-" (number-to-string idx) "-" ) | 191 | (setq regex-p (concat "\\(" comment-start-skip "\\)\\s-*-" |
| 131 | regex-a (concat "//\\s-*#" (number-to-string idx) "#" )) | 192 | (number-to-string idx) "-" ) |
| 193 | regex-a (concat "\\(" comment-start-skip "\\)\\s-*#" | ||
| 194 | (number-to-string idx) "#" )) | ||
| 132 | (goto-char (point-min)) | 195 | (goto-char (point-min)) |
| 133 | (save-match-data | 196 | (save-match-data |
| 134 | (when (re-search-forward regex-p nil t) | 197 | (when (re-search-forward regex-p nil t) |
| @@ -141,13 +204,18 @@ | |||
| 141 | (save-excursion | 204 | (save-excursion |
| 142 | 205 | ||
| 143 | (goto-char p) | 206 | (goto-char p) |
| 207 | (skip-chars-backward " ") ;; some languages need a space. | ||
| 144 | 208 | ||
| 145 | (let* ((ctxt (semantic-analyze-current-context)) | 209 | (let* ((ctxt (semantic-analyze-current-context)) |
| 210 | ;; TODO - fix the NOTFOUND case to be nil and not an error when finding | ||
| 211 | ;; completions, then remove the below debug-on-error setting. | ||
| 212 | (debug-on-error nil) | ||
| 146 | (acomp | 213 | (acomp |
| 147 | (condition-case nil | 214 | (condition-case err |
| 148 | (semantic-analyze-possible-completions ctxt) | 215 | (semantic-analyze-possible-completions ctxt) |
| 149 | (error nil)))) | 216 | ((error user-error) nil)) |
| 150 | (setq actual (mapcar 'semantic-tag-name acomp))) | 217 | )) |
| 218 | (setq actual (mapcar 'semantic-format-tag-name acomp))) | ||
| 151 | 219 | ||
| 152 | (goto-char a) | 220 | (goto-char a) |
| 153 | 221 | ||
| @@ -157,8 +225,14 @@ | |||
| 157 | (error (setq desired (format " FAILED TO PARSE: %S" | 225 | (error (setq desired (format " FAILED TO PARSE: %S" |
| 158 | bss))))) | 226 | bss))))) |
| 159 | 227 | ||
| 228 | (setq actual (sort actual 'string<)) | ||
| 229 | (setq desired (sort desired 'string<)) | ||
| 230 | |||
| 160 | (if (equal actual desired) | 231 | (if (equal actual desired) |
| 161 | (setq pass (cons idx pass)) | 232 | (prog1 |
| 233 | (setq pass (cons idx pass)) | ||
| 234 | ;;(message "PASS: %S" actual) | ||
| 235 | ) | ||
| 162 | (setq fail (cons | 236 | (setq fail (cons |
| 163 | (list | 237 | (list |
| 164 | (format "Failed %d. Desired: %S Actual %S" | 238 | (format "Failed %d. Desired: %S Actual %S" |
| @@ -171,7 +245,7 @@ | |||
| 171 | ) | 245 | ) |
| 172 | 246 | ||
| 173 | (when fail | 247 | (when fail |
| 174 | (cons "COMPLETION SUBTEST" fail)) | 248 | (cons "COMPLETION SUBTEST" (reverse fail))) |
| 175 | )) | 249 | )) |
| 176 | 250 | ||
| 177 | (defun semantic-ia-utest-buffer-refs () | 251 | (defun semantic-ia-utest-buffer-refs () |
| @@ -189,7 +263,8 @@ | |||
| 189 | ) | 263 | ) |
| 190 | ;; Keep looking for test points until we run out. | 264 | ;; Keep looking for test points until we run out. |
| 191 | (while (save-excursion | 265 | (while (save-excursion |
| 192 | (setq regex-p (concat "//\\s-*\\^" (number-to-string idx) "^" ) | 266 | (setq regex-p (concat "\\(" comment-start-skip |
| 267 | "\\)\\s-*\\^" (number-to-string idx) "^" ) | ||
| 193 | ) | 268 | ) |
| 194 | (goto-char (point-min)) | 269 | (goto-char (point-min)) |
| 195 | (save-match-data | 270 | (save-match-data |
| @@ -295,7 +370,8 @@ | |||
| 295 | ) | 370 | ) |
| 296 | ;; Keep looking for test points until we run out. | 371 | ;; Keep looking for test points until we run out. |
| 297 | (while (save-excursion | 372 | (while (save-excursion |
| 298 | (setq regex-p (concat "//\\s-*\\%" (number-to-string idx) "%" ) | 373 | (setq regex-p (concat "\\(" comment-start-skip "\\)\\s-*\\%" |
| 374 | (number-to-string idx) "%" ) | ||
| 299 | ) | 375 | ) |
| 300 | (goto-char (point-min)) | 376 | (goto-char (point-min)) |
| 301 | (save-match-data | 377 | (save-match-data |
| @@ -307,7 +383,7 @@ | |||
| 307 | tag) | 383 | tag) |
| 308 | 384 | ||
| 309 | (setq actual-result (semantic-symref-find-references-by-name | 385 | (setq actual-result (semantic-symref-find-references-by-name |
| 310 | (semantic-tag-name tag) 'target | 386 | (semantic-format-tag-name tag) 'target |
| 311 | 'symref-tool-used)) | 387 | 'symref-tool-used)) |
| 312 | 388 | ||
| 313 | (if (not actual-result) | 389 | (if (not actual-result) |
| @@ -393,13 +469,14 @@ tag that contains point, and return that." | |||
| 393 | ) | 469 | ) |
| 394 | ;; Keep looking for test points until we run out. | 470 | ;; Keep looking for test points until we run out. |
| 395 | (while (save-excursion | 471 | (while (save-excursion |
| 396 | (setq regex-p (concat "//\\s-*@" | 472 | (setq regex-p (concat "\\(" comment-start-skip "\\)\\s-*@" |
| 397 | (number-to-string idx) | 473 | (number-to-string idx) |
| 398 | "@\\s-+\\(\\w+\\)" )) | 474 | "@\\s-+\\w+" )) |
| 399 | (goto-char (point-min)) | 475 | (goto-char (point-min)) |
| 400 | (save-match-data | 476 | (save-match-data |
| 401 | (when (re-search-forward regex-p nil t) | 477 | (when (re-search-forward regex-p nil t) |
| 402 | (goto-char (match-beginning 1)) | 478 | (goto-char (match-end 0)) |
| 479 | (skip-syntax-backward "w") | ||
| 403 | (setq desired (read (buffer-substring (point) (point-at-eol)))) | 480 | (setq desired (read (buffer-substring (point) (point-at-eol)))) |
| 404 | (setq start (match-beginning 0)) | 481 | (setq start (match-beginning 0)) |
| 405 | (goto-char start) | 482 | (goto-char start) |