This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

broadened the exception matching regexp to pick up more exception loc…

…ations
  • Loading branch information...
hugoduncan committed Mar 13, 2010
1 parent 1ada3b2 commit 647fe5a26c7e32bb3828d265c0da08b87ab6e2ad
Showing with 31 additions and 1 deletion.
  1. +1 −1 src/swank/commands/basic.clj
  2. +30 −0 test/swank/test_swank/commands/basic.clj
@@ -86,7 +86,7 @@
;;;; Compiler / Execution
-(def *compiler-exception-location-re* #"^clojure\\.lang\\.Compiler\\$CompilerException: ([^:]+):([^:]+):")
+(def *compiler-exception-location-re* #"Exception:.*\(([^:]+):([0-9]+)\)")
(defn- guess-compiler-exception-location [#^Throwable t]
(when (instance? clojure.lang.Compiler$CompilerException t)
(let [[match file line] (re-find *compiler-exception-location-re* (.toString t))]
@@ -0,0 +1,30 @@
+(ns swank.test-swank.commands.basic
+ (:refer-clojure :exclude [load-file])
+ (:use swank.commands.basic :reload-all)
+ (:use clojure.test))
+
+(defn emacs-package-fixture [f]
+ (binding [swank.core/*current-package* "user"]
+ (f)))
+
+(use-fixtures :each emacs-package-fixture)
+
+(defmacro with-private-vars [[ns fns] & tests]
+ "Refers private fns from ns and runs tests in context. From users mailing
+list, Alan Dipert and MeikelBrandmeyer."
+ `(let ~(reduce #(conj %1 %2 `@(ns-resolve '~ns '~%2)) [] fns)
+ ~@tests))
+
+(with-private-vars [swank.commands.basic
+ [guess-compiler-exception-location
+ exception-location]]
+
+ (deftest guess-compiler-exception-location-test
+ (is (= '(:location (:file "a.clj") (:line 1) nil)
+ (guess-compiler-exception-location
+ (clojure.lang.Compiler$CompilerException. "a.clj" 1 (Exception. "err"))))))
+
+ (deftest exception-location-test
+ (is (= '(:location (:file "a.clj") (:line 1) nil)
+ (exception-location
+ (clojure.lang.Compiler$CompilerException. "a.clj" 1 (Exception. "err")))))))

0 comments on commit 647fe5a

Please sign in to comment.