-
-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
24 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,5 @@ web/*.js | |
web/out | ||
web/target-cljs | ||
.rebl | ||
.shadow-cljs | ||
.shadow-cljs | ||
.clj-kondo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,31 @@ | ||
(ns user | ||
(:require | ||
[clojure.core.server :as server] | ||
[clojure.java.io :as io] | ||
[clojure.test :as t] | ||
[clojure.tools.namespace.repl :as ns])) | ||
[clj-reload.core :as reload] | ||
[duti.core :as duti])) | ||
|
||
(ns/set-refresh-dirs "src" "bench" "test" #_"bench_datomic" #_"test_datomic") | ||
(reload/init | ||
{:dirs ["src" "bench" "test" #_"bench_datomic" #_"test_datomic"] | ||
:no-reload '#{user}}) | ||
|
||
(defn reload [] | ||
(defn reload [& [opts]] | ||
(set! *warn-on-reflection* true) | ||
(let [res (ns/refresh)] | ||
(if (instance? Throwable res) | ||
(do | ||
(.printStackTrace ^Throwable res) | ||
(throw res)) | ||
res))) | ||
|
||
(def lock | ||
(Object.)) | ||
|
||
(defn position [] | ||
(let [trace (->> (Thread/currentThread) | ||
(.getStackTrace) | ||
(seq)) | ||
el ^StackTraceElement (nth trace 4)] | ||
(str "[" (clojure.lang.Compiler/demunge (.getClassName el)) " " (.getFileName el) ":" (.getLineNumber el) "]"))) | ||
|
||
(defn p [form] | ||
`(let [t# (System/currentTimeMillis) | ||
res# ~form] | ||
(locking lock | ||
(println (str "#p" (position) " " '~form " => (" (- (System/currentTimeMillis) t#) " ms) " res#))) | ||
res#)) | ||
(let [res (reload/reload opts) | ||
cnt (count (:loaded res))] | ||
(str "Reloaded " cnt " namespace" (when (not= 1 cnt) "s")))) | ||
|
||
(defn -main [& args] | ||
;; setup repl | ||
(let [args (apply array-map args) | ||
port (or | ||
(some-> (get args "--port") parse-long) | ||
(+ 1024 (rand-int 64512))) | ||
file (io/file ".repl-port")] | ||
(println "Started Server Socket REPL on port" port) | ||
(spit file port) | ||
(.deleteOnExit file) | ||
(server/start-server | ||
{:name "repl" | ||
:port port | ||
:accept 'clojure.core.server/repl | ||
:server-daemon false}))) | ||
;; starting app | ||
_ (set! *warn-on-reflection* true) | ||
_ (require 'datascript.test) | ||
;; starting socket repl | ||
port (some-> (get args "--port") parse-long) | ||
_ (duti/start-socket-repl {:port port})])) | ||
|
||
(defn test-all [] | ||
(reload) | ||
(t/run-all-tests #"datascript\..*")) | ||
(duti/test #"datascript\.test\..*")) | ||
|
||
(defn -test-main [_] | ||
(reload {:only #"datascript\.test\..*"}) | ||
(duti/test-exit #"datascript\.test\..*")) |