forked from clj-commons/etaoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
road to bb: http-client-lite & tests
When running babashka, we now use the compatible http-client-lite. (Thanks borkdude your etaoin pod work was a very useful reference!) (I worked around an issue in http-client-lite when running on Windows. See clj-commons/clj-http-lite#18) Reader conditionals select the existing http-client when running on from the JVM. Reader conditionals mean .cljc, which often means Clojure and ClojureScript, but in our case it means JVM Clojure and Babashka Clojure. Update configs for cljdoc and clj-kondo to let them know that this is not a ClojureScript project. Facility to test our bb implementation added via a new --platform option on our `bb test` task. I'm not sure of the best way to run babashka tests, but my first stab generates a runner.clj with appropriate namespaces and classpath then runs that. Etaoin does have some debug logging, so Babashka's log level is adjusted from the default of debug to info in the generated test runner. Finally adjusted our CI matrix to include the bb platform. Contributes to clj-commons#380
- Loading branch information
Showing
11 changed files
with
196 additions
and
67 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
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Test | |
|
||
on: | ||
push: | ||
branches: ['master'] | ||
branches: ['lread-*'] | ||
pull_request: | ||
|
||
jobs: | ||
|
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 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 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{:cljdoc.doc/tree | ||
[["Readme" {:file "README.adoc"}] | ||
["Changelog" {:file "CHANGELOG.adoc"}]] | ||
:cljdoc/languages ["clj"]} |
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 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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
(ns bb-test-runner | ||
(:require [babashka.fs :as fs] | ||
[clojure.string :as string] | ||
[babashka.tasks :as tasks] | ||
[helper.main :as main])) | ||
|
||
(def id->nses {:ide ['etaoin.ide-test] | ||
:api ['etaoin.api-test] | ||
:unit (->> "test/etaoin/unit" | ||
fs/list-dir | ||
(map #(fs/relativize "test" %)) | ||
(map #(string/replace % #"\.clj$" "")) | ||
(map #(string/replace % fs/file-separator ".")) | ||
(map #(string/replace % "_" "-")) | ||
sort)}) | ||
|
||
(def args-usage "Valid args: | ||
(unit|api|ide|all) | ||
--help | ||
Commands: | ||
unit Run only unit tests | ||
api Run only api tests | ||
ide Run only ide tests | ||
all Run all tests | ||
Options: | ||
--help Show this help | ||
Intended to be called from test.clj where setup for such things as browser | ||
web browser selection and virtual displays occur") | ||
|
||
(defn -main [& args] | ||
(when-let [opts (main/doc-arg-opt args-usage args)] | ||
(let [;; we only need bb-spec for ide and unit tests tests, so explicitly otherwise test without it | ||
cp-aliases (if (or (get opts "all") (get opts "ide") (get opts "unit")) | ||
":test:bb-spec" | ||
":test") | ||
nses (cond | ||
(get opts "ide") (:ide id->nses) | ||
(get opts "api") (:api id->nses) | ||
(get opts "unit") (:unit id->nses) | ||
(get opts "all") (mapcat second id->nses)) | ||
runner (-> "script/bb_test_runner_template.clj" | ||
slurp | ||
(string/replace "{{cp-aliases}}" cp-aliases) | ||
(string/replace "{{nses}}" (->> nses | ||
(map #(str "'" %)) | ||
(string/join " ")))) | ||
test-runner-file (-> (fs/create-temp-file {:prefix "bb-test-runner" | ||
:suffix ".clj"}) | ||
fs/file)] | ||
(spit test-runner-file runner) | ||
(tasks/shell "bb" test-runner-file) | ||
(try | ||
(finally | ||
(fs/delete-if-exists test-runner-file)))))) | ||
|
||
(main/when-invoked-as-script | ||
(apply -main *command-line-args*)) |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(require '[babashka.classpath :as cp] | ||
'[babashka.tasks :as tasks] | ||
'[clojure.test :as t] | ||
'[taoensso.timbre :as timbre]) | ||
|
||
;; bb log level by default is debug, let's set it to info | ||
;; TODO: maybe there is some different abstraction for this? | ||
(alter-var-root #'timbre/*config* #(assoc %1 :min-level :info)) | ||
|
||
(cp/add-classpath (with-out-str (tasks/clojure "-A{{cp-aliases}} -Spath"))) | ||
|
||
(require {{nses}}) | ||
|
||
(let [test-results (t/run-tests {{nses}})] | ||
(System/exit (+ (:fail test-results) (:error test-results)))) |
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
Oops, something went wrong.