Skip to content

Commit

Permalink
bass/test generates coverage reports
Browse files Browse the repository at this point in the history
  • Loading branch information
vito committed Apr 17, 2023
1 parent 8e011c3 commit 9f54a16
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
19 changes: 11 additions & 8 deletions bass/bass.bass
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,17 @@

; returns a thunk that will run the tests and return cover.html
(defn coverage [src testflags]
(from (with-bass-and-buildkitd src)
(with-go-cache
($ gotestsum --format testname --no-color=false --jsonfile ./tests.log
--
-cover
-coverprofile ./cover.out
-covermode count
& $testflags))
(from
(-> ($ gotestsum --format testname --no-color=false --jsonfile ./tests.log
--
-cover
-coverprofile ./cover.out
-coverpkg ./...
-covermode count
& $testflags)
with-go-cache
(with-env {:SKIP_DAGGER_TESTS "true"})
(with-bass-and-buildkitd src))

; report slow tests
($ gotestsum tool slowest --jsonfile ./tests.log --threshold "500ms")
Expand Down
13 changes: 8 additions & 5 deletions bass/test
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
;
; Emits code coverage to *stdout*.
(defn main testflags
(for [{:src src} *stdin*]
(let [args (if (empty? testflags) ["./..."] testflags)
tests (bass:tests src args)]
(log "running tests")
(run tests))))
(for [{:src src
(:out *dir*) out} *stdin*]
(log "running tests")
(write
(subpath
(bass:coverage src (if (empty? testflags) ["./..."] testflags))
./cover.html)
out/cover.html)))

0 comments on commit 9f54a16

Please sign in to comment.