From f0c6ede1418dd0c55b816eab8c4352b761b90fb8 Mon Sep 17 00:00:00 2001 From: oreodave Date: Tue, 27 Aug 2019 17:26:14 +0100 Subject: ~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! --- doom.d/config.org | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/doom.d/config.org b/doom.d/config.org index b9fe3ca..8fd49a8 100644 --- a/doom.d/config.org +++ b/doom.d/config.org @@ -224,27 +224,32 @@ My docsets are stored in .docsets for ease of use 'font-lock-face '(:foreground "green" :weight bold))) ) nil) + + (defun oreodave/csharp/get-unit-test-in-project () (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 + (let* ((tags-file (counsel-etags-locate-tags-file)) + (cands (counsel-etags-collect-cands "void.*Test" t buffer-file-name))) + (ivy-read "Choose test: " + cands + :action + (lambda (item) + ;; From the counsel-etags file-open-api function + (when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" item) + (let* ((file (match-string-no-properties 1 item)) + (linenum (match-string-no-properties 2 item)) + ;; always calculate path relative to TAGS + (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))) - (ivy-read "Choose test: " ;; Start ivy to get nice menu - (mapcar (lambda (els) (cdr (nth 1 els))) test-methods) ;; Get names of any unit test methods - :require-match t - :keymap counsel-describe-map - :sort t - :unwind (lambda () - (counsel-delete-process) - (swiper--cleanup)) - :action (lambda (x) - (set-process-sentinel - (start-process-shell-command "csharp-unit-testing" "*csharp-test-output*" (format "dotnet test --logger \"console;verbosity=detailed\" --filter FullyQualifiedName~%S" x)) - (lambda (process _event) - (when (memq (process-status process) '(exit stop)) - (message "Unit test finished :\)")))))))))) (setq omnisharp-server-executable-path "~/bin/omnisharp/run") (add-hook 'csharp-mode-hook '(lambda() (setq c-basic-offset 4))) ; Hook for csharp setting variables -- cgit v1.2.3-13-gbd6f