From fc86026dcd00cf035bf5344f6175eb43917771cb Mon Sep 17 00:00:00 2001 From: oreodave Date: Tue, 27 Aug 2019 17:24:27 +0100 Subject: -csharp-unit-test function +reimpl of emit-results The reimplementation of omnisharp--unit-test-emit-results is so stdout is always printed regardless of errors. Makes it cleaner to use. --- doom.d/config.org | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/doom.d/config.org b/doom.d/config.org index f847370..b9fe3ca 100644 --- a/doom.d/config.org +++ b/doom.d/config.org @@ -169,12 +169,61 @@ My docsets are stored in .docsets for ease of use (load-file (concat doom-private-dir "config.el")) ) #+END_SRC - ** Languages *** C# #+BEGIN_SRC emacs-lisp (after! csharp-mode - (defun oreodave/csharp/unit-test () + (defun omnisharp--unit-test-emit-results (passed results) + ; Mostly a copy of the actual omnisharp--unit-test-emit-results function + ; Just allows stdout to come out regardless of whether test has passed or not + (omnisharp--unit-test-message "") + + (seq-doseq (result results) + (-let* (((&alist 'MethodName method-name + 'Outcome outcome + 'ErrorMessage error-message + 'ErrorStackTrace error-stack-trace + 'StandardOutput stdout + 'StanderError stderr) result) + (outcome-is-passed (string-equal "passed" outcome))) + + (omnisharp--unit-test-message + (format "[%s] %s " + (propertize + (upcase outcome) + 'font-lock-face (if outcome-is-passed + '(:foreground "green" :weight bold) + '(:foreground "red" :weight bold))) + (omnisharp--truncate-symbol-name method-name 76))) + + (unless (= (seq-length stdout) 0) + (omnisharp--unit-test-message "Standard output:") + (seq-doseq (stdout-line stdout) + (omnisharp--unit-test-message stdout-line))) + + (unless outcome-is-passed + (omnisharp--unit-test-message error-message) + + (if error-stack-trace + (omnisharp--unit-test-message error-stack-trace)) + + (unless (= (seq-length stderr) 0) + (omnisharp--unit-test-message "Standard error:") + (seq-doseq (stderr-line stderr) + (omnisharp--unit-test-message stderr-line))) + ))) + + (omnisharp--unit-test-message "") + + (if (eq passed :json-false) + (omnisharp--unit-test-message + (propertize "*** UNIT TEST RUN HAS FAILED ***" + 'font-lock-face '(:foreground "red" :weight bold))) + (omnisharp--unit-test-message + (propertize "*** UNIT TEST RUN HAS SUCCEEDED ***" + 'font-lock-face '(:foreground "green" :weight bold))) + ) + nil) (interactive) (omnisharp--cs-inspect-buffer (lambda (elements) -- cgit v1.2.3-13-gbd6f