[#535] fix order in --uberscript (2)
This commit is contained in:
parent
0829ccbe2e
commit
02032625ee
6 changed files with 37 additions and 9 deletions
2
sci
2
sci
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0da67e32e2930aa0ea18c9350b8a40fc0b9cb502
|
Subproject commit a92fce09210f47a8243a30e6d4a0a6febca21c27
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[sci.addons :as addons]
|
[sci.addons :as addons]
|
||||||
[sci.core :as sci]
|
[sci.core :as sci]
|
||||||
|
[sci.impl.namespaces :as sci-namespaces]
|
||||||
[sci.impl.unrestrict :refer [*unrestricted*]]
|
[sci.impl.unrestrict :refer [*unrestricted*]]
|
||||||
[sci.impl.vars :as vars])
|
[sci.impl.vars :as vars])
|
||||||
(:gen-class))
|
(:gen-class))
|
||||||
|
|
@ -479,11 +480,18 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that
|
||||||
(System/getenv "BABASHKA_CLASSPATH"))
|
(System/getenv "BABASHKA_CLASSPATH"))
|
||||||
_ (when classpath
|
_ (when classpath
|
||||||
(add-classpath* classpath))
|
(add-classpath* classpath))
|
||||||
load-fn (fn [{:keys [:namespace]}]
|
load-fn (fn [{:keys [:namespace :reload]}]
|
||||||
(when-let [{:keys [:loader]} @cp-state]
|
(when-let [{:keys [:loader]}
|
||||||
(let [res (cp/source-for-namespace loader namespace nil)]
|
@cp-state]
|
||||||
(when uberscript (swap! uberscript-sources conj (:source res)))
|
(if ;; ignore built-in namespaces when uberscripting, unless with :reload
|
||||||
res)))
|
(and uberscript
|
||||||
|
(not reload)
|
||||||
|
(or (contains? namespaces namespace)
|
||||||
|
(contains? sci-namespaces/namespaces namespace)))
|
||||||
|
""
|
||||||
|
(let [res (cp/source-for-namespace loader namespace nil)]
|
||||||
|
(when uberscript (swap! uberscript-sources conj (:source res)))
|
||||||
|
res))))
|
||||||
_ (when file
|
_ (when file
|
||||||
(let [abs-path (.getAbsolutePath (io/file file))]
|
(let [abs-path (.getAbsolutePath (io/file file))]
|
||||||
(vars/bindRoot sci/file abs-path)
|
(vars/bindRoot sci/file abs-path)
|
||||||
|
|
@ -516,8 +524,7 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that
|
||||||
:classes classes/class-map
|
:classes classes/class-map
|
||||||
:imports imports
|
:imports imports
|
||||||
:load-fn load-fn
|
:load-fn load-fn
|
||||||
:dry-run uberscript
|
:uberscript uberscript
|
||||||
:reload true
|
|
||||||
:readers core/data-readers}
|
:readers core/data-readers}
|
||||||
opts (addons/future opts)
|
opts (addons/future opts)
|
||||||
sci-ctx (sci/init opts)
|
sci-ctx (sci/init opts)
|
||||||
|
|
|
||||||
6
test-resources/babashka/uberscript/src/my/impl.clj
Normal file
6
test-resources/babashka/uberscript/src/my/impl.clj
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
(ns my.impl
|
||||||
|
(:require [clojure.string]))
|
||||||
|
|
||||||
|
(defn impl-fn
|
||||||
|
"identity"
|
||||||
|
[x] x)
|
||||||
4
test-resources/babashka/uberscript/src/my/impl2.clj
Normal file
4
test-resources/babashka/uberscript/src/my/impl2.clj
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
(ns my.impl2
|
||||||
|
(:require [my.impl :as impl]))
|
||||||
|
|
||||||
|
(def impl-fn impl/impl-fn)
|
||||||
6
test-resources/babashka/uberscript/src/my/main.clj
Normal file
6
test-resources/babashka/uberscript/src/my/main.clj
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
(ns my.main
|
||||||
|
(:require [my.impl :as impl])
|
||||||
|
(:require [my.impl2 :as impl2]))
|
||||||
|
|
||||||
|
(defn -main [& args]
|
||||||
|
(impl/impl-fn args))
|
||||||
|
|
@ -39,7 +39,12 @@
|
||||||
(.deleteOnExit tmp-file)
|
(.deleteOnExit tmp-file)
|
||||||
(is (empty? (tu/bb nil "--classpath" "test-resources/babashka/src_for_classpath_test" "-m" "my.main" "--uberscript" (.getPath tmp-file))))
|
(is (empty? (tu/bb nil "--classpath" "test-resources/babashka/src_for_classpath_test" "-m" "my.main" "--uberscript" (.getPath tmp-file))))
|
||||||
(is (= "(\"1\" \"2\" \"3\" \"4\")\n"
|
(is (= "(\"1\" \"2\" \"3\" \"4\")\n"
|
||||||
(tu/bb nil "--file" (.getPath tmp-file) "1" "2" "3" "4")))))
|
(tu/bb nil "--file" (.getPath tmp-file) "1" "2" "3" "4")))
|
||||||
|
(testing "order of namespaces is correct"
|
||||||
|
(tu/bb nil "--classpath" "test-resources/babashka/uberscript/src" "-m" "my.main" "--uberscript" (.getPath tmp-file))
|
||||||
|
(prn (slurp (.getPath tmp-file)))
|
||||||
|
(is (= "(\"1\" \"2\" \"3\" \"4\")\n"
|
||||||
|
(tu/bb nil "--file" (.getPath tmp-file) "1" "2" "3" "4"))))))
|
||||||
|
|
||||||
(deftest error-while-loading-test
|
(deftest error-while-loading-test
|
||||||
(is (true?
|
(is (true?
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue