|
42 | 42 | (should (eq (alist-get 'foo-project-type test-cockpit--project-types)
|
43 | 43 | (alist-get 'foo-project-type-alias test-cockpit--project-types))))
|
44 | 44 |
|
| 45 | + |
| 46 | +(defclass test-cockpit--dape-engine (test-cockpit--engine) |
| 47 | + ((current-module-string :initarg :current-module-string |
| 48 | + :initform nil) |
| 49 | + (current-function-string :initarg :current-function-string |
| 50 | + :initform nil))) |
| 51 | + |
| 52 | +(cl-defmethod test-cockpit--test-project-command ((obj test-cockpit--dape-engine)) |
| 53 | + (lambda (_ args) (concat "test project" " " (string-join args " ")))) |
| 54 | +(cl-defmethod test-cockpit--test-module-command ((obj test-cockpit--dape-engine)) |
| 55 | + (lambda (module args) (concat "test module" " " module " " (string-join args " ")))) |
| 56 | +(cl-defmethod test-cockpit--test-function-command ((obj test-cockpit--dape-engine)) |
| 57 | + (lambda (func args) (concat "test function" " " func " " (string-join args " ")))) |
| 58 | +(cl-defmethod test-cockpit--transient-infix ((obj test-cockpit--dape-engine)) |
| 59 | + ["Dape" ("-f" "dape" "--dape")]) |
| 60 | +(cl-defmethod test-cockpit--engine-current-module-string ((obj test-cockpit--dape-engine)) |
| 61 | + (oref obj current-module-string)) |
| 62 | +(cl-defmethod test-cockpit--engine-current-function-string ((obj test-cockpit--dape-engine)) |
| 63 | + (oref obj current-function-string)) |
| 64 | +(cl-defmethod test-cockpit--engine-dape-last-test-config ((obj test-cockpit--dape-engine)) |
| 65 | + 'dape-foo-config) |
| 66 | + |
| 67 | +(defun tc--register-dape-project (test-string) |
| 68 | + (setq test-cockpit--project-engines nil) |
| 69 | + (test-cockpit-register-project-type 'dape-project-type 'test-cockpit--dape-engine) |
| 70 | + (mocker-let ((projectile-project-type () ((:output 'dape-project-type :min-occur 0))) |
| 71 | + (projectile-project-root (&optional _dir) ((:input-matcher (lambda (_) t) :output "dape-project" :min-occur 0)))) |
| 72 | + (oset (test-cockpit--retrieve-engine) current-module-string |
| 73 | + (when test-string (concat test-string "-module-string"))) |
| 74 | + (oset (test-cockpit--retrieve-engine) current-function-string |
| 75 | + (when test-string (concat test-string "-function-string"))))) |
| 76 | + |
| 77 | + |
45 | 78 | (ert-deftest test-current-module-string-dummy ()
|
46 | 79 | (setq test-cockpit--project-engines nil)
|
47 | 80 | (mocker-let ((projectile-project-type () ((:output 'bar-project-type)))
|
|
361 | 394 | (test-cockpit-test-module '("bar" "foo"))
|
362 | 395 | (test-cockpit--do-repeat-function nil)))
|
363 | 396 |
|
| 397 | +(ert-deftest test-dape-debug-repeat-test--not-available () |
| 398 | + (tc--register-foo-project "foo") |
| 399 | + (should-error (test-cockpit-dape-debug-repeat-test))) |
| 400 | + |
| 401 | +(ert-deftest test-dape-debug-repeat-test--available () |
| 402 | + (tc--register-dape-project "dape") |
| 403 | + (mocker-let ((projectile-project-type () ((:output 'dape-project-type))) |
| 404 | + (dape (config) ((:input '(dape-foo-config) :output 'success)))) |
| 405 | + (test-cockpit-dape-debug-repeat-test))) |
| 406 | + |
| 407 | + |
| 408 | +(ert-deftest test-dape-debug-repeat-test--repeat () |
| 409 | + (tc--register-dape-project "dape") |
| 410 | + (mocker-let ((projectile-project-type () ((:output 'dape-project-type))) |
| 411 | + (dape (config) ((:input '(dape-foo-config) :output 'success :occur 2)))) |
| 412 | + (test-cockpit-dape-debug-repeat-test) |
| 413 | + (test-cockpit-repeat-test))) |
| 414 | + |
364 | 415 |
|
365 | 416 | (ert-deftest test-main-suffix--all-nil ()
|
366 | 417 | (tc--register-foo-project "foo")
|
|
426 | 477 | ("f" "function: some-last-function" test-cockpit-test-function)
|
427 | 478 | ("c" "custom" test-cockpit-custom-test-command)]))))
|
428 | 479 |
|
| 480 | +(ert-deftest test-main-suffix-dape-debug-no-last-test () |
| 481 | + (tc--register-dape-project "dape") |
| 482 | + (mocker-let ((projectile-project-root (&optional _dir) ((:input-matcher (lambda (_) t) :output "dape-project"))) |
| 483 | + (test-cockpit--current-module-string () ((:output nil))) |
| 484 | + (test-cockpit--current-function-string () ((:output nil))) |
| 485 | + (test-cockpit--last-module-string () ((:output nil))) |
| 486 | + (test-cockpit--last-function-string () ((:output "dape-project/some-last-function"))) |
| 487 | + (test-cockpit--last-interactive-test-command () ((:output nil)))) |
| 488 | + (should (equal (test-cockpit--main-suffix) |
| 489 | + ["Run tests" |
| 490 | + ("p" "project" test-cockpit-test-project) |
| 491 | + ("f" "function: some-last-function" test-cockpit-test-function) |
| 492 | + ("c" "custom" test-cockpit-custom-test-command)])))) |
| 493 | + |
| 494 | +(ert-deftest test-main-suffix-dape-debug-with-last-test () |
| 495 | + (tc--register-dape-project "dape") |
| 496 | + (mocker-let ((projectile-project-root (&optional _dir) ((:input-matcher (lambda (_) t) :output "dape-project"))) |
| 497 | + (test-cockpit--current-module-string () ((:output nil))) |
| 498 | + (test-cockpit--current-function-string () ((:output nil))) |
| 499 | + (test-cockpit--last-module-string () ((:output nil))) |
| 500 | + (test-cockpit--last-function-string () ((:output "dape-project/some-last-function"))) |
| 501 | + (test-cockpit--last-interactive-test-command () ((:output 'some-cmd)))) |
| 502 | + (should (equal (test-cockpit--main-suffix) |
| 503 | + ["Run tests" |
| 504 | + ("p" "project" test-cockpit-test-project) |
| 505 | + ("f" "function: some-last-function" test-cockpit-test-function) |
| 506 | + ("d" "dape debug repeat" test-cockpit-dape-debug-repeat-test) |
| 507 | + ("c" "custom" test-cockpit-custom-test-command) |
| 508 | + ("r" "repeat" test-cockpit--repeat-interactive-test)])))) |
| 509 | + |
429 | 510 |
|
430 | 511 | (ert-deftest test-repeat-transient-suffix-nil ()
|
431 | 512 | (tc--register-foo-project "foo")
|
|
0 commit comments