12345678910111213141516171819202122232425262728293031323334 |
- ;; ===========
- ;; DESCRIPTION
- ;; ===========
- ;; This is a minimalistic example of running tests with coverage in Guile taken
- ;; from: https://github.com/a-guile-mind/coverage, slightly adapted.
- (use-modules (system vm coverage)
- (system vm vm))
- (define (run-test-with-coverage test)
- (call-with-values
- ;; This is the thunk for call-with-values, so that it does not immediately
- ;; get executed, but instead is executed in call-with-values. Delayed
- ;; execution.
- (lambda ()
- (with-code-coverage
- ;; with-code-coverage also needs a thunk. Also delayed execution.
- (lambda ()
- ;; Load (run) the given test.
- (load test))))
- ;; Here is a procedure for processing the results of the coverage run.
- (lambda (data result)
- (let ([port (open-output-file (string-append #|test|# "test.info"))])
- ;; Write the information to a file for later review.
- (coverage-data->lcov data port #|#:modules '(bit-integer-operations)|#)
- ;; Close the port to that file.
- (close port)))))
- (run-test-with-coverage (cadr (program-arguments)))
|