From ae389b9480d46091bfd9b6843aebdc48aa577c16 Mon Sep 17 00:00:00 2001 From: Andrey Listopadov Date: Mon, 28 Aug 2023 22:13:21 +0300 Subject: Update fennel-test, and add test runner script --- .fennel-test | 4 ++++ README.md | 10 +++++++--- build.fnl | 17 ----------------- cljlib.fnl | 4 ++-- fennel-test | 2 +- run-tests.fnl | 8 ++++++++ tests/.dir-locals.el | 1 - tests/core.fnl | 2 +- tests/fn.fnl | 8 ++++---- tests/macros.fnl | 2 +- utils/build | 17 +++++++++++++++++ utils/run-tests | 8 ++++++++ 12 files changed, 53 insertions(+), 30 deletions(-) create mode 100644 .fennel-test delete mode 100644 build.fnl create mode 100644 run-tests.fnl delete mode 120000 tests/.dir-locals.el create mode 100644 utils/build create mode 100644 utils/run-tests diff --git a/.fennel-test b/.fennel-test new file mode 100644 index 0000000..d4ab1c7 --- /dev/null +++ b/.fennel-test @@ -0,0 +1,4 @@ +;; -*- mode: fennel -*- + +{:reporter :dots + :searcher-opts {:useMetadata true}} diff --git a/README.md b/README.md index 1a879be..4888419 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,15 @@ Documentation is auto-generated with [Fenneldoc](https://gitlab.com/andreyorst/f Please make sure you've read [contribution guidelines][2]. -In order to work on the library, edit the `src/cljlib.fnl` file, then run the `build.fnl` script to produce a self-contained version of the library. +In order to work on the library, edit the `src/cljlib.fnl` file, then run the following command in the project root: -Tests can be ran with + fennel utils/build - for test in tests/*.fnl; do fennel --metadata $test; done +This produces a self-contained version of the library with all dependencies properly included. + +Tests can be ran with: + + fennel utils/run-tests [1]: https://gitlab.com/andreyorst/fennel-cljlib/-/raw/master/cljlib.fnl [2]: https://gitlab.com/andreyorst/fennel-cljlib/-/tree/master/CONTRIBUTING.md diff --git a/build.fnl b/build.fnl deleted file mode 100644 index 4c3c3db..0000000 --- a/build.fnl +++ /dev/null @@ -1,17 +0,0 @@ -(fn spit-lib [path to] - (with-open [lib (io.open path)] - (each [line (lib:lines)] - ;; patching compile-time variable used to store macro module - ;; namr because when loafing the combined file it will always - ;; equal the the main module and will break macros in vendored - ;; libraries. - (case (line:match "%(local lib%-name %(or %.%.%. (.*)") - name (to:write (.. "(local lib-name (or " name "\n")) - _ (to:write line "\n"))))) - -(with-open [cljlib (io.open "./cljlib.fnl" :w)] - (let [main (io.open "src/cljlib.fnl")] - (each [line (main:lines)] - (case (line:match ";;;###include (.*)") - (path) (spit-lib path cljlib) - _ (cljlib:write line "\n"))))) diff --git a/cljlib.fnl b/cljlib.fnl index de753ad..29be35e 100644 --- a/cljlib.fnl +++ b/cljlib.fnl @@ -675,6 +675,7 @@ accepts sorting function `f`. " (eval-compiler (local lib-name (or :lazy-seq)) + (fn lazy-seq [...] "Create lazy sequence from the result provided by running the `body'. Delays the execution until the resulting sequence is consumed. @@ -1875,8 +1876,7 @@ called. Early termination is supported via `reduced`. ;;; cljlib (eval-compiler - (local lib-name - (or ... :cljlib)) + (local lib-name (or ... :cljlib)) (fn string? [x] (= :string (type x))) diff --git a/fennel-test b/fennel-test index 6c27e21..b78eb4c 160000 --- a/fennel-test +++ b/fennel-test @@ -1 +1 @@ -Subproject commit 6c27e215aa4f9458463fb1002d9de5177320f576 +Subproject commit b78eb4c7c8a0abfe26b19ea8468f7904693cfa1c diff --git a/run-tests.fnl b/run-tests.fnl new file mode 100644 index 0000000..e70fae1 --- /dev/null +++ b/run-tests.fnl @@ -0,0 +1,8 @@ +(local t (require :fennel-test.fennel-test)) + +(local test-modules + [:tests.core + :tests.fn + :tests.macros]) + +(t.run-tests test-modules) diff --git a/tests/.dir-locals.el b/tests/.dir-locals.el deleted file mode 120000 index 0b353b0..0000000 --- a/tests/.dir-locals.el +++ /dev/null @@ -1 +0,0 @@ -../fennel-test/.dir-locals.el \ No newline at end of file diff --git a/tests/core.fnl b/tests/core.fnl index bd3a4aa..a317436 100644 --- a/tests/core.fnl +++ b/tests/core.fnl @@ -1,4 +1,4 @@ -(require-macros :fennel-test) +(require-macros (doto :fennel-test.fennel-test require)) (import-macros clj (doto :cljlib require)) (local core (require :cljlib)) diff --git a/tests/fn.fnl b/tests/fn.fnl index eeee017..886c763 100644 --- a/tests/fn.fnl +++ b/tests/fn.fnl @@ -1,13 +1,13 @@ -(require-macros :fennel-test) +(require-macros (doto :fennel-test.fennel-test require)) (require-macros (doto :cljlib require)) (local (meta? fennel) (pcall require :fennel)) (fn meta [x] (fennel.metadata:get x)) -(deftest test-fn* +(deftest test-defn (when meta? - (testing "fn* meta" + (testing "defn meta" (defn f "single arity" [x] x) @@ -66,7 +66,7 @@ "([[{:a [a b c]}] d e])"]} (meta f))) - (testing "defn anonymous calls" + (testing "fn* anonymous calls" (assert-eq ((fn* [])) (values)) (assert-eq ((fn* [] nil)) nil) (assert-eq ((fn* [x] x) 5) 5) diff --git a/tests/macros.fnl b/tests/macros.fnl index 3b3eeba..cf3d455 100644 --- a/tests/macros.fnl +++ b/tests/macros.fnl @@ -1,4 +1,4 @@ -(require-macros :fennel-test) +(require-macros (doto :fennel-test.fennel-test require)) (require-macros (doto :cljlib require)) (local (meta? fennel) (pcall require :fennel)) diff --git a/utils/build b/utils/build new file mode 100644 index 0000000..4c3c3db --- /dev/null +++ b/utils/build @@ -0,0 +1,17 @@ +(fn spit-lib [path to] + (with-open [lib (io.open path)] + (each [line (lib:lines)] + ;; patching compile-time variable used to store macro module + ;; namr because when loafing the combined file it will always + ;; equal the the main module and will break macros in vendored + ;; libraries. + (case (line:match "%(local lib%-name %(or %.%.%. (.*)") + name (to:write (.. "(local lib-name (or " name "\n")) + _ (to:write line "\n"))))) + +(with-open [cljlib (io.open "./cljlib.fnl" :w)] + (let [main (io.open "src/cljlib.fnl")] + (each [line (main:lines)] + (case (line:match ";;;###include (.*)") + (path) (spit-lib path cljlib) + _ (cljlib:write line "\n"))))) diff --git a/utils/run-tests b/utils/run-tests new file mode 100644 index 0000000..e70fae1 --- /dev/null +++ b/utils/run-tests @@ -0,0 +1,8 @@ +(local t (require :fennel-test.fennel-test)) + +(local test-modules + [:tests.core + :tests.fn + :tests.macros]) + +(t.run-tests test-modules) -- cgit v1.2.3