From 19d1457a252e023cc9c598837e256a9336547085 Mon Sep 17 00:00:00 2001 From: Risto Stevcev Date: Sun, 22 Mar 2020 23:36:59 +0100 Subject: [PATCH] Added code coverage --- .gitignore | 2 ++ Makefile | 28 ++++++++++++++++++++++++++-- bastet.opam | 3 ++- bastet/src/dune | 3 ++- bastet_js/test/Test_JsArray.re | 2 ++ bsconfig.json | 12 +++++++++--- dune | 2 ++ dune-project | 3 ++- package.json | 3 ++- yarn.lock | 5 +++++ 10 files changed, 54 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 4716803d7..bd8e215d1 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ node_modules _build/ _opam/ bastet/src/index.mld +docs/bisect_ppx +coverage.json diff --git a/Makefile b/Makefile index 075dfedbc..a162e2704 100644 --- a/Makefile +++ b/Makefile @@ -12,8 +12,13 @@ clean-native: clean-docs: rm -rf docs/** +.PHONY: clean-coverage +clean-coverage: + rm -rf _coverage *.coverage + rm -f coverage.json + .PHONY: clean -clean: clean-bs clean-native clean-docs +clean: clean-bs clean-native clean-docs clean-coverage .PHONY: build-bs build-bs: @@ -60,6 +65,25 @@ test-native: build-native .PHONY: test test: test-bs test-native +.PHONY: bisect +bisect: + BISECT_ENABLE=yes make test + +.PHONY: bisect-html +bisect-html: bisect + bisect-ppx-report html + +.PHONY: coveralls-json +coveralls-json: bisect + bisect-ppx-report coveralls --repo-token ${COVERALLS_TOKEN} coverage.json + +.PHONY: coveralls-send +coveralls-send: + curl -L -F json_file=@./coverage.json https://coveralls.io/api/v1/jobs + +.PHONY: coveralls +coveralls: coveralls-json coveralls-send + .PHONY: watch-native watch-native: dune build @all -w @@ -71,7 +95,7 @@ watch-bs: .PHONY: watch-test-bs watch-test-bs: yarn run watch-test - + .PHONY: watch-test-native watch-test: dune runtest --no-buffer -w diff --git a/bastet.opam b/bastet.opam index 3daf7f07b..12aa9511c 100644 --- a/bastet.opam +++ b/bastet.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -synopsis: "A ReasonML/Ocaml library for category theory and abstract algebra" +synopsis: "A ReasonML/OCaml library for category theory and abstract algebra" maintainer: ["me@risto.codes"] authors: ["Risto Stevcev"] license: "BSD-3-Clause" @@ -14,6 +14,7 @@ depends: [ "qcheck-alcotest" {>= "0.13" & with-test} "ocamlformat" {>= "0.13.0" & with-test} "mdx" {>= "1.6.0" & with-test} + "bisect_ppx" {>= "2.1.0" & with-test} "odoc" {>= "1.5.0" & with-doc} "mustache" {>= "3.1.0" & with-doc} "dune" {>= "2.2.0"} diff --git a/bastet/src/dune b/bastet/src/dune index ec0f6e311..dc92903c2 100644 --- a/bastet/src/dune +++ b/bastet/src/dune @@ -1,6 +1,7 @@ (library (name bastet) - (public_name bastet)) + (public_name bastet) + (preprocess (pps bisect_ppx --conditional))) (documentation (package bastet)) diff --git a/bastet_js/test/Test_JsArray.re b/bastet_js/test/Test_JsArray.re index 4430d8aad..697bda829 100644 --- a/bastet_js/test/Test_JsArray.re +++ b/bastet_js/test/Test_JsArray.re @@ -1,6 +1,8 @@ open BsMocha.Mocha; open BsJsverify.Verify.Arbitrary; +Bisect.Runtime.write_coverage_data_on_exit(); + module ArbitraryArray: Test.ARBITRARY_A with type t('a) = array('a) and type arbitrary('a) = arbitrary('a) = { diff --git a/bsconfig.json b/bsconfig.json index 645e76baa..183c1c1a7 100644 --- a/bsconfig.json +++ b/bsconfig.json @@ -24,9 +24,15 @@ "in-source": false }, "suffix": ".bs.js", + "bs-dependencies": [ + "bisect_ppx" + ], "bs-dev-dependencies": [ - "bs-jsverify", - "bs-mocha", - "bs-chai" + "bs-jsverify", + "bs-mocha", + "bs-chai" + ], + "ppx-flags": [ + "bisect_ppx/ppx" ] } diff --git a/dune b/dune index c0ba8581f..ad6b21f18 100644 --- a/dune +++ b/dune @@ -8,3 +8,5 @@ (progn (run ocaml-mdx test %{x}) (diff? %{x} %{x}.corrected)))) + +(data_only_dirs node_modules) diff --git a/dune-project b/dune-project index 60154a39d..bb808de84 100644 --- a/dune-project +++ b/dune-project @@ -9,7 +9,7 @@ (package (name bastet) - (synopsis "A ReasonML/Ocaml library for category theory and abstract algebra") + (synopsis "A ReasonML/OCaml library for category theory and abstract algebra") (depends (ocaml (>= 4.06.1)) (reason (>= 3.6.0)) @@ -18,6 +18,7 @@ (qcheck-alcotest (and (>= 0.13) :with-test)) (ocamlformat (and (>= 0.13.0) :with-test)) (mdx (and (>= 1.6.0) :with-test)) + (bisect_ppx (and (>= 2.1.0) :with-test)) (odoc (and (>= 1.5.0) :with-doc)) (mustache (and (>= 3.1.0) :with-doc)) (dune (>= 2.2.0)))) diff --git a/package.json b/package.json index 22fd60092..cf0e0c411 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bs-bastet", "version": "1.1.0", - "description": "A ReasonML/Ocaml library for category theory and abstract algebra", + "description": "A ReasonML/OCaml library for category theory and abstract algebra", "repository": { "type": "git", "url": "git://github.com/Risto-Stevcev/bastet.git" @@ -24,6 +24,7 @@ "license": "BSD-3-Clause", "dependencies": {}, "devDependencies": { + "bisect_ppx": "^2.1.0", "bs-chai": "^1.0.1", "bs-jsverify": "0.10.0", "bs-mocha": "^1.0.0", diff --git a/yarn.lock b/yarn.lock index 44bc61fe0..b8697e67b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -41,6 +41,11 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= +bisect_ppx@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/bisect_ppx/-/bisect_ppx-2.1.0.tgz#b1f9b0c125a104c41dc6aaddb8b0e112af618ae4" + integrity sha512-wFw+BwOExrX2MbtlNlHY5gNDw8Wsd+aL5ykRdN904aGLrVfuV6YUf1S0+X/4khA8GhibgqC7pLazW4/IvxgPIw== + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"