-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable running (most of) bbin's test suite on a JVM #92
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,5 @@ | |
/checkouts | ||
/classes | ||
/target | ||
|
||
/deps.local.edn | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,9 @@ | |
org.babashka/http-client {:mvn/version "0.1.8"}, | ||
version-clj/version-clj {:mvn/version "2.0.2"}, | ||
babashka/fs {:mvn/version "0.3.17"}, | ||
org.babashka/json {:mvn/version "0.1.1"}}}) | ||
ring/ring-core {:mvn/version "1.13.0"}, | ||
org.babashka/json {:mvn/version "0.1.1"}, | ||
http-kit/http-kit {:mvn/version "2.8.0"}}}) | ||
Comment on lines
-20
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't expect these dependencies to make it into |
||
|
||
(ns babashka.bbin.meta) | ||
(def min-bb-version "This def was generated by the bbin build script." "0.9.162") | ||
|
@@ -740,12 +742,21 @@ WARNING: (We won't make any changes without asking you first.) | |
(defn snake-case [s] | ||
(str/replace s "_" "-")) | ||
|
||
(defmacro whenbb [& forms] | ||
(when (System/getProperty "babashka.version") | ||
`(do ~@forms))) | ||
|
||
(defmacro ifbb [then else] | ||
(if (System/getProperty "babashka.version") | ||
then | ||
else)) | ||
Comment on lines
+749
to
+752
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
(ns babashka.bbin.scripts.common | ||
(:require [babashka.bbin.deps :as bbin-deps] | ||
[babashka.bbin.dirs :as dirs] | ||
[babashka.bbin.specs] | ||
[babashka.bbin.util :as util :refer [sh]] | ||
[babashka.deps :as deps] | ||
[babashka.bbin.util :as util :refer [sh whenbb]] | ||
;; [babashka.deps :as deps] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commented-out lines should be deleted! |
||
[babashka.fs :as fs] | ||
[clojure.edn :as edn] | ||
[clojure.main :as main] | ||
|
@@ -1040,8 +1051,9 @@ WARNING: (We won't make any changes without asking you first.) | |
header' (if (#{::no-lib} lib) | ||
{:coords {:bbin/url (str "file://" (get-in header [:coords :local/root]))}} | ||
header) | ||
_ (when-not (#{::no-lib} lib) | ||
(deps/add-deps {:deps script-deps})) | ||
_ (whenbb (when-not (#{::no-lib} lib) | ||
((requiring-resolve 'babashka.deps/add-deps) | ||
{:deps script-deps}))) | ||
script-root (fs/canonicalize (or (get-in header [:coords :local/root]) | ||
(local-lib-path script-deps)) | ||
{:nofollow-links true}) | ||
|
@@ -1249,8 +1261,7 @@ WARNING: (We won't make any changes without asking you first.) | |
(:require [babashka.bbin.dirs :as dirs] | ||
[babashka.bbin.protocols :as p] | ||
[babashka.bbin.scripts.common :as common] | ||
[babashka.bbin.util :as util] | ||
[babashka.deps :as deps] | ||
[babashka.bbin.util :as util :refer [whenbb]] | ||
[babashka.fs :as fs] | ||
[babashka.http-client :as http] | ||
[babashka.json :as json] | ||
|
@@ -1338,7 +1349,8 @@ WARNING: (We won't make any changes without asking you first.) | |
(select-keys cli-opts [:mvn/version])} | ||
header {:lib (key (first script-deps)) | ||
:coords (val (first script-deps))} | ||
_ (deps/add-deps {:deps script-deps}) | ||
_ (whenbb ((requiring-resolve 'babashka.deps/add-deps) | ||
{:deps script-deps}) ) | ||
script-root (fs/canonicalize (or (:local/root cli-opts) (common/local-lib-path script-deps)) {:nofollow-links true}) | ||
script-name (or (:as cli-opts) (second (str/split (:script/lib cli-opts) #"/"))) | ||
script-config (common/default-script-config cli-opts) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env sh | ||
clojure -M:kaocha "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bb | ||
|
||
(require '[lambdaisland.launchpad :as launchpad]) | ||
|
||
(launchpad/main {}) | ||
|
||
;; (launchpad/main {:steps (into [(partial launchpad/ensure-java-version 17)] | ||
;; launchpad/default-steps)}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
(ns babashka.bbin.dev | ||
(:require [babashka.process :refer [sh]] | ||
[clojure.core.async :refer [<!] :as async] | ||
[clojure.core.async :as async :refer [<!]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My editor did this without me noticing, I'll revert it! |
||
[clojure.string :as str] | ||
[pod.babashka.fswatcher :as fw] | ||
[taoensso.timbre :as log])) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
(:require [babashka.bbin.deps :as bbin-deps] | ||
[babashka.bbin.dirs :as dirs] | ||
[babashka.bbin.specs] | ||
[babashka.bbin.util :as util :refer [sh]] | ||
[babashka.deps :as deps] | ||
[babashka.bbin.util :as util :refer [sh whenbb]] | ||
;; [babashka.deps :as deps] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete out-commented line. |
||
[babashka.fs :as fs] | ||
[clojure.edn :as edn] | ||
[clojure.main :as main] | ||
|
@@ -298,8 +298,9 @@ | |
header' (if (#{::no-lib} lib) | ||
{:coords {:bbin/url (str "file://" (get-in header [:coords :local/root]))}} | ||
header) | ||
_ (when-not (#{::no-lib} lib) | ||
(deps/add-deps {:deps script-deps})) | ||
_ (whenbb (when-not (#{::no-lib} lib) | ||
((requiring-resolve 'babashka.deps/add-deps) | ||
{:deps script-deps}))) | ||
script-root (fs/canonicalize (or (get-in header [:coords :local/root]) | ||
(local-lib-path script-deps)) | ||
{:nofollow-links true}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -319,3 +319,12 @@ | |
|
||
(defn snake-case [s] | ||
(str/replace s "_" "-")) | ||
|
||
(defmacro whenbb [& forms] | ||
(when (System/getProperty "babashka.version") | ||
`(do ~@forms))) | ||
|
||
(defmacro ifbb [then else] | ||
(if (System/getProperty "babashka.version") | ||
then | ||
else)) | ||
Comment on lines
+327
to
+330
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
(ns babashka.bbin.scripts.maven-jar-test | ||
(:require [babashka.bbin.dirs :as dirs] | ||
[babashka.bbin.test-util :as tu] | ||
[babashka.bbin.util :refer [whenbb]] | ||
[babashka.fs :as fs] | ||
[clojure.string :as str] | ||
[clojure.test :refer [deftest is testing use-fixtures]])) | ||
|
@@ -28,18 +29,19 @@ | |
(is (= `{~'http-server ~maven-lib} (tu/run-ls)))))) | ||
|
||
(def upgraded-lib | ||
(assoc-in maven-lib [:coords :mvn/version] "0.1.12")) | ||
(assoc-in maven-lib [:coords :mvn/version] "0.1.13")) | ||
Comment on lines
31
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be a failing test on master too - |
||
|
||
(deftest upgrade-maven-jar-test | ||
(testing "upgrade (maven jar)" | ||
(tu/reset-test-dir) | ||
(dirs/ensure-bbin-dirs {}) | ||
(let [out (tu/run-install {:script/lib (str (:lib maven-lib)) | ||
:mvn/version (-> maven-lib :coords :mvn/version)}) | ||
out2 (tu/run-upgrade {:script/lib "http-server"})] | ||
(is (= maven-lib out)) | ||
(is (= upgraded-lib out2)) | ||
(is (fs/exists? (fs/file (dirs/bin-dir nil) (name (:lib upgraded-lib))))) | ||
(is (str/starts-with? (tu/run-bin-script (:lib upgraded-lib) "--help") | ||
help-text)) | ||
(is (= `{~'http-server ~upgraded-lib} (tu/run-ls)))))) | ||
(whenbb | ||
(deftest upgrade-maven-jar-test | ||
(testing "upgrade (maven jar)" | ||
(tu/reset-test-dir) | ||
(dirs/ensure-bbin-dirs {}) | ||
(let [out (tu/run-install {:script/lib (str (:lib maven-lib)) | ||
:mvn/version (-> maven-lib :coords :mvn/version)}) | ||
out2 (tu/run-upgrade {:script/lib "http-server"})] | ||
(is (= maven-lib out)) | ||
(is (= upgraded-lib out2)) | ||
(is (fs/exists? (fs/file (dirs/bin-dir nil) (name (:lib upgraded-lib))))) | ||
(is (str/starts-with? (tu/run-bin-script (:lib upgraded-lib) "--help") | ||
help-text)) | ||
(is (= {'http-server upgraded-lib} (tu/run-ls))))))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#kaocha/v1 {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No trailing final newline is ugly!