diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 957dba6..cc8cae4 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -16,6 +16,10 @@ A release with known breaking changes is marked with: == Unreleased +* Tests can now be generated from a header-less doc +https://github.com/lread/test-doc-blocks/issues/25[#25] +(thanks for the feedback https://github.com/genmeblog[@genmeblog]!) + == v1.1.19 - 2024-05-02 [[v1.1.19]] * Drop `alpha` status, we don't have many users, but folks have been using this lib for years diff --git a/README.adoc b/README.adoc index 1294c24..d76325d 100644 --- a/README.adoc +++ b/README.adoc @@ -67,6 +67,7 @@ Test-doc-block versioning scheme is: `major`.`minor`.`release`-`test-qualifier` image:seancorfield.png[seancorfield,width=273,link="https://github.com/seancorfield"] image:MIJOTHY.png[MIJOTHY,width=273,link="https://github.com/MIJOTHY"] image:borkdude.png[borkdude,width=273,link="https://github.com/borkdude"] +image:genmeblog.png[genmeblog,width=273,link="https://github.com/genmeblog"] image:holyjak.png[holyjak,width=273,link="https://github.com/holyjak"] image:PEZ.png[PEZ,width=273,link="https://github.com/PEZ"] image:SevereOverfl0w.png[SevereOverfl0w,width=273,link="https://github.com/SevereOverfl0w"] diff --git a/deps.edn b/deps.edn index 78691f3..7897297 100644 --- a/deps.edn +++ b/deps.edn @@ -32,7 +32,8 @@ ;; but on Windows it can be very time consuming to learn how to escape them ;; sooo... I'm putting :docs here :test-opts {:exec-args {:docs ["doc/01-user-guide.adoc" - "doc/example.{adoc,md,cljc}"]}} + "doc/example.{adoc,md,cljc}" + "test-resources/doc/*.{adoc,md}"]}} ;; and :target, even passing a "\"string\"" is hard on windows :regen-opts {:exec-args {:target-root "test-resources/expected"}} diff --git a/doc/contributors.edn b/doc/contributors.edn index 6562abc..39bae9f 100644 --- a/doc/contributors.edn +++ b/doc/contributors.edn @@ -7,7 +7,8 @@ {:github-id "seancorfield" :contributions [:inspiration :feedback :testing]} {:github-id "uochan" :contributions [:feedback]} {:github-id "holyjak" :contributions [:docs]} - {:github-id "MIJOTHY" :contributions [:feedback :docs]}] + {:github-id "MIJOTHY" :contributions [:feedback :docs]} + {:github-id "genmeblog" :contributions [:feedback]}] :maintainers [{:github-id "lread" :contributions [:code]}]} diff --git a/doc/generated/contributors/genmeblog.png b/doc/generated/contributors/genmeblog.png new file mode 100644 index 0000000..c7ae0fc Binary files /dev/null and b/doc/generated/contributors/genmeblog.png differ diff --git a/src/lread/test_doc_blocks.clj b/src/lread/test_doc_blocks.clj index 11483da..221b4e8 100644 --- a/src/lread/test_doc_blocks.clj +++ b/src/lread/test_doc_blocks.clj @@ -33,7 +33,8 @@ (doseq [[fname headers] fnames] (println (indent fname indent-cnt)) (doseq [[header lines] (->> headers (group-by :header) (into []) (sort-by #(-> % second first :line-no)))] - (println (indent header (+ 2 indent-cnt))) + (when header + (println (indent header (+ 2 indent-cnt)))) (doseq [line lines] (println (-> (format "%03d: %s" (:line-no line) (:test-doc-blocks/test-ns line)) (indent (+ 4 indent-cnt))))))))) diff --git a/test-resources/doc/minimal.adoc b/test-resources/doc/minimal.adoc new file mode 100644 index 0000000..e968388 --- /dev/null +++ b/test-resources/doc/minimal.adoc @@ -0,0 +1,5 @@ +[source,clojure] +---- +(+ 1 2) +;; => 3 +---- diff --git a/test-resources/doc/minimal.md b/test-resources/doc/minimal.md new file mode 100644 index 0000000..9f49898 --- /dev/null +++ b/test-resources/doc/minimal.md @@ -0,0 +1,4 @@ +```clojure +(+ 1 2) +;; => 3 +``` diff --git a/test-resources/expected/test-doc-blocks/test/minimal_adoc_test.cljc b/test-resources/expected/test-doc-blocks/test/minimal_adoc_test.cljc new file mode 100644 index 0000000..e29c1ee --- /dev/null +++ b/test-resources/expected/test-doc-blocks/test/minimal_adoc_test.cljc @@ -0,0 +1,11 @@ +(ns minimal-adoc-test + (:require clojure.test + clojure.string + #?(:cljs [lread.test-doc-blocks.runtime :include-macros]) + #?(:clj lread.test-doc-blocks.runtime))) + +(clojure.test/deftest block-0001 + (clojure.test/testing "test-resources/doc/minimal.adoc - line 2" +(clojure.test/is (= '3 (+ 1 2))))) + +(defn test-ns-hook [] (block-0001)) \ No newline at end of file diff --git a/test-resources/expected/test-doc-blocks/test/minimal_md_test.cljc b/test-resources/expected/test-doc-blocks/test/minimal_md_test.cljc new file mode 100644 index 0000000..d2cece2 --- /dev/null +++ b/test-resources/expected/test-doc-blocks/test/minimal_md_test.cljc @@ -0,0 +1,11 @@ +(ns minimal-md-test + (:require clojure.test + clojure.string + #?(:cljs [lread.test-doc-blocks.runtime :include-macros]) + #?(:clj lread.test-doc-blocks.runtime))) + +(clojure.test/deftest block-0001 + (clojure.test/testing "test-resources/doc/minimal.md - line 1" +(clojure.test/is (= '3 (+ 1 2))))) + +(defn test-ns-hook [] (block-0001)) \ No newline at end of file diff --git a/test/lread/test_doc_blocks_test.clj b/test/lread/test_doc_blocks_test.clj index 3d3be6c..fc9a330 100644 --- a/test/lread/test_doc_blocks_test.clj +++ b/test/lread/test_doc_blocks_test.clj @@ -18,7 +18,9 @@ (deftest verify-generation-against-known-good-run (sut/gen-tests {:docs ["doc/01-user-guide.adoc" - "doc/example.{adoc,md,cljc}"] + "doc/example.{adoc,md,cljc}" + "test-resources/doc/minimal.adoc" + "test-resources/doc/minimal.md"] :target-root "target/actual"}) (let [expected-dir "test-resources/expected/test-doc-blocks/test/"