File tree 14 files changed +295
-123
lines changed
14 files changed +295
-123
lines changed Original file line number Diff line number Diff line change 43
43
- name : Lint
44
44
run : bb lint
45
45
46
- test :
46
+ test-jvm :
47
47
runs-on : ${{ matrix.os }}-latest
48
48
strategy :
49
49
fail-fast : false
@@ -78,24 +78,21 @@ jobs:
78
78
uses : DeLaGuardo/setup-clojure@9.4
79
79
with :
80
80
bb : ' latest'
81
- cli : ' latest'
82
81
83
82
- name : Tools versions
84
83
run : |
85
84
echo "bb --version"
86
85
bb --version
87
- echo "clojure --version"
88
- clojure --version
89
86
echo "java -version"
90
87
java -version
91
88
92
89
- name : Bring down deps
93
90
run : bb deps
94
91
95
92
- name : Run tests
96
- run : clojure -M: ${{ matrix.clojure-version }}:test
93
+ run : bb test:jvm --clj-version ${{ matrix.clojure-version }}
97
94
98
- bb- test :
95
+ test-bb :
99
96
runs-on : ${{ matrix.os }}-latest
100
97
strategy :
101
98
fail-fast : false
@@ -143,8 +140,8 @@ jobs:
143
140
runs-on : ubuntu-latest
144
141
needs :
145
142
- lint
146
- - test
147
- - bb- test
143
+ - test-jvm
144
+ - test-bb
148
145
149
146
steps :
150
147
- 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.
315
315
316
316
### Clojure JVM Tests
317
317
318
- To run tests for the JVM:
319
-
318
+ Optionally:
320
319
``` shell
321
320
$ bb clean
322
321
$ bb deps
322
+ ```
323
+
324
+ Run all Clojure tests against minimum supported version of Clojure (1.8):
323
325
324
- Run all Clojure tests against minimum supported version of Clojure (1.8)
325
- $ clojure -M:test
326
+ ``` shell
327
+ $ bb test:jvm
328
+ ```
326
329
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.*'
329
338
```
330
339
331
340
### Babashka Tests
332
341
333
- To run a small suite of sanity tests for babashka (found under ./bb ] ) :
342
+ To run the entire test suite under Babashka :
334
343
335
344
``` shell
336
345
$ bb test:bb
337
346
```
347
+ You can also include cognitect test runner options:
348
+ ``` shell
349
+ $ bb test:bb --var clj-http.lite.integration-test/roundtrip
350
+ ```
338
351
339
352
### Linting
340
353
Original file line number Diff line number Diff line change 1
1
{: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"
4
3
:sha " 35ed39645038e81b42cb15ed6753b8462e60a06d" }}
5
4
:tasks
6
5
{:requires ([tasks :as t])
10
9
clean
11
10
{:doc " Delete any work dirs"
12
11
: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}
13
15
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*)}
16
24
lint
17
25
{:doc " [--rebuild] Lint source code"
18
26
: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 9
9
{:deps {io.github.clojure/tools.build {:git/tag " v0.8.3" :git/sha " 0d20256" }
10
10
slipset/deps-deploy {:mvn/version " 0.2.0" }}
11
11
:ns-default build}
12
- :test
12
+ :http-server ; ; used for to support integration tests
13
13
{: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 " }
16
16
ring/ring-jetty-adapter {:mvn/version " 1.9.5" }
17
17
ch.qos.logback/logback-classic {:mvn/version " 1.2.11"
18
18
:exclusions [org.slf4j/slf4j-api]}
19
19
org.slf4j/jcl-over-slf4j {:mvn/version " 1.7.36" }
20
20
org.slf4j/jul-to-slf4j {:mvn/version " 1.7.36" }
21
21
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" }}
22
27
:main-opts [" -m" " cognitect.test-runner" ]}
23
28
; ; for consistent linting we use a specific version of clj-kondo through the jvm
24
29
: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]
4
5
[clojure.test :as t :refer [deftest is]]))
5
6
6
7
(deftest client-test
11
12
(is (= 200 (:status (client/post " https://postman-echo.com/post" {:throw-exceptions false }))))
12
13
13
14
(is (= 200 (:status (client/post " https://postman-echo.com/post"
14
- {:body ( json/generate-string { :a 1 })
15
+ {:body " { \" a \" : 1}"
15
16
:headers {" X-Hasura-Role" " admin" }
16
17
:content-type :json
17
18
:accept :json
18
19
:throw-exceptions false }))))
19
20
20
21
(is (= 200 (:status (client/put " https://postman-echo.com/put"
21
- {:body ( json/generate-string { :a 1 })
22
+ {:body " { \" a \" : 1}"
22
23
:headers {" X-Hasura-Role" " admin" }
23
24
:content-type :json
24
25
:accept :json
Original file line number Diff line number Diff line change 1
1
(ns clj-http.lite.client-test
2
2
(:require [clj-http.lite.client :as client]
3
3
[clj-http.lite.util :as util]
4
+ [clj-http.lite.test-util.test-report]
4
5
[clojure.test :refer [deftest is testing]])
5
6
(:import (java.net UnknownHostException)))
6
7
132
133
(is (= " fooⓕⓞⓞ" (:body resp)))))
133
134
134
135
(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 " }})
137
138
o-client (client/wrap-output-coercion client)
138
139
resp (o-client {:uri " /foo" :as :auto })]
139
140
(is (= " sõme ßÒññÝ chÀråcters" (:body resp)))))
153
154
(doseq [[in-body encoding expected-encoding] [[" μτƒ8 нαs мαηλ ςнαяαςτεяs ൠ" nil " UTF-8" ]
154
155
[" μτƒ8 нαs мαηλ ςнαяαςτεяs ൠ" " UTF-8" " UTF-8" ]
155
156
[" 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 " ]]]
157
158
(let [resp (i-client {:body in-body :body-encoding encoding})
158
159
decoded-body (slurp (:body resp) :encoding expected-encoding)]
159
160
(is (= expected-encoding (:character-encoding resp)) " character encoding" )
You can’t perform that action at this time.
0 commit comments