Fix gaka tests
This commit is contained in:
parent
095dd0db99
commit
9220b983c5
4 changed files with 26 additions and 28 deletions
|
|
@ -15,7 +15,7 @@
|
||||||
:java-source-paths ["src-java"]
|
:java-source-paths ["src-java"]
|
||||||
:resource-paths ["resources" "sci/resources"]
|
:resource-paths ["resources" "sci/resources"]
|
||||||
:dependencies [[org.clojure/clojure "1.10.2-alpha2"]
|
:dependencies [[org.clojure/clojure "1.10.2-alpha2"]
|
||||||
[borkdude/edamame "0.0.11-alpha.28"]
|
[borkdude/edamame "0.0.11-alpha.29"]
|
||||||
[borkdude/graal.locking "0.0.2"]
|
[borkdude/graal.locking "0.0.2"]
|
||||||
[org.clojure/tools.cli "1.0.194"]
|
[org.clojure/tools.cli "1.0.194"]
|
||||||
[cheshire "5.10.0"]
|
[cheshire "5.10.0"]
|
||||||
|
|
|
||||||
|
|
@ -243,6 +243,7 @@
|
||||||
;; Nothing is marked "private" here, so you can rebind things to plug
|
;; Nothing is marked "private" here, so you can rebind things to plug
|
||||||
;; in your own testing or reporting frameworks.
|
;; in your own testing or reporting frameworks.
|
||||||
|
|
||||||
|
(def tns (sci/create-ns 'clojure.test nil))
|
||||||
|
|
||||||
;;; USER-MODIFIABLE GLOBALS
|
;;; USER-MODIFIABLE GLOBALS
|
||||||
|
|
||||||
|
|
@ -251,28 +252,28 @@
|
||||||
be created by deftest, set-test, or with-test. Use this to omit
|
be created by deftest, set-test, or with-test. Use this to omit
|
||||||
tests when compiling or loading production code."}
|
tests when compiling or loading production code."}
|
||||||
load-tests
|
load-tests
|
||||||
(sci/new-dynamic-var '*load-tests* true))
|
(sci/new-dynamic-var '*load-tests* true {:ns tns}))
|
||||||
|
|
||||||
(def
|
(def
|
||||||
^{:doc "The maximum depth of stack traces to print when an Exception
|
^{:doc "The maximum depth of stack traces to print when an Exception
|
||||||
is thrown during a test. Defaults to nil, which means print the
|
is thrown during a test. Defaults to nil, which means print the
|
||||||
complete stack trace."}
|
complete stack trace."}
|
||||||
stack-trace-depth
|
stack-trace-depth
|
||||||
(sci/new-dynamic-var '*stack-trace-depth* nil))
|
(sci/new-dynamic-var '*stack-trace-depth* nil {:ns tns}))
|
||||||
|
|
||||||
|
|
||||||
;;; GLOBALS USED BY THE REPORTING FUNCTIONS
|
;;; GLOBALS USED BY THE REPORTING FUNCTIONS
|
||||||
|
|
||||||
(def report-counters (sci/new-dynamic-var '*report-counters* nil)) ; bound to a ref of a map in test-ns
|
(def report-counters (sci/new-dynamic-var '*report-counters* nil {:ns tns})) ; bound to a ref of a map in test-ns
|
||||||
|
|
||||||
(def initial-report-counters ; used to initialize *report-counters*
|
(def initial-report-counters ; used to initialize *report-counters*
|
||||||
(sci/new-dynamic-var '*initial-report-counters* {:test 0, :pass 0, :fail 0, :error 0}))
|
(sci/new-dynamic-var '*initial-report-counters* {:test 0, :pass 0, :fail 0, :error 0} {:ns tns}))
|
||||||
|
|
||||||
(def testing-vars (sci/new-dynamic-var '*testing-vars* (list))) ; bound to hierarchy of vars being tested
|
(def testing-vars (sci/new-dynamic-var '*testing-vars* (list) {:ns tns})) ; bound to hierarchy of vars being tested
|
||||||
|
|
||||||
(def testing-contexts (sci/new-dynamic-var '*testing-contexts* (list))) ; bound to hierarchy of "testing" strings
|
(def testing-contexts (sci/new-dynamic-var '*testing-contexts* (list) {:ns tns})) ; bound to hierarchy of "testing" strings
|
||||||
|
|
||||||
(def test-out (sci/new-dynamic-var '*test-out* sci/out)) ; PrintWriter for test reporting output
|
(def test-out (sci/new-dynamic-var '*test-out* sci/out {:ns tns})) ; PrintWriter for test reporting output
|
||||||
|
|
||||||
(defmacro with-test-out-internal
|
(defmacro with-test-out-internal
|
||||||
"Runs body with *out* bound to the value of *test-out*."
|
"Runs body with *out* bound to the value of *test-out*."
|
||||||
|
|
@ -324,8 +325,6 @@
|
||||||
:added "1.1"}
|
:added "1.1"}
|
||||||
report-impl :type)
|
report-impl :type)
|
||||||
|
|
||||||
(def tns (sci/create-ns 'clojure.test nil))
|
|
||||||
|
|
||||||
(def report (sci/copy-var report-impl tns))
|
(def report (sci/copy-var report-impl tns))
|
||||||
|
|
||||||
(defn do-report
|
(defn do-report
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,17 @@
|
||||||
(ns babashka.impl.test
|
(ns babashka.impl.test
|
||||||
(:require [babashka.impl.clojure.test :as t]
|
(:require [babashka.impl.clojure.test :as t]
|
||||||
[babashka.impl.common :refer [ctx]]))
|
[babashka.impl.common :refer [ctx]]
|
||||||
|
[sci.core :as sci]))
|
||||||
(defn macrofy [v]
|
|
||||||
(with-meta v {:sci/macro true}))
|
|
||||||
|
|
||||||
(defn contextualize [f]
|
(defn contextualize [f]
|
||||||
(fn [& args]
|
(fn [& args]
|
||||||
(apply f @ctx args)))
|
(apply f @ctx args)))
|
||||||
|
|
||||||
|
(def tns t/tns)
|
||||||
|
|
||||||
(def clojure-test-namespace
|
(def clojure-test-namespace
|
||||||
{'*load-tests* t/load-tests
|
{:obj tns
|
||||||
|
'*load-tests* t/load-tests
|
||||||
'*stack-trace-depth* t/stack-trace-depth
|
'*stack-trace-depth* t/stack-trace-depth
|
||||||
'*report-counters* t/report-counters
|
'*report-counters* t/report-counters
|
||||||
'*initial-report-counters* t/initial-report-counters
|
'*initial-report-counters* t/initial-report-counters
|
||||||
|
|
@ -30,18 +31,16 @@
|
||||||
'assert-any t/assert-any
|
'assert-any t/assert-any
|
||||||
;; assertion methods
|
;; assertion methods
|
||||||
'assert-expr t/assert-expr
|
'assert-expr t/assert-expr
|
||||||
'try-expr (with-meta @#'t/try-expr
|
'try-expr (sci/copy-var t/try-expr tns)
|
||||||
{:sci/macro true})
|
|
||||||
;; assertion macros
|
;; assertion macros
|
||||||
'is (with-meta @#'t/is
|
'is (sci/copy-var t/is tns)
|
||||||
{:sci/macro true})
|
'are (sci/copy-var t/are tns)
|
||||||
'are (macrofy @#'t/are)
|
'testing (sci/copy-var t/testing tns)
|
||||||
'testing (macrofy @#'t/testing)
|
|
||||||
;; defining tests
|
;; defining tests
|
||||||
'with-test (macrofy @#'t/with-test)
|
'with-test (sci/copy-var t/with-test tns)
|
||||||
'deftest (macrofy @#'t/deftest)
|
'deftest (sci/copy-var t/deftest tns)
|
||||||
'deftest- (macrofy @#'t/deftest-)
|
'deftest- (sci/copy-var t/deftest- tns)
|
||||||
'set-test (macrofy @#'t/set-test)
|
'set-test (sci/copy-var t/set-test tns)
|
||||||
;; fixtures
|
;; fixtures
|
||||||
'use-fixtures t/use-fixtures
|
'use-fixtures t/use-fixtures
|
||||||
'compose-fixtures t/compose-fixtures
|
'compose-fixtures t/compose-fixtures
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
(ns gaka.core-test
|
(ns gaka.core-test
|
||||||
(:require [clojure.test :refer [deftest is #_are]]
|
(:require [clojure.test :refer [deftest is are]]
|
||||||
[gaka.core :refer [css compile* inline-css render-rule]]
|
[gaka.core :refer [css compile* inline-css render-rule]]
|
||||||
))
|
))
|
||||||
|
|
||||||
(defmacro =? [& body]
|
(defmacro =? [& body]
|
||||||
`(clojure.test/are [x# y#] (= x# y#)
|
`(are [x# y#] (= x# y#)
|
||||||
~@body))
|
~@body))
|
||||||
|
|
||||||
(deftest test-flatten
|
(deftest test-flatten
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
(=? (flatten-maps [1 2 {3 4}])
|
(=? (flatten-maps [1 2 {3 4}])
|
||||||
[1 2 3 4])
|
[1 2 3 4])
|
||||||
|
|
||||||
#_(=? (flatten-maps [1 {2 3 4 5} 6])
|
(=? (flatten-maps [1 {2 3 4 5} 6])
|
||||||
[1 2 3 4 5 6])
|
[1 2 3 4 5 6])
|
||||||
|
|
||||||
(=? (flatten-keyvals [1 '(2 {3 4} 5)])
|
(=? (flatten-keyvals [1 '(2 {3 4} 5)])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue