Skip to content

Commit

Permalink
✨ [test] Coverage
Browse files Browse the repository at this point in the history
Problem:
- The contextual library doesn't measure test coverage in any way,
making it difficult to asses the effetiveness of the tests.

Solution:
- Add test coverage.
  • Loading branch information
sabjohnso committed Oct 31, 2024
1 parent 0918462 commit f90d7a2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
*~
\#*

# Test coverage output
coverage/

# various fasl extensions
*.FASL
*.fasl
Expand Down
34 changes: 34 additions & 0 deletions run-coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
#|

set -euo pipefail
scriptdir=$(cd $(dirname $0) && pwd)
scriptpath=$scriptdir/$(basename $0)
sbcl --script $scriptpath
exit $?
|#

(require :sb-cover)
(require :asdf)

(declaim (optimize sb-cover:store-coverage-data))


(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))

(ql:quickload "trivia")
(ql:quickload "fiveam")

(declaim (optimize (sb-cover:store-coverage-data 0)))

(asdf:oos 'asdf:load-op :contextual :force t)
(asdf:oos 'asdf:load-op :contextual/test :force t)
(if (5am:run-all-tests)
(progn
(declaim (optimize sb-cover:store-coverage-data))
(asdf:oos 'asdf:load-op :contextual :force t)
(5am:run-all-tests)
(sb-cover:report "coverage/"))
(sb-ext:exit :code 1))
14 changes: 11 additions & 3 deletions run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@ set -euo pipefail
scriptdir=$(cd $(dirname $0) && pwd)
scriptpath=$scriptdir/$(basename $0)
sbcl --script $scriptpath

exit $?
|#

(require :sb-cover)
(require :asdf)


(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))

(ql:quickload "trivia")
(ql:quickload "fiveam")
(require :asdf)

(asdf:load-system :contextual)
(asdf:test-system :contextual)
(asdf:load-system :contextual/test)

(defun run ()
(if (5am:run-all-tests) 0 1))

(sb-ext:exit :code (run))

0 comments on commit f90d7a2

Please sign in to comment.