32 lines
1.4 KiB
Clojure
32 lines
1.4 KiB
Clojure
(ns vibe.integration.coverage
|
|
"Entry point that runs the vibe server under Cloverage instrumentation so the
|
|
black-box integration tests produce a line-coverage report.
|
|
|
|
Cloverage normally instruments the source and then runs a test suite in-process.
|
|
Here the 'suite' is the outside world: the runner starts the real server and blocks
|
|
until the JVM gets SIGTERM (`docker compose stop`), then Cloverage writes its reports.
|
|
|
|
Deliberately does not require any vibe.* source namespace at load time: those must
|
|
be loaded by Cloverage (instrumented), not by us."
|
|
(:require [cloverage.coverage :as cov]))
|
|
|
|
(defmethod cov/runner-fn :integration [_]
|
|
(fn [_nses]
|
|
(let [stop (promise)
|
|
main (Thread/currentThread)]
|
|
((requiring-resolve 'vibe.core/start-server))
|
|
;; The report is written by the main thread after the runner returns, but the JVM
|
|
;; only stays up while shutdown hooks run, so the hook must wait for the main thread.
|
|
(.addShutdownHook (Runtime/getRuntime)
|
|
(Thread. (fn []
|
|
(deliver stop true)
|
|
(.join main))))
|
|
@stop
|
|
{:errors 0})))
|
|
|
|
(defn -main [& args]
|
|
;; Cloverage's own System/exit would deadlock inside the shutdown hook above.
|
|
(binding [cov/*exit-after-test* false]
|
|
(apply cov/-main args))
|
|
(shutdown-agents))
|