Unit testing 用于运行测试的Emacs matlab模式密钥绑定

Unit testing 用于运行测试的Emacs matlab模式密钥绑定,unit-testing,matlab,emacs,Unit Testing,Matlab,Emacs,我使用Emacs+作为我的Matlab开发环境。我还安装了Matlab来运行我的单元测试——我现在想做的是有一个键绑定,从MatlabShell中的当前文件运行测试,我一直在M-x MatlabShell中打开 到目前为止,我所拥有的是: ; Runs the unit tests available in the current buffer (defun run-matlab-test () (interactive) (matlab-shell-run-command (concat "r

我使用Emacs+作为我的Matlab开发环境。我还安装了Matlab来运行我的单元测试——我现在想做的是有一个键绑定,从MatlabShell中的当前文件运行测试,我一直在M-x MatlabShell中打开

到目前为止,我所拥有的是:

; Runs the unit tests available in the current buffer
(defun run-matlab-test ()
(interactive)
(matlab-shell-run-command (concat "runtests "
                (car (split-string (buffer-name) "\\.")))))

; Bind "C-c l" to running unit tests in matlab-mode
(defun map-run-matlab-test-keys ()
  (local-set-key (kbd "C-c l") 'run-matlab-test))

(add-hook 'matlab-mode-hook 'map-run-matlab-test-keys)
我需要做的是在runmatlabtest函数中使用buffername命令提供的参数调用runtests命令,所有这些都应该发生在我前面提到的matlabshell中。有什么提示吗


编辑:我通过调用MatlabShell运行命令使其工作。这里的警告是,它只在以下情况下起作用:打开unit test.m文件,从该文件运行m-x matlab shell,这样matlab从tests目录中的当前工作目录开始,然后您可以使用上面的绑定。

为了避免上面的警告,您可以在调用runtest之前向matlab发出cd,通过执行以下未经测试的操作:

(defun run-matlab-test ()
  (interactive)
  (matlab-shell-run-command (concat "cd " (file-name-directory (buffer-file-name))))
  (matlab-shell-run-command (concat "runtests "
                            (car (split-string (buffer-name) "\\.")))))

为了避免上面的警告,您可以在调用runtest之前,通过执行以下未经测试的操作,向matlab发出cd:

(defun run-matlab-test ()
  (interactive)
  (matlab-shell-run-command (concat "cd " (file-name-directory (buffer-file-name))))
  (matlab-shell-run-command (concat "runtests "
                            (car (split-string (buffer-name) "\\.")))))