Remove Unix-specific classes (#227)

This commit is contained in:
Michiel Borkent 2020-01-08 11:48:40 +01:00 committed by GitHub
parent 6633d8b674
commit 2b0cb6fb1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 174 additions and 172 deletions

View file

@ -52,7 +52,7 @@ jobs:
mkdir -p /tmp/release
lein do clean, uberjar
VERSION=$(cat resources/BABASHKA_VERSION)
cp target/babashka-$VERSION-standalone.jar /tmp/release/babashka-$VERSION-linux-standalone.jar
cp target/babashka-$VERSION-standalone.jar /tmp/release/babashka-$VERSION-standalone.jar
- store_artifacts:
path: /tmp/release
destination: release

2
sci

@ -1 +1 @@
Subproject commit d9e6d7396374631731a9cc7b11dedb41281e867d
Subproject commit 1374d2a37b64e3d2216349345ff930b1154e39b3

View file

@ -2,18 +2,17 @@
{:no-doc true}
(:require
[cheshire.core :as json]
[clojure.string :as str]))
#_[clojure.string :as str]))
(def os-name (str/lower-case (System/getProperty "os.name")))
(def os (cond (str/includes? os-name "mac") :mac
(or (str/includes? os-name "nix")
(str/includes? os-name "nux")) :linux
(str/includes? os-name "win") :windows))
(def unix-like? (or (identical? os :linux)
(identical? os :mac)))
;; (def os-name (str/lower-case (System/getProperty "os.name")))
;; (def os (cond (str/includes? os-name "mac") :mac
;; (or (str/includes? os-name "nix")
;; (str/includes? os-name "nux")) :linux
;; (str/includes? os-name "win") :windows))
;; (def unix-like? (or (identical? os :linux)
;; (identical? os :mac)))
(def classes
(cond->
'{:all [java.io.BufferedReader
java.io.BufferedWriter
java.io.ByteArrayInputStream
@ -162,12 +161,7 @@
;; not supported: {:name "setURLStreamHandlerFactory"}
{:name "toExternalForm"}
{:name "toString"}
{:name "toURI"}]}}}
unix-like? (->
(update :methods conj 'sun.nio.fs.UnixPath)
(update :all conj
'java.lang.UNIXProcess
'java.lang.UNIXProcess$ProcessPipeOutputStream))))
{:name "toURI"}]}}})
(defmacro gen-class-map []
(let [classes (concat (:all classes)
@ -175,11 +169,17 @@
(:constructors classes)
(:methods classes)
(:fields classes)
(:instance-checks classes))]
(apply hash-map
(:instance-checks classes))
m (apply hash-map
(for [c classes
c [(list 'quote c) c]]
c))))
c))]
(assoc m :public-class
(fn [v]
(cond (instance? java.nio.file.Path v)
java.nio.file.Path
(instance? java.lang.Process v)
java.lang.Process)))))
(def class-map (gen-class-map))

View file

@ -169,6 +169,8 @@
(deftest process-builder-test
(is (str/includes? (bb nil "
(def ls (-> (ProcessBuilder. [\"ls\"]) (.start)))
(def input (.getOutputStream ls))
(.write (io/writer input) \"hello\") ;; dummy test just to see if this works
(def output (.getInputStream ls))
(assert (int? (.waitFor ls)))
(slurp output)")