Skip to content

Commit 5ca3736

Browse files
committed
bb internal scripts: move get-os to its own helper
1 parent 0909f03 commit 5ca3736

File tree

8 files changed

+26
-24
lines changed

8 files changed

+26
-24
lines changed

script/ci_unit_tests.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env bb
22

33
(ns ci-unit-tests
4-
(:require [helper.env :as env]
5-
[helper.fs :as fs]
4+
(:require [helper.fs :as fs]
65
[helper.main :as main]
6+
[helper.os :as os]
77
[helper.shell :as shell]
88
[lread.status-line :as status]))
99

@@ -33,7 +33,7 @@
3333
(shell/command "bb test-shadow-cljs"))
3434

3535
(defn cljs-bootstrap-tests []
36-
(if (some #{(env/get-os)} '(:mac :unix))
36+
(if (some #{(os/get-os)} '(:mac :unix))
3737
(shell/command "bb test-cljs --env planck --optimizations none")
3838
(status/line :warn "skipping planck tests, they can only be run on linux and macOS")) )
3939

script/helper/env.clj

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
11
(ns helper.env
22
(:require [clojure.edn :as edn]
3-
[clojure.string :as string]
43
[helper.shell :as shell]
54
[lread.status-line :as status]
65
[version-clj.core :as ver]))
76

8-
(defn get-os []
9-
(let [os-name (string/lower-case (System/getProperty "os.name"))]
10-
(condp re-find os-name
11-
#"win" :win
12-
#"mac" :mac
13-
#"(nix|nux|aix)" :unix
14-
#"sunos" :solaris
15-
:unknown)))
16-
177
(defn- assert-clojure-min-version
188
"Asserts minimum version of Clojure version"
199
[]

script/helper/graal.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(ns helper.graal
22
(:require [clojure.java.io :as io]
33
[clojure.string :as string]
4-
[helper.env :as env]
54
[helper.fs :as fs]
5+
[helper.os :as os]
66
[helper.shell :as shell]
77
[lread.status-line :as status]))
88

@@ -12,10 +12,10 @@
1212
(fs/at-path (str (io/file (System/getenv "GRAALVM_HOME") "bin")) prog-name)))
1313

1414
(defn find-native-image-prog []
15-
(find-graal-prog (if (= :win (env/get-os)) "native-image.cmd" "native-image")))
15+
(find-graal-prog (if (= :win (os/get-os)) "native-image.cmd" "native-image")))
1616

1717
(defn find-gu-prog []
18-
(find-graal-prog (if (= :win (env/get-os)) "gu.cmd" "gu")))
18+
(find-graal-prog (if (= :win (os/get-os)) "gu.cmd" "gu")))
1919

2020
(defn- assert-min-native-image-version [native-image-exe]
2121
(let [min-major 21

script/helper/os.clj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(ns helper.os
2+
(:require [clojure.string :as string]))
3+
4+
(defn get-os []
5+
(let [os-name (string/lower-case (System/getProperty "os.name"))]
6+
(condp re-find os-name
7+
#"win" :win
8+
#"mac" :mac
9+
#"(nix|nux|aix)" :unix
10+
#"sunos" :solaris
11+
:unknown)))

script/helper/shell.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
(with-out-str (pprint/pprint cmd))))})
1212

1313
(defn command
14-
"Thin wrapper on babashka.tasks/shell that on error, prints status error message and exits."
14+
"Thin wrapper on babashka.tasks/shell that on error, prints status error message and exits.
15+
Automatically converts calls to clojure on Windows to call with powershell"
1516
[cmd & args]
1617
(let [[opts cmd args] (if (map? cmd)
1718
[cmd (first args) (rest args)]

script/test_native.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
(ns test-native
44
(:require [clojure.java.io :as io]
5-
[helper.env :as env]
65
[helper.fs :as fs]
76
[helper.graal :as graal]
87
[helper.main :as main]
8+
[helper.os :as os]
99
[helper.shell :as shell]
1010
[lread.status-line :as status]))
1111

@@ -37,7 +37,7 @@ Options:
3737
native-image-xmx "6g"
3838
target-path "target"
3939
target-exe "rewrite-clj-test"
40-
full-target-exe (str target-path "/" target-exe (when (= :win (env/get-os)) ".exe"))]
40+
full-target-exe (str target-path "/" target-exe (when (= :win (os/get-os)) ".exe"))]
4141
(status/line :head "Creating native image for test")
4242
(status/line :detail "java -version")
4343
(shell/command "java -version")

script/test_native_sci.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
(ns test-native-sci
44
(:require [clojure.java.io :as io]
5-
[helper.env :as env]
65
[helper.graal :as graal]
76
[helper.main :as main]
7+
[helper.os :as os]
88
[helper.shell :as shell]
99
[lread.status-line :as status]))
1010

@@ -45,7 +45,7 @@ Options:
4545
graal-reflection-fname "target/native-image/reflection.json"
4646
target-path "target"
4747
target-exe "sci-test-rewrite-clj"
48-
full-target-exe (str target-path "/" target-exe (when (= :win (env/get-os)) ".exe"))]
48+
full-target-exe (str target-path "/" target-exe (when (= :win (os/get-os)) ".exe"))]
4949
(status/line :head "Creating native image for testing via sci")
5050
(status/line :detail "java -version")
5151
(shell/command "java -version")

script/test_shadow_cljs.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env bb
22

33
(ns test-shadow-cljs
4-
(:require [helper.env :as env]
5-
[helper.main :as main]
4+
(:require [helper.main :as main]
5+
[helper.os :as os]
66
[helper.shell :as shell]
77
[lread.status-line :as status]))
88

@@ -12,7 +12,7 @@
1212
(defn -main [& args]
1313
(when (main/doc-arg-opt args)
1414
(status/line :head "testing ClojureScript source with Shadow CLJS, node, optimizations: none")
15-
(shell/command (if (= :win (env/get-os)) "npx.cmd" "npx")
15+
(shell/command (if (= :win (os/get-os)) "npx.cmd" "npx")
1616
"shadow-cljs" "compile" "test")
1717
(shell/command "node" compiled-tests))
1818
nil)

0 commit comments

Comments
 (0)