added rudementary coveralls support
This commit is contained in:
parent
bb81fec0d6
commit
3836db1902
|
@ -6,12 +6,16 @@ This library is a replacement for rackets `raco test` that has a few benefits. N
|
|||
|
||||
install via `raco pkg install better-test`. To install for development, checkout the repo into a folder named `Better Test` and in the parent directory run `raco pkg install better-test/`.
|
||||
|
||||
If you're doing developement remember: better-test *cannot* run on itself.
|
||||
|
||||
## How to use
|
||||
|
||||
To view the arguments for Better Test run `raco better-test -h`.
|
||||
|
||||
Code coverage can be generated by specifying the `-c <format>` flag.
|
||||
Right now the valid formats are: html. Coveralls support is comming.
|
||||
Right now the valid formats are: html and coveralls.
|
||||
Using coveralls requires the "COVERALLS_REPO_TOKEN" to be set, and needs bash and curl.
|
||||
Travic-ci/Coveralls support coming soon...
|
||||
The directory that the coverage is outputted to can be specified with the `-d` flag.
|
||||
|
||||
If any tests run by `rackunit` fail, Better Test will return with exit code `1`. If all tests pass it will return with exit code `0`.
|
||||
|
@ -19,4 +23,4 @@ If any tests run by `rackunit` fail, Better Test will return with exit code `1`.
|
|||
|
||||
## Internals
|
||||
|
||||
Better Test also comes with a racket API for running tests and generating coverage reports. Documentation comming soon...
|
||||
Better Test also comes with a racket API for running tests and generating coverage reports. Documentation coming soon...
|
||||
|
|
5
curl.sh
Executable file
5
curl.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
file=$1
|
||||
|
||||
curl -v --include --form json_file=@"$file" "https://coveralls.io/api/v1/jobs"
|
17
format.rkt
17
format.rkt
|
@ -3,6 +3,7 @@
|
|||
(require syntax/modread
|
||||
syntax/parse
|
||||
unstable/sequence
|
||||
racket/runtime-path
|
||||
json
|
||||
syntax-color/racket-lexer
|
||||
(only-in xml write-xexpr))
|
||||
|
@ -175,21 +176,29 @@
|
|||
;; Coveralls
|
||||
|
||||
;; Coverage [Hasheq String String] [path-string] -> Void
|
||||
(define-runtime-path post "curl.sh")
|
||||
(define (generate-coveralls-coverage coverage meta [dir "coverage"])
|
||||
(make-directory* dir)
|
||||
(define coverage-path (path->string (build-path (current-directory) dir)))
|
||||
(with-output-to-file (string-append coverage-path "/coverage.json")
|
||||
(λ () (write-json (generate-coveralls-json coverage meta)))
|
||||
#:exists 'replace))
|
||||
(define coverage-file (string-append coverage-path "/coverage.json"))
|
||||
(define json (generate-coveralls-json coverage meta))
|
||||
(define token (or (getenv "COVERALLS_REPO_TOKEN") ""))
|
||||
(with-output-to-file coverage-file
|
||||
(λ () (write-json (hash-set (hash-set json 'repo_token token)
|
||||
'service_name
|
||||
"better-test")))
|
||||
#:exists 'replace)
|
||||
(system* (path->string post) coverage-file))
|
||||
|
||||
;; Coverage [Hasheq String String] -> JSexpr
|
||||
;; Generates a string that represents a valid coveralls json_file object
|
||||
(define (generate-coveralls-json coverage meta)
|
||||
(define src-files
|
||||
(for/list ([file (hash-keys coverage)])
|
||||
(define local-file (path->string (find-relative-path (current-directory) file)))
|
||||
(define src (file->string file))
|
||||
(define c (line-coverage coverage file))
|
||||
(hasheq 'src src 'coverage c)))
|
||||
(hasheq 'source src 'coverage c 'name local-file)))
|
||||
(hash-set meta 'source_files src-files))
|
||||
|
||||
;; CoverallsCoverage = Nat | json-null
|
||||
|
|
Loading…
Reference in New Issue
Block a user