package bisect_ppx
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=fb1fb30ccc1d941bb0cf2062dc9a8758e1eabbb668147e2adac4bcd4a563778f
md5=1d7990510bb53dd7ee13a5629ce2aa66
Description
Bisect_ppx helps you test thoroughly. It is a small preprocessor that inserts instrumentation at places in your code, such as if-then-else and match expressions. After you run tests, Bisect_ppx gives a nice HTML report showing which places were visited and which were missed.
Usage is simple - add package bisect_ppx when building tests, run your tests, then run the Bisect_ppx report tool on the generated visitation files.
Published: 30 Nov 2018
README
Bisect_ppx
Bisect_ppx is a code coverage tool for OCaml. It helps you test thoroughly by showing which parts of your code are not tested.
For a live demonstration, see the coverage report Bisect_ppx generates for itself.
Instructions
Most of these commands go in a Makefile
or other script, so that you only have to run that script, then refresh your browser.
Install Bisect_ppx.
opam install bisect_ppx
You can also install without OPAM.
When compiling for testing, include Bisect_ppx. Instructions are also available for Dune, Ocamlbuild, and OASIS.
ocamlfind c -package bisect_ppx -c my_code.ml ocamlfind c -c my_tests.ml ocamlfind c -linkpkg -package bisect_ppx my_code.cmo my_tests.cmo
Run your test binary. In addition to testing your code, it will produce one or more files with names like
bisect0001.out
../a.out # Produces bisect0001.out
Generate the coverage report.
bisect-ppx-report -I _build/ -html coverage/ bisect*.out`
Open
coverage/index.html
!In each file of the report,
Green lines contain expressions, all of which were visited.
Red lines contain expressions, none of which were visited.
Yellow lines contain expressions, some of which were visited, but others not.
White lines are those that don't contain visitable expressions. They may have type declarations, keywords, or something else that Bisect_ppx did not, or cannot instrument.
See also the advanced usage.
Coveralls.io
(New) You can generate a Coveralls json report using the bisect-ppx-report
tool with the -coveralls
flag. Note that Bisect_ppx reports are more precise than Coveralls, which only considers whole lines as visited or not. The built in Coveralls reporter will consider a full line unvisited if any point on that line is not visited, check the html report to verify precisly which points are not covered.
Example using the built in Coveralls reporter on Travis CI (which sets $TRAVIS_JOB_ID
):
bisect-ppx-report \
-I _build/ \
-coveralls coverage.json \
-service-name travis-ci \
-service-job-id $TRAVIS_JOB_ID \
bisect*.out
curl -L -F json_file=@./coverage.json https://coveralls.io/api/v1/jobs
Bisect_ppx in practice
A small sample of projects using Bisect_ppx:
License
Bisect_ppx is available under the Mozilla Public License 2.0 (MPL). To summarize, you can incorporate Bisect_ppx into proprietary projects. If you make modifications to Bisect_ppx, you have to open-source them. The rest of your project remains proprietary.
Essentially, this is like the BSD or MIT licenses, except that if you include a customized Bisect_ppx in a release (as opposed to private use), you have to make the altered source visible. This can be done by contributing the changes back, keeping Bisect_ppx in a visible fork, or if your bigger project itself also happens to be open source.
Besides proprietary licenses, MPL is compatible with BSD/MIT/Apache- and (L)GPL-licensed projects. See the MPL 2.0 FAQ.
The Ocamlbuild plugin is dedicated to the public domain.
Contributing
Bug reports and pull requests are warmly welcome. Bisect_ppx is developed on GitHub, so please open an issue.
To get the latest development version of Bisect_ppx using OPAM, run
opam source --dev-repo --pin bisect_ppx
You will now have a bisect_ppx
subdirectory to work in.
Dependencies (5)
- ppx_tools_versioned
-
ocaml-migrate-parsetree
>= "1.0.3" & < "2.0.0"
-
ocaml
>= "4.02.0"
- dune
- base-unix
Used by (48)
- ambient-context
- ambient-context-eio
- ambient-context-lwt
- amf
-
arp
>= "1.0.0" & < "2.3.1"
-
azure-cosmos-db
>= "0.2.3"
-
base58
>= "0.1.2"
-
bio_io
< "0.5.1"
- bisect-summary
-
bisect_ppx-ocamlbuild
>= "1.0.1"
- checked_oint
- cll
-
cuid
>= "0.2"
- easy_xlsx
- exit
-
GT
>= "0.5.2"
-
gobba
< "0.4.2"
- jose
- little_logger
-
lwt
>= "4.2.0" & < "5.3.0"
-
markup
= "0.8.1"
- mazeppa
-
minicaml
= "0.3.3"
-
mirage-block-ccm
>= "1.1.0"
- mirage-btrees
- mnd
-
mssql
< "2.0.3"
- obeam
-
ocaml-protoc-plugin
>= "5.0.0"
-
ocamlformat
= "0.11.0"
-
ocveralls
>= "0.3.2"
-
odoc
>= "1.4.0" & < "2.0.0"
- omg
- open_packaging
- partition_map
-
pgx
< "1.0"
-
ppx_make
>= "0.3.4"
-
ppx_subliner
>= "0.2.0"
-
pyml_bindgen
< "0.3.0"
- reed-solomon-erasure
-
rfc6287
>= "1.0.2"
-
shared-block-ring
>= "2.3.0" & < "3.0.0"
- so
- spreadsheetml
- tezos-bls12-381-polynomial
-
tezos-plompiler
= "0.1.3"
-
tezos-plonk
= "0.1.3"
-
validate
>= "1.0.0"
Conflicts (1)
-
ocveralls
<= "0.3.2"