~csharp/get-unit-test-in-project to use omnisharp

Now uses omnisharp-unit-test-at-point to test the unit test. Instead
goes to the file in tag and runs test at that point. Allows you to
traverse test as well!
This commit is contained in:
oreodave
2019-08-27 17:26:14 +01:00
parent fc86026dcd
commit f0c6ede141

View File

@@ -224,27 +224,32 @@ My docsets are stored in .docsets for ease of use
'font-lock-face '(:foreground "green" :weight bold))) 'font-lock-face '(:foreground "green" :weight bold)))
) )
nil) nil)
(interactive)
(omnisharp--cs-inspect-buffer
(lambda (elements)
(let* ((test-methods (omnisharp--cs-filter-resursively
'omnisharp--cs-unit-test-method-p
elements))) ;; Get set of elements through omnisharp
(ivy-read "Choose test: " ;; Start ivy to get nice menu (defun oreodave/csharp/get-unit-test-in-project ()
(mapcar (lambda (els) (cdr (nth 1 els))) test-methods) ;; Get names of any unit test methods (interactive)
:require-match t (let* ((tags-file (counsel-etags-locate-tags-file))
:keymap counsel-describe-map (cands (counsel-etags-collect-cands "void.*Test" t buffer-file-name)))
:sort t (ivy-read "Choose test: "
:unwind (lambda () cands
(counsel-delete-process) :action
(swiper--cleanup)) (lambda (item)
:action (lambda (x) ;; From the counsel-etags file-open-api function
(set-process-sentinel (when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" item)
(start-process-shell-command "csharp-unit-testing" "*csharp-test-output*" (format "dotnet test --logger \"console;verbosity=detailed\" --filter FullyQualifiedName~%S" x)) (let* ((file (match-string-no-properties 1 item))
(lambda (process _event) (linenum (match-string-no-properties 2 item))
(when (memq (process-status process) '(exit stop)) ;; always calculate path relative to TAGS
(message "Unit test finished :\)")))))))))) (default-directory (counsel-etags-tags-file-directory)))
(when counsel-etags-debug
(message "counsel-etags-open-file-api called => dir=%s, linenum=%s, file=%s" dir linenum file))
(counsel-etags-push-marker-stack (point-marker))
(find-file file)
(counsel-etags-forward-line linenum)
(omnisharp-unit-test-at-point)
)))
:caller 'oreodave/csharp/get-unit-tests-in-project)))
(setq omnisharp-server-executable-path "~/bin/omnisharp/run") (setq omnisharp-server-executable-path "~/bin/omnisharp/run")
(add-hook 'csharp-mode-hook '(lambda() (setq c-basic-offset 4))) ; Hook for csharp setting variables (add-hook 'csharp-mode-hook '(lambda() (setq c-basic-offset 4))) ; Hook for csharp setting variables