From be29d791a8c024e4d098aa52aa5f5cd9c431ab22 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 2 Aug 2021 23:34:38 +0200 Subject: [PATCH] [#733] print-deps tests --- src/babashka/impl/print_deps.clj | 10 +++++++--- test/babashka/bb_edn_test.clj | 16 ++++++++++++++++ test/babashka/deps_test.clj | 5 ----- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/babashka/impl/print_deps.clj b/src/babashka/impl/print_deps.clj index d9a25218..5844f21d 100644 --- a/src/babashka/impl/print_deps.clj +++ b/src/babashka/impl/print_deps.clj @@ -5,7 +5,8 @@ [clojure.edn :as edn] [clojure.java.io :as io] [clojure.pprint :as pp] - [clojure.string :as str])) + [clojure.string :as str] + [sci.core :as sci])) (defn print-deps [deps-format] (let [deps (-> (io/resource "META-INF/babashka/deps.edn") @@ -21,7 +22,8 @@ 'org.postgresql/postgresql 'babashka/clojure-lanterna 'seancorfield/next.jdbc - 'datascript/datascript) + 'datascript/datascript + 'org.hsqldb/hsqldb) bb-edn-deps (:deps @common/bb-edn) deps (merge deps bb-edn-deps) paths (:paths @common/bb-edn) @@ -31,4 +33,6 @@ (case deps-format ("deps" nil) (binding [*print-namespace-maps* false] (pp/pprint deps)) - ("classpath") (println (str/trim (with-out-str (deps/clojure ["-Spath" "-Sdeps" deps]))))))) + ("classpath") (let [cp (str/trim (sci/with-out-str + (deps/clojure ["-Spath" "-Sdeps" deps] {:out :string})))] + (println cp))))) diff --git a/test/babashka/bb_edn_test.clj b/test/babashka/bb_edn_test.clj index ef963a33..26b63846 100644 --- a/test/babashka/bb_edn_test.clj +++ b/test/babashka/bb_edn_test.clj @@ -34,6 +34,22 @@ (is (= "src" (bb "-cp" "src" "-e" "(babashka.classpath/get-classpath)")))))) +(deftest print-deps-test + (test-utils/with-config '{:deps {medley/medley {:mvn/version "1.3.0"}}} + (testing "deps output" + (let [edn (bb "print-deps") + deps (:deps edn)] + (is deps) + (is (map? (get deps 'selmer/selmer))) + (is (string? (:mvn/version (get deps 'selmer/selmer)))) + (testing "user provided lib" + (is (map? (get deps 'medley/medley)))))) + (testing "classpath output" + (let [classpath (test-utils/bb nil "print-deps" "--format" "classpath")] + (is (str/includes? classpath "selmer")) + (is (str/includes? classpath (System/getProperty "path.separator"))) + (is (str/includes? classpath "medley")))))) + (deftest task-test (test-utils/with-config '{:tasks {foo (+ 1 2 3)}} (is (= 6 (bb "run" "--prn" "foo")))) diff --git a/test/babashka/deps_test.clj b/test/babashka/deps_test.clj index 4b72f4a2..397a01f9 100644 --- a/test/babashka/deps_test.clj +++ b/test/babashka/deps_test.clj @@ -113,8 +113,3 @@ true (str/replace ":env-key" ":extra-env"))) (is (fs/exists? libs-dir)) (is (fs/exists? libs-dir2))))) - -(deftest print-deps-test - - - )