Generates CLR-compatible test files from ^:rct/test blocks. Run via: clojure -M -m rct-clr.gen --help
Generates CLR-compatible test files from ^:rct/test blocks. Run via: clojure -M -m rct-clr.gen --help
(build-resolver ns-sym)Build a rewrite-clj auto-resolve map for a loaded namespace.
Build a rewrite-clj auto-resolve map for a loaded namespace.
(datum->form {:keys [test-sexpr expectation-type] :as datum} ns-sym output-ns)Convert an RCT datum to a Clojure form for the generated test. A => expectation lands in code position, as RCT emits it.
Convert an RCT datum to a Clojure form for the generated test. A => expectation lands in code position, as RCT emits it.
(file->ns-sym file)Get namespace symbol from a source file.
Get namespace symbol from a source file.
(file->rct-blocks file ns-sym)Extract RCT test data from a file, grouped by ^:rct/test block. Namespace must already be loaded. Returns a seq of seqs (one per comment block).
Extract RCT test data from a file, grouped by ^:rct/test block. Namespace must already be loaded. Returns a seq of seqs (one per comment block).
(find-source-files dir)Find all .clj and .cljc files in dir, keeping the .cljc when a namespace is present as both.
Find all .clj and .cljc files in dir, keeping the .cljc when a namespace is present as both.
(generate {:keys [src-dirs output namespace]})Scan source directories for ^:rct/test blocks and write the generated test file. Returns {:namespaces n :blocks n} on success. Throws ex-info if a namespace fails to load.
Scan source directories for ^:rct/test blocks and write the generated
test file. Returns {:namespaces n :blocks n} on success.
Throws ex-info if a namespace fails to load.(ns-sym->test-base ns-sym)Convert namespace symbol to base name for tests.
Convert namespace symbol to base name for tests.
(read-expectation {:keys [expectation-string expectation-type]} ns-sym)Read expectation string into a form, handling ellipses for =>>.
Read expectation string into a form, handling ellipses for =>>.
(resolve-reader-conditionals form ns-sym)Post-process a form from z/sexpr to resolve reader conditionals for CLR. rewrite-clj wraps unresolved #? forms as (read-string "#?(...)"), so this walks the tree and resolves them with :features #{:cljr}.
Post-process a form from z/sexpr to resolve reader conditionals for CLR.
rewrite-clj wraps unresolved #? forms as (read-string "#?(...)"), so this
walks the tree and resolves them with :features #{:cljr}.(validate-opts args)Parse and validate CLI options. Returns a tagged map: {:ok {:src-dirs [...] :output "..." :namespace "..."}} on success, {:help summary-string} for -h, {:errors ["msg" ...]} on failure.
Parse and validate CLI options. Returns a tagged map:
{:ok {:src-dirs [...] :output "..." :namespace "..."}} on success,
{:help summary-string} for -h, {:errors ["msg" ...]} on failure.(write-block-fn w fn-sym block-data ns-sym file output-ns)Write a defn- for a single ^:rct/test block, one run-form! call per line. Each form is quoted and eval'd by run-form!, so it resolves in the source namespace at test time, not the generated test namespace.
Write a defn- for a single ^:rct/test block, one run-form! call per line. Each form is quoted and eval'd by run-form!, so it resolves in the source namespace at test time, not the generated test namespace.
(write-deftest w ns-sym block-infos)Write a deftest that calls block fns in order. Binds ns to the source namespace so eval'd forms resolve there, and the REPL vars so bind-repl-vars! has a thread-local to set!.
Write a deftest that calls block fns in order. Binds *ns* to the source namespace so eval'd forms resolve there, and the REPL vars so bind-repl-vars! has a thread-local to set!.
(write-preamble w output-ns ns-syms)Write the ns form and the helpers the generated tests call. The ns is tagged ^:clr-only so Kaocha skips it on the JVM.
Write the ns form and the helpers the generated tests call. The ns is tagged ^:clr-only so Kaocha skips it on the JVM.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |