|
24 | 24 |
|
25 | 25 | (defun tc--register-foo-project (test-string)
|
26 | 26 | (setq test-cockpit--project-engines nil)
|
| 27 | + (setq test-cockpit--project-type-custom-actions |
| 28 | + (assoc-delete-all 'foo-project-type test-cockpit--project-type-custom-actions)) |
27 | 29 | (test-cockpit-register-project-type 'foo-project-type 'test-cockpit--foo-engine)
|
28 | 30 | (mocker-let ((projectile-project-type () ((:output 'foo-project-type :min-occur 0)))
|
29 | 31 | (projectile-project-root (&optional _dir) ((:input-matcher (lambda (_) t) :output "foo-project" :min-occur 0))))
|
|
413 | 415 | (test-cockpit-repeat-test)))
|
414 | 416 |
|
415 | 417 |
|
| 418 | +(ert-deftest test-custom-action-simple () |
| 419 | + (mocker-let ((projectile-project-root (&optional _dir) ((:input-matcher (lambda (_) t) :output "/path/to/project"))) |
| 420 | + (buffer-file-name () ((:output "/path/to/project/some/file.el"))) |
| 421 | + (compile (command) ((:input '("custom test command") :output 'success)))) |
| 422 | + (test-cockpit-dynamic-custom-test-command "custom test command"))) |
| 423 | + |
| 424 | + |
| 425 | +(ert-deftest test-custom-action-repeat () |
| 426 | + (tc--register-foo-project "foo") |
| 427 | + (mocker-let (;(projectile-project-type () ((:output 'foo-project-type))) |
| 428 | + (projectile-project-root (&optional _dir) ((:input-matcher (lambda (_) t) :output "foo-project"))) |
| 429 | + (buffer-file-name () ((:output "/path/to/project/some/file.el"))) |
| 430 | + (compile (command) ((:input '("other custom test action") :output 'success :occur 2)))) |
| 431 | + (test-cockpit-dynamic-custom-test-command "other custom test action") |
| 432 | + (test-cockpit-repeat-test))) |
| 433 | + |
| 434 | + |
| 435 | +(ert-deftest test-custom-action-replace-project-root () |
| 436 | + (tc--register-foo-project "foo") |
| 437 | + (mocker-let ((projectile-project-type () ((:output 'foo-project-type))) |
| 438 | + (projectile-project-root (&optional _dir) ((:input-matcher (lambda (_) t) :output "/path/to/project"))) |
| 439 | + (buffer-file-name () ((:output "/path/to/project/some/file.el"))) |
| 440 | + (compile (command) ((:input '("command /path/to/project") :output 'success :occur 2)))) |
| 441 | + (test-cockpit-dynamic-custom-test-command "command %P") |
| 442 | + (test-cockpit-repeat-test))) |
| 443 | + |
| 444 | +(ert-deftest test-custom-action-no-replace-project-root () |
| 445 | + (tc--register-foo-project "foo") |
| 446 | + (mocker-let ((projectile-project-type () ((:output 'foo-project-type))) |
| 447 | + (projectile-project-root (&optional _dir) ((:input-matcher (lambda (_) t) :output "/path/to/project"))) |
| 448 | + (buffer-file-name () ((:output "/path/to/project/some/file.el"))) |
| 449 | + (compile (command) ((:input '("command %Project") :output 'success :occur 2)))) |
| 450 | + (test-cockpit-dynamic-custom-test-command "command %%Project") |
| 451 | + (test-cockpit-repeat-test))) |
| 452 | + |
| 453 | + |
| 454 | +(ert-deftest test-custom-action-replace-absolute-file () |
| 455 | + (tc--register-foo-project "foo") |
| 456 | + (mocker-let ((projectile-project-type () ((:output 'foo-project-type))) |
| 457 | + (projectile-project-root (&optional _dir) ((:input-matcher (lambda (_) t) :output "/path/to/project/"))) |
| 458 | + (buffer-file-name () ((:output "/path/to/project/some/file.el"))) |
| 459 | + (compile (command) ((:input '("command /path/to/project/some/file.el") :output 'success :occur 2)))) |
| 460 | + (test-cockpit-dynamic-custom-test-command "command %F") |
| 461 | + (test-cockpit-repeat-test))) |
| 462 | + |
| 463 | + |
| 464 | +(ert-deftest test-custom-action-no-replace-absolute-file () |
| 465 | + (tc--register-foo-project "foo") |
| 466 | + (mocker-let ((projectile-project-type () ((:output 'foo-project-type))) |
| 467 | + (projectile-project-root (&optional _dir) ((:input-matcher (lambda (_) t) :output "/path/to/project/"))) |
| 468 | + (buffer-file-name () ((:output "/path/to/project/some/file.el"))) |
| 469 | + (compile (command) ((:input '("command %Foo") :output 'success :occur 2)))) |
| 470 | + (test-cockpit-dynamic-custom-test-command "command %%Foo") |
| 471 | + (test-cockpit-repeat-test))) |
| 472 | + |
| 473 | + |
| 474 | +(ert-deftest test-custom-action-replace-relative-file () |
| 475 | + (tc--register-foo-project "foo") |
| 476 | + (mocker-let ((projectile-project-type () ((:output 'foo-project-type))) |
| 477 | + (projectile-project-root (&optional _dir) ((:input-matcher (lambda (_) t) :output "/path/to/project/"))) |
| 478 | + (buffer-file-name () ((:output "/path/to/project/some/file.el"))) |
| 479 | + (compile (command) ((:input '("command some/file.el") :output 'success :occur 2)))) |
| 480 | + (test-cockpit-dynamic-custom-test-command "command %f") |
| 481 | + (test-cockpit-repeat-test))) |
| 482 | + |
| 483 | + |
416 | 484 | (ert-deftest test-main-suffix--all-nil ()
|
417 | 485 | (tc--register-foo-project "foo")
|
418 | 486 | (mocker-let ((projectile-project-type () ((:output 'foo-project-type)))
|
|
426 | 494 | ("c" "custom" test-cockpit-custom-test-command)]))))
|
427 | 495 |
|
428 | 496 |
|
| 497 | +(ert-deftest test-main-suffix--one-custom-actions-added () |
| 498 | + (tc--register-foo-project "foo") |
| 499 | + (test-cockpit-add-custom-action |
| 500 | + 'foo-project-type "C" "some custom action" "some_custom_action --foo") |
| 501 | + (mocker-let ((projectile-project-type () ((:output 'foo-project-type))) |
| 502 | + (test-cockpit--current-module-string () ((:output nil))) |
| 503 | + (test-cockpit--current-function-string () ((:output nil))) |
| 504 | + (test-cockpit--last-module-string () ((:output nil))) |
| 505 | + (test-cockpit--last-function-string () ((:output nil)))) |
| 506 | + (should (equal (test-cockpit--main-suffix) |
| 507 | + [["Run tests" |
| 508 | + ("p" "project" test-cockpit-test-project) |
| 509 | + ("c" "custom" test-cockpit-custom-test-command)] |
| 510 | + ["Custom actions" |
| 511 | + ("C" "some custom action" (lambda () (interactive) (test-cockpit--run-test "some_custom_action --foo")))]])))) |
| 512 | + |
| 513 | + |
| 514 | +(ert-deftest test-main-suffix--two-custom-actions-added () |
| 515 | + (tc--register-foo-project "foo") |
| 516 | + (test-cockpit-add-custom-action |
| 517 | + 'foo-project-type "C" "some strange action" "some_strange_action --foo") |
| 518 | + (test-cockpit-add-custom-action |
| 519 | + 'foo-project-type "O" "another custom action" #'some-action-function) |
| 520 | + (mocker-let ((projectile-project-type () ((:output 'foo-project-type))) |
| 521 | + (test-cockpit--current-module-string () ((:output nil))) |
| 522 | + (test-cockpit--current-function-string () ((:output nil))) |
| 523 | + (test-cockpit--last-module-string () ((:output nil))) |
| 524 | + (test-cockpit--last-function-string () ((:output nil)))) |
| 525 | + (should (equal (test-cockpit--main-suffix) |
| 526 | + [["Run tests" |
| 527 | + ("p" "project" test-cockpit-test-project) |
| 528 | + ("c" "custom" test-cockpit-custom-test-command)] |
| 529 | + ["Custom actions" |
| 530 | + ("C" "some strange action" (lambda () (interactive) (test-cockpit--run-test "some_strange_action --foo"))) |
| 531 | + ("O" "another custom action" some-action-function)]])))) |
| 532 | + |
| 533 | + |
| 534 | +(ert-deftest test-main-suffix--dynamic-custom-actions-added () |
| 535 | + (tc--register-foo-project "foo") |
| 536 | + (test-cockpit-add-dynamic-custom-action |
| 537 | + 'foo-project-type "C" "some custom action" "some_custom_action %f --foo") |
| 538 | + (mocker-let ((projectile-project-type () ((:output 'foo-project-type))) |
| 539 | + (test-cockpit--current-module-string () ((:output nil))) |
| 540 | + (test-cockpit--current-function-string () ((:output nil))) |
| 541 | + (test-cockpit--last-module-string () ((:output nil))) |
| 542 | + (test-cockpit--last-function-string () ((:output nil)))) |
| 543 | + (should (equal (test-cockpit--main-suffix) |
| 544 | + [["Run tests" |
| 545 | + ("p" "project" test-cockpit-test-project) |
| 546 | + ("c" "custom" test-cockpit-custom-test-command)] |
| 547 | + ["Custom actions" |
| 548 | + ("C" "some custom action" (lambda () (interactive) (test-cockpit-dynamic-custom-test-command "some_custom_action %f --foo")))]])))) |
| 549 | + |
| 550 | + |
429 | 551 | (ert-deftest test-main-suffix--current-module ()
|
430 | 552 | (tc--register-foo-project "foo")
|
431 | 553 | (mocker-let ((projectile-project-root (&optional _dir) ((:input-matcher (lambda (_) t) :output "foo-project")))
|
|
739 | 861 | (should (equal default-directory "foo-project")))))
|
740 | 862 | (test-cockpit-custom-test-command))))
|
741 | 863 |
|
| 864 | + |
742 | 865 | (ert-deftest test-set-infix ()
|
743 | 866 | (tc--register-foo-project "foo")
|
744 | 867 | (mocker-let ((projectile-project-type () ((:output 'foo-project-type))))
|
|
0 commit comments