|
123 | 123 | (warn 'missing-test :test-name id))) |
124 | 124 |
|
125 | 125 | (defun get-tests (&key tests tags package reintern-package |
| 126 | + exclude-tests exclude-tags |
126 | 127 | &aux (db *test-db*)) |
127 | 128 | "finds tests by names, tags, and package |
128 | 129 |
|
129 | 130 | if reintern-package is provided, reintern all symbols provided for tests |
130 | 131 | and tags into the reintern-package. Mostly provided for easing conversion |
131 | 132 | of lisp-unit1 test suites |
132 | 133 | " |
133 | | - (%log-around (#?"get-tests:${tests} tags:${tags} package:${package} reintern-package:${reintern-package}" |
| 134 | + (%log-around (#?"get-tests:${tests} tags:${tags} package:${package} reintern-package:${reintern-package} exclude-tags:${exclude-tags} exclude-tests:${ exclude-tests }" |
134 | 135 | :start-level 0) |
| 136 | + |
135 | 137 | (when reintern-package |
136 | | - (setf tests (%in-package tests reintern-package)) |
137 | | - (setf tags (%in-package tags reintern-package))) |
| 138 | + (setf tests (alexandria:ensure-list |
| 139 | + (%in-package tests reintern-package))) |
| 140 | + (setf tags (alexandria:ensure-list |
| 141 | + (%in-package tags reintern-package))) |
| 142 | + (setf exclude-tests (alexandria:ensure-list |
| 143 | + (%in-package exclude-tests reintern-package))) |
| 144 | + (setf exclude-tags (alexandria:ensure-list |
| 145 | + (%in-package exclude-tags reintern-package)))) |
138 | 146 | ;; defaults to pulling up all tests in the current package |
139 | 147 | (when (and (null tests) (null tags) (null package)) |
140 | 148 | (setf package (package-name *package*))) |
141 | | - (remove-duplicates |
142 | | - (append |
143 | | - (iter (for p in (alexandria:ensure-list package)) |
144 | | - (appending (head (gethash (find-package p) (package-index db))))) |
145 | | - (iter (for tag in (alexandria:ensure-list tags)) |
146 | | - (appending (head (gethash tag (tag-index db))))) |
147 | | - (iter (for name in (alexandria:ensure-list tests)) |
148 | | - (for test = (%to-test name)) |
149 | | - (when test |
150 | | - (collect test)))) |
151 | | - :key #'name))) |
| 149 | + (collectors:with-collector-output (out) |
| 150 | + (collectors:with-appender (gathered) |
| 151 | + (iter (for p in (alexandria:ensure-list package)) |
| 152 | + (gathered (head (gethash (find-package p) (package-index db))))) |
| 153 | + (iter (for tag in (alexandria:ensure-list tags)) |
| 154 | + (gathered (head (gethash tag (tag-index db))))) |
| 155 | + (iter (for name in (alexandria:ensure-list tests)) |
| 156 | + (for test = (%to-test name)) |
| 157 | + (gathered test)) |
| 158 | + (flet ((excluded? (test) |
| 159 | + (or (and (find (name test) exclude-tests) |
| 160 | + (not (find (name test) tests))) |
| 161 | + (iter (for tag in (tags test)) |
| 162 | + (thereis (and (find tag exclude-tags) |
| 163 | + (not (find tag tags)))))))) |
| 164 | + (iter (for test in (gathered)) |
| 165 | + (unless (or (null test) |
| 166 | + (excluded? test) |
| 167 | + (find test (out))) |
| 168 | + (out test)))) |
| 169 | + )))) |
152 | 170 |
|
153 | 171 |
|
154 | 172 |
|
|
468 | 486 |
|
469 | 487 |
|
470 | 488 | (defgeneric run-tests (&key |
471 | | - tests tags package name |
| 489 | + tests tags package name exclude-tests exclude-tags |
472 | 490 | test-contexts |
473 | 491 | run-contexts |
474 | 492 | reintern-package) |
|
492 | 510 |
|
493 | 511 | run-contexts is a list of contexts that will be applied around the entire |
494 | 512 | suite (around signals) |
| 513 | +
|
| 514 | + exclude-tests, exclude-tags: tests / tags to remove from the |
| 515 | + run. explicit inclusion overrides, explicit exclusion, overrides |
| 516 | + implicit inclusion |
| 517 | + EG: (define-test test-takes-forever (manual stuff) ...) |
| 518 | + (find-test :tags 'stuff :exclude-tags 'manual) |
| 519 | + will not find test-takes-forever |
| 520 | + (find-test :tags '(stuff manual) :exclude-tags 'manual) |
| 521 | + (find-test :tests 'test-takes-forever :exclude-tags 'manual) |
| 522 | + both will find test-takes-forever |
495 | 523 | ") |
496 | | - (:method :around (&key tests tags package name |
| 524 | + (:method :around (&key tests tags package name exclude-tests exclude-tags |
497 | 525 | test-contexts run-contexts |
498 | 526 | reintern-package) |
499 | 527 | (declare (ignorable tests tags package test-contexts run-contexts |
| 528 | + exclude-tests exclude-tags |
500 | 529 | reintern-package name)) |
501 | 530 | (%log-around (#?"Running tests${name}:${tests} tags:${tags} package:${package} context:${test-contexts},${run-contexts}") |
502 | 531 | (call-next-method))) |
503 | 532 | (:method (&rest args |
504 | 533 | &key |
505 | | - tests tags package reintern-package name |
| 534 | + tests tags package reintern-package name exclude-tests exclude-tags |
506 | 535 | test-contexts |
507 | 536 | run-contexts |
508 | 537 | &aux |
509 | | - (all-tests (get-tests :tests tests |
510 | | - :tags tags |
511 | | - :package package |
512 | | - :reintern-package reintern-package)) |
| 538 | + (all-tests |
| 539 | + (get-tests :tests tests |
| 540 | + :tags tags |
| 541 | + :package package |
| 542 | + :reintern-package reintern-package |
| 543 | + :exclude-tests exclude-tests |
| 544 | + :exclude-tags exclude-tags)) |
513 | 545 | (results (make-instance 'test-results-db :tests all-tests :name name :args args)) |
514 | 546 | (*results* results)) |
515 | 547 | (%log #?"Running tests:${all-tests}" :level 0) |
|
0 commit comments