Skip to content

Commit 9920e90

Browse files
authored
Merge pull request #189 from kit-clj/fix/kaocha-followups
Kaocha follow-ups
2 parents 6c03b91 + f42c40a commit 9920e90

14 files changed

Lines changed: 125 additions & 41 deletions

File tree

‎.gitignore‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ pom.xml.asc
1717
.DS_Store
1818
.nrepl-port
1919
.lsp
20-
.clj-kondo/.cache/
20+
**/.clj-kondo/.cache/
21+
**/.clj-kondo/imports/
22+
**/.clj-kondo/inline-configs/
2123
.aider*
2224
/libs/kit-generator/test/resources/generated/
2325
/libs/kit-generator/test/resources/modules/install-log.edn

‎CHANGELOG.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Change Log
22

3+
## 2026-08-07
4+
5+
### Bug Fixes
6+
7+
- Restore `clj -X:test` in generated projects — the Kaocha switch dropped the `:test` alias `:exec-fn` without replacing it. Also added to `kit-core` and `kit-generator`.
8+
- Stop copying local tooling caches into generated projects. The template copier only skipped hidden *files*, so a `.clj-kondo/.cache` directory sitting in the template resources was copied into the output (and would be baked into a released template jar).
9+
- Generated projects no longer ship a failing placeholder test — `core-test` asserted `(= 1 2)`, so a brand new project failed its test run out of the box.
10+
- Add `.PHONY` to the generated `Makefile`. `make test` collided with the `test/` directory and silently did nothing ("make: `test' is up to date").
11+
12+
### Improvements
13+
14+
- `bb test-libs` runs the test suite of every lib under `libs/` that has one, and `bb ci` now includes it. `kit-generator`'s 39 tests were never running: its `:test` alias had no `:extra-paths ["test"]`.
15+
- Replace the root `:watch-test` alias with `:test-watch`, meant to be combined with `:test` (`clj -M:test:test-watch`) so the deps aren't duplicated, and wire it up as `bb test-watch`. It previously declared both `:main-opts` and `:exec-args {:watch? true ...}`, so `clj -M:watch-test` silently ignored watch and fail-fast.
16+
- Generated projects get the same `:test-watch` alias, plus `bb test-watch` and `make test-watch`.
17+
- Generated `tests.edn` declares the project's actual `test/clj` and `src/clj` paths instead of relying on Kaocha's `test`/`src` defaults.
18+
- Drop `humane-test-output` from the generated `:dev` alias; its only activation site was the test alias `:main-opts` that the Kaocha switch removed.
19+
- Document how to run the tests, including what `bin/kaocha` hardcodes.
20+
321
## 2026-08-05
422

523
### Improvements

‎README.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,29 @@ Additional profiles:
145145
Presently only Clojure deps is supported, however there are
146146
plans to add Leiningen support.
147147

148+
## Running the tests
149+
150+
Tests are run with [Kaocha](https://github.com/lambdaisland/kaocha). Each project
151+
that has tests carries its own `tests.edn`.
152+
153+
```
154+
bb test # the template parity test in this repo's test/ dir
155+
bb test-libs # the test suite of every lib under libs/ that has one
156+
bb test-watch # re-run the root tests on file changes
157+
bb ci # everything CI runs: test-libs, install the templates, test
158+
```
159+
160+
`bin/kaocha` is a convenience binstub that runs the root suite with Kaocha's
161+
bundled profiling plugin always on, so it reports the slowest tests:
162+
163+
```
164+
bin/kaocha # equivalent to clj -M:test --plugin profiling
165+
bin/kaocha --watch # extra args are passed through to Kaocha
166+
```
167+
168+
It is not the standard entry point — use `bb test` or `clj -M:test` for a
169+
normal run. Edit the script if you want different plugins.
170+
148171
## Documentation
149172

150173
[Documentation can be found here](https://kit-clj.github.io)

‎bb.edn‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
(println (str
99
ansi/bold-font "+ clojure " (str/join " " args)
1010
ansi/reset-font))
11-
(apply clojure args)))
11+
(apply clojure args))
12+
(defn clj-in [dir & args]
13+
(println (str
14+
ansi/bold-font "+ (cd " dir ") clojure " (str/join " " args)
15+
ansi/reset-font))
16+
(apply clojure {:dir dir} args)))
1217
publish-local (clj "-T:build install-lib" :artifact-id lib)
1318
publish (clj "-T:build install-lib" :artifact-id lib :publish true)
1419
publish-all-local (clj "-T:build all" :publish false)
@@ -19,10 +24,18 @@
1924
ci {:doc "Run all CI tasks locally"
2025
:requires ([taoensso.timbre :as log])
2126
:task (do
27+
(log/info "bb run test-libs")
28+
(run 'test-libs)
2229
(log/info "bb run publish-local deps-template")
2330
(clj "-T:build install-lib" :artifact-id "deps-template")
2431
(log/info "bb run publish-local lein-template")
2532
(clj "-T:build install-lib" :artifact-id "lein-template")
2633
(log/info "bb run test")
2734
(run 'test))}
28-
test (clj "-M:test")}}
35+
test (clj "-M:test")
36+
test-watch {:doc "Re-runs the tests on file changes"
37+
:task (clj "-M:test:test-watch")}
38+
test-libs {:doc "Runs the test suite of every lib that has one"
39+
:requires ([babashka.fs :as fs])
40+
:task (doseq [tests-edn (sort (fs/glob "libs" "*/tests.edn"))]
41+
(clj-in (str (fs/parent tests-edn)) "-M:test"))}}}

‎bin/kaocha‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
#!/usr/bin/env bash
22

3+
# Runs the root test suite with Kaocha's bundled profiling plugin always on, so
4+
# it reports the slowest tests. The plugin list is hardcoded here on purpose --
5+
# this is a convenience binstub, not the standard entry point. Use `bb test` or
6+
# `clj -M:test` for a normal run, and edit this line to change the plugins.
7+
#
8+
# Extra args are passed through to Kaocha, e.g. `bin/kaocha --watch`.
9+
310
clojure -M:test --plugin profiling "$@"

‎deps.edn‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@
1717
babashka/fs {:mvn/version "0.5.27"}
1818
babashka/process {:mvn/version "0.6.23"}}
1919
:main-opts ["-m" "kaocha.runner"]
20-
:exec-fn kaocha.runner/exec-fn
21-
:exec-args {}}
22-
:watch-test {:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}
23-
babashka/process {:mvn/version "0.6.23"}
24-
babashka/fs {:mvn/version "0.5.27"}}
20+
:exec-fn kaocha.runner/exec-fn}
21+
22+
;; combine with :test, e.g. clj -M:test:test-watch
23+
:test-watch {:main-opts ["-m" "kaocha.runner" "--watch" "--fail-fast"]
2524
:exec-fn kaocha.runner/exec-fn
26-
:exec-args {:watch? true
27-
:skip-meta :slow
28-
:fail-fast? true}
29-
:main-opts ["-m" "kaocha.runner"]}}}
25+
:exec-args {:watch? true :fail-fast? true}}}}

‎libs/deps-template/resources/io/github/kit_clj/kit/Makefile‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.PHONY: clean run repl test test-watch uberjar
2+
13
clean:
24
rm -rf target
35

@@ -10,5 +12,8 @@ repl:
1012
test:
1113
clj -M:test
1214

15+
test-watch:
16+
clj -M:test:test-watch
17+
1318
uberjar:
1419
clj -T:build all

‎libs/deps-template/resources/io/github/kit_clj/kit/bb.edn‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
test {:doc "runs tests"
1818
:task (clojure {:dir "."} "-M:test")}
1919

20+
test-watch {:doc "re-runs tests on file changes"
21+
:task (clojure {:dir "."} "-M:test:test-watch")}
22+
2023
uberjar {:doc "builds the uberjar"
2124
:task (clojure {:dir "."} "-T:build all")}
2225

‎libs/deps-template/resources/io/github/kit_clj/kit/deps.edn‎

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
expound/expound {:mvn/version "0.9.0"}
4646
integrant/repl {:mvn/version "0.5.1"}
4747
mvxcvi/cljstyle {:mvn/version "0.17.642"}
48-
pjstadig/humane-test-output {:mvn/version "0.11.0"}
4948
ring/ring-devel {:mvn/version "1.15.5"}
5049
ring/ring-mock {:mvn/version "0.6.2"}
5150
io.github.kit-clj/kit-generator {:mvn/version "<<versions.kit-generator>>"}
@@ -60,17 +59,23 @@
6059
cider/cider-nrepl {:mvn/version "0.58.0"}}
6160
:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]" "-i"]}
6261

63-
:test {:extra-deps {criterium/criterium {:mvn/version "0.4.6"}
64-
expound/expound {:mvn/version "0.9.0"}
65-
integrant/repl {:mvn/version "0.5.1"}
66-
lambdaisland/kaocha {:mvn/version "1.91.1392"}
67-
ring/ring-devel {:mvn/version "1.15.5"}
68-
ring/ring-mock {:mvn/version "0.6.2"}
69-
io.github.kit-clj/kit-generator {:mvn/version "<<versions.kit-generator>>"}
70-
org.clojure/tools.namespace {:mvn/version "1.5.0"}
71-
peridot/peridot {:mvn/version "0.5.4"}
72-
org.clj-commons/byte-streams {:mvn/version "0.3.4"}
73-
com.lambdaisland/classpath {:mvn/version "0.6.58"}}
62+
:test {:extra-deps {criterium/criterium {:mvn/version "0.4.6"}
63+
expound/expound {:mvn/version "0.9.0"}
64+
integrant/repl {:mvn/version "0.5.1"}
65+
lambdaisland/kaocha {:mvn/version "1.91.1392"}
66+
ring/ring-devel {:mvn/version "1.15.5"}
67+
ring/ring-mock {:mvn/version "0.6.2"}
68+
io.github.kit-clj/kit-generator {:mvn/version "<<versions.kit-generator>>"}
69+
org.clojure/tools.namespace {:mvn/version "1.5.0"}
70+
peridot/peridot {:mvn/version "0.5.4"}
71+
org.clj-commons/byte-streams {:mvn/version "0.3.4"}
72+
com.lambdaisland/classpath {:mvn/version "0.6.58"}}
7473
:extra-paths ["env/dev/clj" "env/dev/resources" "env/test/resources" "test/clj"]
75-
:main-opts ["-m" "kaocha.runner"]}}
74+
:main-opts ["-m" "kaocha.runner"]
75+
:exec-fn kaocha.runner/exec-fn}
76+
77+
;; combine with :test, e.g. clj -M:test:test-watch
78+
:test-watch {:main-opts ["-m" "kaocha.runner" "--watch" "--fail-fast"]
79+
:exec-fn kaocha.runner/exec-fn
80+
:exec-args {:watch? true :fail-fast? true}}}
7681
}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
(ns <<ns-name>>.core-test
22
(:require
3-
[<<ns-name>>.test-utils :as utils]
4-
[clojure.test :refer :all]))
3+
[clojure.test :refer [deftest is]]))
54

65
(deftest example-test
7-
(is (= 1 2)))
8-
6+
(is (= 1 1)))

0 commit comments

Comments
 (0)