-
Notifications
You must be signed in to change notification settings - Fork 2
/
tests.clj
57 lines (49 loc) · 2.02 KB
/
tests.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(require
'[babashka.process :as p]
'[clojure.string :as s]
'[clojure.java.shell :as csh])
(defn- shell
[inherit? cmd & args]
(p/process (into (p/tokenize cmd) (remove nil? args)) {:inherit inherit?}))
(defn github-graalvm-version
[]
(let [result (s/trim (:out (csh/sh (str (System/getenv "GRAALVM_HOME") "/bin/native-image") "--version")))
graalvm-version (second (first (re-seq #"GraalVM ([A-Za-z\.0-9-]+)" result)))]
(println "> GraalVM Version" graalvm-version)
graalvm-version))
(def configs
[{:name "ring/ring-jetty-adapter"}
{:name "com.taoensso/nippy"}
{:name "cheshire/cheshire"}
{:name "com.h2database/h2"}
{:name "com.github.seancorfield/next.jdbc"}
{:name "org.slf4j/slf4j-simple"}
{:name "clj-http/clj-http"}
{:name "clj-easy/nippy-mikera-vectorz"}])
(defn config->root-path
[config]
(str "config/" (:name config)))
(defn config->test-path
[config]
(str (config->root-path config) "/example"))
(defn should-test?
[config]
(= 1 (:exit @(shell false "git" "diff" "--exit-code" "HEAD~1" "HEAD" "--" (config->root-path config)))))
(defn run-tests!
[]
(doseq [config configs
:let [run-tests (fn [version]
(let [result @(shell true (str "bash -c \"bb native-image-test :dir " (config->test-path config) " :graalvm-version " "provided" "\""))]
(if (= 0 (:exit result))
(println ">>> Successful test!")
(System/exit 1)))
(println ">> Running tests for config:" (:name config) "GraalVM version:" version "...Success!"))]]
(if (and (not (System/getenv "LOCAL")) (not (should-test? config)))
(println "> Skipping tests for config:" (:name config))
(do
(println "> Running tests for config:" (:name config))
(if (System/getenv "LOCAL")
(doseq [version (:versions config)]
(run-tests version))
(run-tests "provided"))))))
(run-tests!)