update some SciVar names (metadata-wise) to align with babashka name (#1236)
* update SciVar names to align with the symbols in the namespace maps * make test using a bb script more consistent with others * update changelog
This commit is contained in:
parent
60a3e86449
commit
3d0befb52b
9 changed files with 29 additions and 10 deletions
|
|
@ -10,6 +10,7 @@ A preview of the next release can be installed from
|
||||||
|
|
||||||
- Add `prepare` subcommand to download deps & pods and cache pod metadata
|
- Add `prepare` subcommand to download deps & pods and cache pod metadata
|
||||||
- [#1041](https://github.com/babashka/babashka/issues/1041): Improve error message when regex literal in EDN config
|
- [#1041](https://github.com/babashka/babashka/issues/1041): Improve error message when regex literal in EDN config
|
||||||
|
- [#1223](https://github.com/babashka/babashka/issues/1223): Ensure that var metadata (specifically `:name`) aligns with the var's symbol (which in turn ensures that `doc` will print the var's name)
|
||||||
|
|
||||||
## 0.8.0 (2022-04-04)
|
## 0.8.0 (2022-04-04)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,10 +52,10 @@
|
||||||
util/raw-string)
|
util/raw-string)
|
||||||
|
|
||||||
(def hiccup-namespace
|
(def hiccup-namespace
|
||||||
{'html (copy-var html-1 hns)})
|
{'html (copy-var html-1 hns {:name 'html})})
|
||||||
|
|
||||||
(def hiccup2-namespace
|
(def hiccup2-namespace
|
||||||
{'html (copy-var html-2 hns2)})
|
{'html (copy-var html-2 hns2 {:name 'html})})
|
||||||
|
|
||||||
(def html-mode (copy-var util/*html-mode* uns))
|
(def html-mode (copy-var util/*html-mode* uns))
|
||||||
(def escape-strings? (copy-var util/*escape-strings?* uns))
|
(def escape-strings? (copy-var util/*escape-strings?* uns))
|
||||||
|
|
|
||||||
|
|
@ -76,4 +76,4 @@
|
||||||
|
|
||||||
(def sni-client-namespace
|
(def sni-client-namespace
|
||||||
{'ssl-configurer (copy-var sni-client/ssl-configurer sns)
|
{'ssl-configurer (copy-var sni-client/ssl-configurer sns)
|
||||||
'default-client (sci/new-var 'sni-client sni-client {:ns sns})})
|
'default-client (sci/new-var 'default-client sni-client {:ns sns})})
|
||||||
|
|
|
||||||
|
|
@ -103,10 +103,10 @@
|
||||||
'untap-all (copy-var async/untap-all core-async-namespace)
|
'untap-all (copy-var async/untap-all core-async-namespace)
|
||||||
;; polyfill
|
;; polyfill
|
||||||
'go (macrofy 'go thread core-async-namespace)
|
'go (macrofy 'go thread core-async-namespace)
|
||||||
'<! (copy-var async/<!! core-async-namespace)
|
'<! (copy-var async/<!! core-async-namespace {:name '<!})
|
||||||
'>! (copy-var async/>!! core-async-namespace)
|
'>! (copy-var async/>!! core-async-namespace {:name '>!})
|
||||||
'alt! (macrofy 'alt! alt!! core-async-namespace)
|
'alt! (macrofy 'alt! alt!! core-async-namespace)
|
||||||
'alts! (copy-var async/alts!! core-async-namespace)
|
'alts! (copy-var async/alts!! core-async-namespace {:name 'alts!})
|
||||||
'go-loop (macrofy 'go-loop go-loop core-async-namespace)})
|
'go-loop (macrofy 'go-loop go-loop core-async-namespace)})
|
||||||
|
|
||||||
(def async-protocols-ns (vars/->SciNamespace 'clojure.core.async.impl.protocols nil))
|
(def async-protocols-ns (vars/->SciNamespace 'clojure.core.async.impl.protocols nil))
|
||||||
|
|
|
||||||
|
|
@ -332,7 +332,7 @@
|
||||||
:added "1.1"}
|
:added "1.1"}
|
||||||
report-impl :type)
|
report-impl :type)
|
||||||
|
|
||||||
(def report (sci/copy-var report-impl tns))
|
(def report (sci/copy-var report-impl tns {:name 'report}))
|
||||||
|
|
||||||
(defn do-report
|
(defn do-report
|
||||||
"Add file and line information to a test result and call report.
|
"Add file and line information to a test result and call report.
|
||||||
|
|
@ -722,7 +722,7 @@
|
||||||
:expected nil, :actual e})))
|
:expected nil, :actual e})))
|
||||||
(do-report {:type :end-test-var, :var v}))))
|
(do-report {:type :end-test-var, :var v}))))
|
||||||
|
|
||||||
(def test-var (sci/copy-var test-var-impl tns))
|
(def test-var (sci/copy-var test-var-impl tns {:name 'test-var}))
|
||||||
|
|
||||||
(defn test-vars
|
(defn test-vars
|
||||||
"Groups vars by their namespace and runs test-vars on them with
|
"Groups vars by their namespace and runs test-vars on them with
|
||||||
|
|
|
||||||
|
|
@ -101,4 +101,4 @@
|
||||||
'clojure (sci/copy-var bdeps/clojure dns)
|
'clojure (sci/copy-var bdeps/clojure dns)
|
||||||
'merge-deps (sci/copy-var merge-deps dns)
|
'merge-deps (sci/copy-var merge-deps dns)
|
||||||
;; undocumented
|
;; undocumented
|
||||||
'merge-defaults (sci/copy-var merge-default-deps dns)})
|
'merge-defaults (sci/copy-var merge-default-deps dns {:name 'merge-defaults})})
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
;; (def task-name (sci/new-dynamic-var '*-task-name* nil {:ns sci-ns}))
|
;; (def task-name (sci/new-dynamic-var '*-task-name* nil {:ns sci-ns}))
|
||||||
(def task (sci/new-dynamic-var '*task* nil {:ns sci-ns}))
|
(def task (sci/new-dynamic-var '*task* nil {:ns sci-ns}))
|
||||||
(def current-task (sci/new-var 'current-task (fn [] @task) {:ns sci-ns}))
|
(def current-task (sci/new-var 'current-task (fn [] @task) {:ns sci-ns}))
|
||||||
(def state (sci/new-var 'state (atom {}) {:ns sci-ns}))
|
(def state (sci/new-var 'current-state (atom {}) {:ns sci-ns}))
|
||||||
|
|
||||||
(defn log-info [& strs]
|
(defn log-info [& strs]
|
||||||
(let [log-level @log-level]
|
(let [log-level @log-level]
|
||||||
|
|
|
||||||
|
|
@ -825,6 +825,10 @@ true")))
|
||||||
(is (= :f (bb nil "(first (into-array [:f]))")))
|
(is (= :f (bb nil "(first (into-array [:f]))")))
|
||||||
(is (= :f (bb nil "(first (first (into-array [(into-array [:f])])))"))))
|
(is (= :f (bb nil "(first (first (into-array [(into-array [:f])])))"))))
|
||||||
|
|
||||||
|
(deftest var-names-test
|
||||||
|
(testing "for all public vars, ns/symbol from ns map matches metadata"
|
||||||
|
(is (empty? (bb nil (.getPath (io/file "test" "babashka" "scripts" "check_var_names.bb")))))))
|
||||||
|
|
||||||
;;;; Scratch
|
;;;; Scratch
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
|
|
|
||||||
14
test/babashka/scripts/check_var_names.bb
Normal file
14
test/babashka/scripts/check_var_names.bb
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
(require '[clojure.string :as str])
|
||||||
|
(let [ns-maps (->> (all-ns)
|
||||||
|
(map (fn [nmspc] [(ns-name nmspc) (ns-publics nmspc)]))
|
||||||
|
(into {})) ; a map of { ns-name {symbol var, ...}}
|
||||||
|
ns-maps (update ns-maps 'user #(dissoc % '*input*))] ; *input* is a special case that we'll skip over
|
||||||
|
(->>
|
||||||
|
(for [[ns-nm _] ns-maps
|
||||||
|
[sym vr] (ns-maps ns-nm)
|
||||||
|
:let [{var-meta-ns :ns, var-meta-name :name} (meta vr)
|
||||||
|
var-meta-ns-name (some-> var-meta-ns ns-name)]]
|
||||||
|
; build a seq of maps containing the ns/symbol from the ns and the ns/symbol from the var's metadata
|
||||||
|
{:actual-ns ns-nm :actual-ns-symbol sym :var-meta-ns var-meta-ns-name :var-meta-name var-meta-name})
|
||||||
|
; and remove the matches
|
||||||
|
(remove #(and (= (:actual-ns %) (:var-meta-ns %)) (= (:actual-ns-symbol %) (:var-meta-name %))))))
|
||||||
Loading…
Reference in a new issue