Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added regression test duplicating what we're seeing fail at work

  • Loading branch information...
commit b84e6b39cb76a8453bd6fface3bbc363945d09da 1 parent 06c0d12
Alex Baranosky authored
View
4 project.clj
@@ -2,7 +2,9 @@
:description "Rips your ns form apart and reconstructs it. We have the technology."
:plugins [[lein-swank "1.4.4"]]
:dependencies [[org.clojure/clojure "1.4.0"]]
- :dev-dependencies [[org.clojure/tools.trace "0.7.3"]]
+ :dev-dependencies [[org.clojure/tools.trace "0.7.3"]
+ [org.clojars.runa/clj-schema "0.7.0"]]
:test-selectors {:default (constantly true)
+ :integration :intgration
:unit :unit})
View
17 src/slam/hound/regrow.clj
@@ -25,10 +25,10 @@
(defn- failure-details [msg]
(when-let [sym (missing-sym-name msg)]
{:missing sym
- :types (cond (class-name? sym) [:import :use]
- (re-find #"Unable to resolve var: \w+/" msg) [:require :use]
- (re-find #"No such (var|namespace)" msg) [:require]
- :else [:use :import])}))
+ :possible-types (cond (class-name? sym) [:import :use]
+ (re-find #"Unable to resolve var: \w+/" msg) [:require :use]
+ (re-find #"No such (var|namespace)" msg) [:require]
+ :else [:use :import])}))
(defn- check-for-failure [ns-map body]
(let [sandbox-ns `slamhound.sandbox#
@@ -44,6 +44,7 @@
(remove-ns (.name *ns*)))))))
(defn candidates [type missing]
+ (println "ALL NS::" (all-ns))
(case type
:import (for [class-name search/available-classes
:when (= missing (last (.split class-name "\\.")))]
@@ -80,8 +81,7 @@
first))
(defn- grow-step [missing type ns-map]
- (if-let [addition (disambiguate (candidates type missing)
- missing ns-map type)]
+ (if-let [addition (disambiguate (candidates type missing) missing ns-map type)]
(update-in ns-map [type] conj addition)
ns-map))
@@ -98,11 +98,12 @@
(loop [ns-map ns-map
last-missing nil
type-to-try 0]
- (if-let [{:keys [missing types]} (check-for-failure ns-map body)]
+ (if-let [{:keys [missing possible-types]} (check-for-failure ns-map body)]
(let [type-idx (if (= last-missing missing)
(inc type-to-try)
0)]
- (if-let [type (get types type-idx)]
+ (println "ARGS::" [missing possible-types type-idx])
+ (if-let [type (get possible-types type-idx)]
(recur (grow-step missing type ns-map) missing type-idx)
(throw (Exception. (str "Couldn't resolve " missing
", got as far as " ns-map)))))
View
5 src/slam/hound/stitch.clj
@@ -1,5 +1,6 @@
(ns slam.hound.stitch
- (:use [slam.hound.prettify :only [prettify]]))
+ (:use [slam.hound.prettify :only [prettify]]
+ clojure.tools.trace))
(def ^:private ns-clauses [:use :require :import])
@@ -48,3 +49,5 @@
sort-subclauses
ns-from-map
prettify))
+
+;; (trace-ns 'slam.hound.stitch)
View
3  test/slam/hound/regrow_test.clj
@@ -42,4 +42,5 @@
(is (not (in-orig? 'java.sql.Date))))
(is (= '(java.io.File java.util.Date)
(:import (regrow [{:old {:import '((java.util Date))}}
- '(vector (Date.) (File. "/tmp"))])))))
+ '(vector (Date.) (File. "/tmp"))])))))
+
View
6 test/slam/hound/stitch_test.clj
@@ -54,9 +54,9 @@
(is (= {:use '[[clojure.test :only [deftest is]]
[slam.hound.stitch :only [ns-from-map]]]}
(collapse-clause {:use '[[clojure.test :only [deftest]]
- [slam.hound.stitch :only [ns-from-map]]
- [clojure.test :only [is]]]}
- :use))))
+ [slam.hound.stitch :only [ns-from-map]]
+ [clojure.test :only [is]]]}
+ :use))))
(deftest ^:unit test-stitch-up
(is (= "(ns slamhound.sample
Please sign in to comment.
Something went wrong with that request. Please try again.