[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/cider 9fb72b30ab 1/3: Introduce `cider-clojure-runtime-err
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/cider 9fb72b30ab 1/3: Introduce `cider-clojure-runtime-error-regexp` |
Date: |
Thu, 1 Feb 2024 13:00:03 -0500 (EST) |
branch: elpa/cider
commit 9fb72b30abe1bed6451f25f238002ce5a44f804c
Author: vemv <vemv@users.noreply.github.com>
Commit: vemv <vemv@users.noreply.github.com>
Introduce `cider-clojure-runtime-error-regexp`
---
cider-eval.el | 33 +++++++++++++++++++++++++++++-
test/cider-error-parsing-tests.el | 42 +++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 1 deletion(-)
diff --git a/cider-eval.el b/cider-eval.el
index 723c9dcd16..391f778b9e 100644
--- a/cider-eval.el
+++ b/cider-eval.el
@@ -567,7 +567,10 @@ It delegates the actual error content to the eval or op
handler."
;; old and the new format, by utilizing a combination of two different regular
;; expressions.
-(defconst cider-clojure-1.10--location `("at ("
+(defconst cider-clojure-1.10--location `((or "at ("
+ (sequence "at "
+ (minimal-match
(one-or-more anything)) ;; the fully-qualified name of the function that
triggered the error
+ " ("))
(group-n 2 (minimal-match
(zero-or-more anything)))
":"
(group-n 3 (one-or-more digit))
@@ -626,6 +629,34 @@ lol in this context, compiling:(/foo/core.clj:10:1)\"
\"Syntax error compiling at (src/workspace_service.clj:227:3).\"
\"Unexpected error (ClassCastException) macroexpanding defmulti at
(src/haystack/parser.cljc:21:1).\"")
+(defconst cider--clojure-execution-error-regexp
+ (append `(sequence
+ "Execution error "
+ (or (sequence "("
+ (minimal-match (one-or-more anything))
+ ")")
+ (minimal-match (zero-or-more anything))))
+ cider-clojure-1.10--location))
+
+(defconst cider--clojure-spec-execution-error-regexp
+ (append `(sequence
+ "Execution error - invalid arguments to "
+ (minimal-match (one-or-more anything))
+ " ")
+ cider-clojure-1.10--location))
+
+(defconst cider-clojure-runtime-error-regexp
+ (eval
+ `(rx bol (or ,cider--clojure-execution-error-regexp
+ ,cider--clojure-spec-execution-error-regexp))
+ t)
+ "Matches runtime errors, as oppsed to compile-time/macroexpansion-time
errors.
+
+A few example values that will match:
+
+\"Execution error (ArithmeticException) at foo/foo
(src/haystack/parser.cljc:4).\"
+\"Execution error - invalid arguments to foo/bar at
(src/haystack/parser.cljc:4).\"")
+
(defconst cider-module-info-regexp
(rx " ("
(minimal-match (one-or-more anything))
diff --git a/test/cider-error-parsing-tests.el
b/test/cider-error-parsing-tests.el
index 583e92b92a..00ab7264dd 100644
--- a/test/cider-error-parsing-tests.el
+++ b/test/cider-error-parsing-tests.el
@@ -143,6 +143,48 @@
(match-string 2 clojure-1.10-compiler-error))
:to-equal "src/haystack/parser.cljc"))))
+(describe "cider-clojure-runtime-error-regexp"
+ (it "Recognizes a clojure-1.10 runtime error message"
+
+ ;; Something like "(ArithmeticException)" will be absent for Exception and
RuntimeException in particular
+ (let ((specimen "Execution error at foo/foo
(src/haystack/parser.cljc:4)."))
+ (expect specimen :to-match cider-clojure-runtime-error-regexp)
+ (expect (progn
+ (string-match cider-clojure-runtime-error-regexp specimen)
+ (match-string 2 specimen))
+ :to-equal "src/haystack/parser.cljc"))
+
+ (let ((specimen "Execution error (ArithmeticException) at foo/foo
(src/haystack/parser.cljc:4)."))
+ (expect specimen :to-match cider-clojure-runtime-error-regexp)
+ (expect (progn
+ (string-match cider-clojure-runtime-error-regexp specimen)
+ (match-string 2 specimen))
+ :to-equal "src/haystack/parser.cljc"))
+
+ ;; without foo/foo symbol
+ (let ((specimen "Execution error at (src/haystack/parser.cljc:4)."))
+ (expect specimen :to-match cider-clojure-runtime-error-regexp)
+ (expect (progn
+ (string-match cider-clojure-runtime-error-regexp specimen)
+ (match-string 2 specimen))
+ :to-equal "src/haystack/parser.cljc"))
+
+ ;; without foo/foo symbol
+ (let ((specimen "Execution error (ArithmeticException) at
(src/haystack/parser.cljc:4)."))
+ (expect specimen :to-match cider-clojure-runtime-error-regexp)
+ (expect (progn
+ (string-match cider-clojure-runtime-error-regexp specimen)
+ (match-string 2 specimen))
+ :to-equal "src/haystack/parser.cljc")))
+
+ (it "Recognizes a clojure-1.10 runtime spec validation error message"
+ (let ((specimen "Execution error - invalid arguments to foo/bar at
(src/haystack/parser.cljc:4)."))
+ (expect specimen :to-match cider-clojure-runtime-error-regexp)
+ (expect (progn
+ (string-match cider-clojure-runtime-error-regexp specimen)
+ (match-string 2 specimen))
+ :to-equal "src/haystack/parser.cljc"))))
+
(describe "cider-module-info-regexp"
(it "Matches module info provided by Java"
(expect " (java.lang.Long is in module java.base of loader 'bootstrap';
clojure.lang.IObj is in unnamed module of loader 'app')"