-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make tools.logging works as expected in CLJ and CLJS
- Loading branch information
Showing
8 changed files
with
806 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(ns funcool.tools.examples | ||
(:require | ||
[funcool.tools.logging :as l] | ||
[promesa.core :as p] | ||
[promesa.protocols :as pt] | ||
[promesa.exec :as px] | ||
[clojure.spec.alpha :as s])) | ||
|
||
(enable-console-print!) | ||
|
||
(l/set-level! :debug) | ||
|
||
(s/def ::foo int?) | ||
(s/def ::bar string?) | ||
(s/def ::foobar | ||
(s/keys :req-un [::foo ::bar])) | ||
|
||
(defn main | ||
[& args] | ||
(js/console.log "main" args)) | ||
|
||
(defn ^:dev/after-load after-load | ||
[] | ||
(let [data (s/explain-data ::foobar {:a 1})] | ||
(l/info :hello "world") | ||
(l/error :hello "error" | ||
:js/sample #js {:a 1 :b 2} | ||
:cause (ex-info "assertion error" data)))) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
(ns user | ||
(:require | ||
[clojure.pprint :refer [pprint]] | ||
[clojure.test :as test] | ||
[clojure.tools.namespace.repl :as r] | ||
[clojure.walk :refer [macroexpand-all]] | ||
[clojure.core.async :as a] | ||
[criterium.core :refer [quick-bench bench with-progress-reporting]] | ||
[promesa.core :as p] | ||
[promesa.exec :as px])) | ||
|
||
(defmacro run-quick-bench | ||
[& exprs] | ||
`(with-progress-reporting (quick-bench (do ~@exprs) :verbose))) | ||
|
||
(defmacro run-quick-bench' | ||
[& exprs] | ||
`(quick-bench (do ~@exprs))) | ||
|
||
(defmacro run-bench | ||
[& exprs] | ||
`(with-progress-reporting (bench (do ~@exprs) :verbose))) | ||
|
||
(defmacro run-bench' | ||
[& exprs] | ||
`(bench (do ~@exprs))) | ||
|
||
(defn- run-test | ||
([] (run-test #"^funcool.*")) | ||
([o] | ||
;; (r/refresh) | ||
(cond | ||
(instance? java.util.regex.Pattern o) | ||
(test/run-all-tests o) | ||
|
||
(symbol? o) | ||
(if-let [sns (namespace o)] | ||
(do (require (symbol sns)) | ||
(test/test-vars [(resolve o)])) | ||
(test/test-ns o))))) | ||
|
||
;; (defn -main | ||
;; [& args] | ||
;; (require 'promesa.tests.test-core) | ||
;; (let [{:keys [fail]} (run-test)] | ||
;; (if (pos? fail) | ||
;; (System/exit fail) | ||
;; (System/exit 0)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{:deps {:aliases [:dev]} | ||
:http {:port 3448} | ||
:nrepl {:port 3447 :host "0.0.0.0"} | ||
:jvm-opts ["-Xmx700m" "-Xms100m" "-XX:+UseSerialGC" "-XX:-OmitStackTraceInFastThrow"] | ||
:dev-http {8889 "target/examples"} | ||
|
||
:builds | ||
{ | ||
;; :test | ||
;; {:target :node-test | ||
;; :output-to "target/tests.js" | ||
;; :output-dir "target/test/" | ||
;; :ns-regexp "^promesa.tests.*-test$" | ||
;; :autorun true | ||
|
||
;; :compiler-options | ||
;; {:output-feature-set :es2020 | ||
;; :output-wrapper false | ||
;; :source-map true | ||
;; :source-map-include-sources-content true | ||
;; :source-map-detail-level :all | ||
;; :warnings {:fn-deprecated false}}} | ||
|
||
:examples | ||
{:target :browser | ||
:output-dir "target/examples/js" | ||
:asset-path "/js" | ||
:modules {:main {:entries [funcool.tools.examples]}} | ||
:compiler-options {:output-feature-set :es-next} | ||
:release | ||
{:compiler-options | ||
{:pseudo-names true | ||
:pretty-print true}}} | ||
|
||
}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.