diff --git a/test-cockpit.el b/test-cockpit.el index 93f410b..9ee41e6 100644 --- a/test-cockpit.el +++ b/test-cockpit.el @@ -364,7 +364,8 @@ the user can repeat the last function test with different ARGS." The command run is then stored in as last command of the project and thus can be repeated using `test-cockpit-repeat-test'." (interactive) - (call-interactively #'compile) + (projectile-with-default-dir (projectile-project-root) + (call-interactively #'compile)) (oset (test-cockpit--retrieve-engine) last-command compile-command)) ;;;###autoload diff --git a/test/test-cockpit.el-test.el b/test/test-cockpit.el-test.el index f31bf2f..228ac7c 100644 --- a/test/test-cockpit.el-test.el +++ b/test/test-cockpit.el-test.el @@ -179,8 +179,17 @@ (tc--register-foo-project "foo") (mocker-let ((projectile-project-root (&optional dir) ((:input-matcher (lambda (_) t) :output "foo-project"))) (compile (command) ((:input '("test project") :output 'success)))) - (test-cockpit-test-project) - )) + (test-cockpit-test-project))) + + +(ert-deftest test-test-project-no-args-working-directory () + (tc--register-foo-project "foo") + (mocker-let ((projectile-project-root (&optional dir) ((:input-matcher (lambda (_) t) :output "foo-project")))) + (cl-letf (((symbol-function 'compile) + (lambda (_cmd) + (should (equal default-directory "foo-project"))))) + (test-cockpit-test-project)))) + (ert-deftest test-test-project-cached () (tc--register-foo-project "foo") @@ -518,6 +527,14 @@ (test-cockpit-custom-test-command) (test-cockpit-repeat-test)))) +(ert-deftest test-custom-test-command-default-directory () + (tc--register-foo-project "foo") + (mocker-let ((projectile-project-root (&optional _dir) ((:input-matcher (lambda (_) t) :output "foo-project")))) + (cl-letf (((symbol-function 'call-interactively) + (lambda (_cmd) + (should (equal default-directory "foo-project"))))) + (test-cockpit-custom-test-command)))) + (ert-deftest test-set-infix () (tc--register-foo-project "foo") (mocker-let ((projectile-project-type () ((:output 'foo-project-type))))