File tree Expand file tree Collapse file tree 14 files changed +295
-123
lines changed Expand file tree Collapse file tree 14 files changed +295
-123
lines changed Original file line number Diff line number Diff line change 4343 - name : Lint
4444 run : bb lint
4545
46- test :
46+ test-jvm :
4747 runs-on : ${{ matrix.os }}-latest
4848 strategy :
4949 fail-fast : false
@@ -78,24 +78,21 @@ jobs:
7878 uses : DeLaGuardo/setup-clojure@9.4
7979 with :
8080 bb : ' latest'
81- cli : ' latest'
8281
8382 - name : Tools versions
8483 run : |
8584 echo "bb --version"
8685 bb --version
87- echo "clojure --version"
88- clojure --version
8986 echo "java -version"
9087 java -version
9188
9289 - name : Bring down deps
9390 run : bb deps
9491
9592 - name : Run tests
96- run : clojure -M: ${{ matrix.clojure-version }}:test
93+ run : bb test:jvm --clj-version ${{ matrix.clojure-version }}
9794
98- bb- test :
95+ test-bb :
9996 runs-on : ${{ matrix.os }}-latest
10097 strategy :
10198 fail-fast : false
@@ -143,8 +140,8 @@ jobs:
143140 runs-on : ubuntu-latest
144141 needs :
145142 - lint
146- - test
147- - bb- test
143+ - test-jvm
144+ - test-bb
148145
149146 steps :
150147 - name : Checkout
Original file line number Diff line number Diff line change @@ -315,26 +315,39 @@ are sugar over this `clj-http.lite.client/request` function.
315315
316316### Clojure JVM Tests
317317
318- To run tests for the JVM:
319-
318+ Optionally:
320319``` shell
321320$ bb clean
322321$ bb deps
322+ ```
323+
324+ Run all Clojure tests against minimum supported version of Clojure (1.8):
323325
324- Run all Clojure tests against minimum supported version of Clojure (1.8)
325- $ clojure -M:test
326+ ``` shell
327+ $ bb test:jvm
328+ ```
326329
327- Run Clojure against a specific Clojure version, for example 1.11
328- $ clojure -M:1.11:test
330+ Run tests against a specific Clojure version, for example 1.11
331+ ``` shell
332+ $ bb test:jvm --clj-version 1.11
333+ ```
334+
335+ You can also include cognitect test runner options:
336+ ``` shell
337+ $ bb test:jvm --clj-version 1.9 --namespace-regex ' *.sanity.*'
329338```
330339
331340### Babashka Tests
332341
333- To run a small suite of sanity tests for babashka (found under ./bb ] ) :
342+ To run the entire test suite under Babashka :
334343
335344``` shell
336345$ bb test:bb
337346```
347+ You can also include cognitect test runner options:
348+ ``` shell
349+ $ bb test:bb --var clj-http.lite.integration-test/roundtrip
350+ ```
338351
339352### Linting
340353
Original file line number Diff line number Diff line change 11{:paths [" ." " bb" ]
2- :deps {org.clj-commons/clj-http-lite {:local/root " ." }
3- lread/status-line {:git/url " https://github.com/lread/status-line.git"
2+ :deps {lread/status-line {:git/url " https://github.com/lread/status-line.git"
43 :sha " 35ed39645038e81b42cb15ed6753b8462e60a06d" }}
54 :tasks
65 {:requires ([tasks :as t])
109 clean
1110 {:doc " Delete any work dirs"
1211 :task (clojure " -T:build clean" )}
12+ test:jvm
13+ {:doc " Runs tests under JVM Clojure [--clj-version] (recognizes cognitect test-runner args)"
14+ :task test-jvm/-main}
1315 test:bb
14- {:doc " Run babashka tests"
15- :task clj-http.lite.test-runner/-main}
16+ {:doc " Runs tests under babashka Clojure (recognizes cognitect test-runner args)"
17+ :extra-paths [" src" " test" " test-resources" ]
18+ :extra-deps {io.github.cognitect-labs/test-runner
19+ {:git/tag " v0.5.1" :git/sha " dfb30dd" }
20+ org.clojure/tools.namespace {:git/url " https://github.com/babashka/tools.namespace"
21+ :git/sha " 16b8c53174a5c9d89d6e0ce4128aa30b071aabdf" }}
22+ :requires ([cognitect.test-runner :as tr])
23+ :task (apply tr/-main *command-line-args*)}
1624 lint
1725 {:doc " [--rebuild] Lint source code"
1826 :task lint/-main}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ (ns test-jvm
2+ (:require [babashka.cli :as cli]
3+ [babashka.tasks :as t]
4+ [lread.status-line :as status]))
5+
6+ (defn -main [& args]
7+ (let [valid-clojure-versions [" 1.8" " 1.9" " 1.10" " 1.11" ]
8+ spec {:clj-version
9+ {:ref " <version>"
10+ :desc " The Clojure version to test against."
11+ :coerce :string
12+ :default-desc " 1.8"
13+ ; ; don't specify :default, we want to know if the user passed this option in
14+ :validate
15+ {:pred (set valid-clojure-versions)
16+ :ex-msg (fn [_m]
17+ (str " --clj-version must be one of: " valid-clojure-versions))}}}
18+ opts (cli/parse-opts args {:spec spec})
19+ clj-version (:clj-version opts)
20+ runner-args (if-not clj-version
21+ args
22+ (loop [args args
23+ out-args []]
24+ (if-let [a (first args)]
25+ (if (re-matches #"(--|:)clj-version" a)
26+ (recur (drop 2 args) out-args)
27+ (recur (rest args) (conj out-args a)))
28+ out-args)))
29+ clj-version (or clj-version " 1.8" )]
30+
31+ (if (:help opts)
32+ (do
33+ (status/line :head " bb task option help" )
34+ (println (cli/format-opts {:spec spec}))
35+ (status/line :head " test-runner option help" )
36+ (t/clojure " -M:test --test-help" ))
37+ (do
38+ (println " Testing against Clojure" clj-version)
39+ (apply t/clojure (format " -M:%s:test" clj-version) runner-args)))))
40+
41+ (when (= *file* (System/getProperty " babashka.file" ))
42+ (apply -main *command-line-args*))
Original file line number Diff line number Diff line change 99 {:deps {io.github.clojure/tools.build {:git/tag " v0.8.3" :git/sha " 0d20256" }
1010 slipset/deps-deploy {:mvn/version " 0.2.0" }}
1111 :ns-default build}
12- :test
12+ :http-server ; ; used for to support integration tests
1313 {:extra-paths [" test" " test-resources" ]
14- :extra -deps {io.github.cognitect-labs/test-runner
15- { :git/tag " v0.5.1 " :git/sha " dfb30dd " }
14+ :override -deps {org.clojure/clojure { :mvn/version " 1.11.1 " }}
15+ :extra-deps {babashka/fs { :mvn/version " 0.1.6 " }
1616 ring/ring-jetty-adapter {:mvn/version " 1.9.5" }
1717 ch.qos.logback/logback-classic {:mvn/version " 1.2.11"
1818 :exclusions [org.slf4j/slf4j-api]}
1919 org.slf4j/jcl-over-slf4j {:mvn/version " 1.7.36" }
2020 org.slf4j/jul-to-slf4j {:mvn/version " 1.7.36" }
2121 org.slf4j/log4j-over-slf4j {:mvn/version " 1.7.36" }}
22+ :exec-fn clj-http.lite.test-util.http-server/run}
23+ :test
24+ {:extra-paths [" test" ]
25+ :extra-deps {io.github.cognitect-labs/test-runner
26+ {:git/tag " v0.5.1" :git/sha " dfb30dd" }}
2227 :main-opts [" -m" " cognitect.test-runner" ]}
2328 ; ; for consistent linting we use a specific version of clj-kondo through the jvm
2429 :clj-kondo {:extra-deps {clj-kondo/clj-kondo {:mvn/version " 2022.08.03" }}
Original file line number Diff line number Diff line change 1- (ns clj-http.lite.client-test
2- (:require [cheshire.core :as json]
3- [clj-http.lite.client :as client]
1+ (ns clj-http.lite.client-sanity-test
2+ " A small subset of tests suitable for sanity testing.
3+ Used by babashka libs tests."
4+ (:require [clj-http.lite.client :as client]
45 [clojure.test :as t :refer [deftest is]]))
56
67(deftest client-test
1112 (is (= 200 (:status (client/post " https://postman-echo.com/post" {:throw-exceptions false }))))
1213
1314 (is (= 200 (:status (client/post " https://postman-echo.com/post"
14- {:body ( json/generate-string { :a 1 })
15+ {:body " { \" a \" : 1}"
1516 :headers {" X-Hasura-Role" " admin" }
1617 :content-type :json
1718 :accept :json
1819 :throw-exceptions false }))))
1920
2021 (is (= 200 (:status (client/put " https://postman-echo.com/put"
21- {:body ( json/generate-string { :a 1 })
22+ {:body " { \" a \" : 1}"
2223 :headers {" X-Hasura-Role" " admin" }
2324 :content-type :json
2425 :accept :json
Original file line number Diff line number Diff line change 11(ns clj-http.lite.client-test
22 (:require [clj-http.lite.client :as client]
33 [clj-http.lite.util :as util]
4+ [clj-http.lite.test-util.test-report]
45 [clojure.test :refer [deftest is testing]])
56 (:import (java.net UnknownHostException)))
67
132133 (is (= " fooⓕⓞⓞ" (:body resp)))))
133134
134135(deftest apply-on-other-output-coercion
135- (let [client (fn [_req] {:body (.getBytes " sõme ßÒññÝ chÀråcters" " windows-1252 " )
136- :headers {" content-type" " text/foo;charset=windows-1252 " }})
136+ (let [client (fn [_req] {:body (.getBytes " sõme ßÒññÝ chÀråcters" " ISO-8859-1 " )
137+ :headers {" content-type" " text/foo;charset=ISO-8859-1 " }})
137138 o-client (client/wrap-output-coercion client)
138139 resp (o-client {:uri " /foo" :as :auto })]
139140 (is (= " sõme ßÒññÝ chÀråcters" (:body resp)))))
153154 (doseq [[in-body encoding expected-encoding] [[" μτƒ8 нαs мαηλ ςнαяαςτεяs ൠ" nil " UTF-8" ]
154155 [" μτƒ8 нαs мαηλ ςнαяαςτεяs ൠ" " UTF-8" " UTF-8" ]
155156 [" plain text" " ASCII" " ASCII" ]
156- [" sõme ßÒññÝ chÀråcters" " windows-1252 " " windows-1252 " ]]]
157+ [" sõme ßÒññÝ chÀråcters" " iso-8859-1 " " iso-8859-1 " ]]]
157158 (let [resp (i-client {:body in-body :body-encoding encoding})
158159 decoded-body (slurp (:body resp) :encoding expected-encoding)]
159160 (is (= expected-encoding (:character-encoding resp)) " character encoding" )
You can’t perform that action at this time.
0 commit comments