Skip to content

Instantly share code, notes, and snippets.

@tgk
Created Sep 12, 2016
Embed
What would you like to do?
A very small script for running spec tests. I have a lein alias for running the main function and that works quite well.
(ns spec-test
(:require [clojure.pprint]
[clojure.spec.test]
[clojure.tools.namespace.repl :refer (refresh)]))
(defn run-analysis
[]
(clojure.spec.test/instrument)
(let [results (clojure.spec.test/check)
failures (remove (comp true? :result :clojure.spec.test.check/ret) results)]
(clojure.pprint/print-table
[:success? :symbol :seed]
(for [result results]
{:success? (true? (get-in result [:clojure.spec.test.check/ret :result]))
:symbol (get result :sym)
:seed (get-in result [:clojure.spec.test.check/ret :seed])}))
(System/exit (if (seq failures) 1 0))))
(defn -main
[& args]
(refresh :after 'spec-test/run-analysis))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment