From c658d8a759adc187da70efaacf800fdc0f852021 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Sat, 30 Jun 2018 20:33:55 +0200 Subject: [Fix #2357] Don't add nil keys to the test op requests They don't make sense and can mess up the request handling on the nREPl side. --- cider-test.el | 80 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 39 deletions(-) (limited to 'cider-test.el') diff --git a/cider-test.el b/cider-test.el index 076b97aa..d5765784 100644 --- a/cider-test.el +++ b/cider-test.el @@ -648,45 +648,47 @@ The include/exclude selectors will be used to filter the tests before ;; we generate a different message when running individual tests (cider-test-echo-running ns (car tests)) (cider-test-echo-running ns))) - (cider-nrepl-send-request - `("op" ,(cond ((stringp ns) "test") - ((eq :project ns) "test-all") - ((eq :loaded ns) "test-all") - ((eq :non-passing ns) "retest")) - "include" ,(when (listp include-selectors) include-selectors) - "exclude" ,(when (listp exclude-selectors) exclude-selectors) - "ns" ,(when (stringp ns) ns) - "tests" ,(when (stringp ns) tests) - "load?" ,(when (or (stringp ns) (eq :project ns)) "true")) - (lambda (response) - (nrepl-dbind-response response (summary results status out err) - (cond ((member "namespace-not-found" status) - (unless silent - (message "No test namespace: %s" (cider-propertize ns 'ns)))) - (out (cider-emit-interactive-eval-output out)) - (err (cider-emit-interactive-eval-err-output err)) - (results - (nrepl-dbind-response summary (error fail) - (setq cider-test-last-summary summary) - (setq cider-test-last-results results) - (cider-test-highlight-problems results) - (cider-test-echo-summary summary results) - (if (or (not (zerop (+ error fail))) - cider-test-show-report-on-success) - (cider-test-render-report - (cider-popup-buffer - cider-test-report-buffer - cider-auto-select-test-report-buffer) - summary - results) - (when (get-buffer cider-test-report-buffer) - (with-current-buffer cider-test-report-buffer - (let ((inhibit-read-only t)) - (erase-buffer))) - (cider-test-render-report - cider-test-report-buffer - summary results)))))))) - conn))))) + (let* ((request `("op" ,(cond ((stringp ns) "test") + ((eq :project ns) "test-all") + ((eq :loaded ns) "test-all") + ((eq :non-passing ns) "retest")))) + ;; we add optional parts of the request only when relevant + (request (when (and (listp include-selectors) include-selectors) (append request `("include" ,include-selectors)))) + (request (when (and (listp exclude-selectors) exclude-selectors) (append request `("exclude" ,exclude-selectors)))) + (request (when (stringp ns) (append request `("ns" ,ns)))) + (request (when (stringp ns) (append request `("tests" ,tests)))) + (request (when (or (stringp ns) (eq :project ns)) (append request `("load?" ,"true"))))) + (cider-nrepl-send-request + request + (lambda (response) + (nrepl-dbind-response response (summary results status out err) + (cond ((member "namespace-not-found" status) + (unless silent + (message "No test namespace: %s" (cider-propertize ns 'ns)))) + (out (cider-emit-interactive-eval-output out)) + (err (cider-emit-interactive-eval-err-output err)) + (results + (nrepl-dbind-response summary (error fail) + (setq cider-test-last-summary summary) + (setq cider-test-last-results results) + (cider-test-highlight-problems results) + (cider-test-echo-summary summary results) + (if (or (not (zerop (+ error fail))) + cider-test-show-report-on-success) + (cider-test-render-report + (cider-popup-buffer + cider-test-report-buffer + cider-auto-select-test-report-buffer) + summary + results) + (when (get-buffer cider-test-report-buffer) + (with-current-buffer cider-test-report-buffer + (let ((inhibit-read-only t)) + (erase-buffer))) + (cider-test-render-report + cider-test-report-buffer + summary results)))))))) + conn)))))) (defun cider-test-rerun-failed-tests () "Rerun failed and erring tests from the last test run." -- cgit v1.2.3