From: Anton Bachin Date: Sun, 12 Oct 2025 18:12:24 +0300 Subject: Adapt to Cmdliner 2.0.0 Bisect_ppx now effectively requires OCaml 4.08, because Cmdliner 2.0.0 requires it. However, the code of Bisect_ppx proper can still easily be made to compile against OCaml 4.03. Resolves #444. Bug-Debian: https://bugs.debian.org/1131638 Origin: https://github.com/aantron/bisect_ppx/commit/2d8dffbbfc0c431a37319d4d9a143836c9ec542e --- .github/workflows/test.yml | 7 +++---- Makefile | 2 +- bisect_ppx.opam | 2 +- src/report/main.ml | 35 ++++++++++++----------------------- test/report/send-to.t | 8 ++++---- 5 files changed, 21 insertions(+), 33 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3ea4474..47af4a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,10 +40,6 @@ jobs: - 4.10.2 - 4.09.1 - 4.08.1 - - 4.07.1 - - 4.06.1 - - 4.05.0 - - 4.04.2 include: - os: macos-latest ocaml: 4.12.1 @@ -87,6 +83,9 @@ jobs: - name: Build run: opam exec -- make build + # The @compatible alias can be removed since due to a constraint in + # cmdliner, we can no longer test against OCaml < 4.08. Remove it if we + # commit to not supporting older versions of OCaml. - name: Test if: ${{runner.os != 'Windows'}} run: | diff --git a/Makefile b/Makefile index f1ddc88..1ce4f9e 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ TEST := @runtest .PHONY : test test : build - dune build -p bisect_ppx $(TEST) + NO_COLOR=yes dune build -p bisect_ppx $(TEST) .PHONY : promote promote : diff --git a/bisect_ppx.opam b/bisect_ppx.opam index 77a2006..d7e5700 100644 --- a/bisect_ppx.opam +++ b/bisect_ppx.opam @@ -19,7 +19,7 @@ maintainer: [ depends: [ "base-unix" - "cmdliner" {>= "1.0.0"} + "cmdliner" {>= "1.3.0"} "dune" {>= "2.7.0"} "ocaml" {>= "4.03.0"} "ppxlib" {>= "0.28.0"} diff --git a/src/report/main.ml b/src/report/main.ml index 4beec68..add6eb6 100644 --- a/src/report/main.ml +++ b/src/report/main.ml @@ -21,29 +21,15 @@ let esy_source_dir = | exception Not_found -> [] | directory -> [Filename.concat directory "default"] -(* Many of the values used from Cmdliner.Term are deprecated in favor of values - from Cmdliner.Cmd. However, Cmdliner.Cmd was introduced in Cmdliner 1.1.0, - which requires OCaml 4.08.0. Bisect_ppx still supports OCaml 4.04, so Bisect - cannot use this recent version of Cmdliner. The 4.04 constraint itself is - only due to ppxlib. - - So, suppress the deprecation warnings. *) -module Term = -struct - include Cmdliner.Term - - let eval_choice = Cmdliner.Term.eval_choice [@ocaml.warning "-3"] - let exit = Cmdliner.Term.exit [@ocaml.warning "-3"] - let info = Cmdliner.Term.info [@ocaml.warning "-3"] -end - module Arg = Cmdliner.Arg +module Cmd = Cmdliner.Cmd +module Term = Cmdliner.Term (* Common arguments. *) -let term_info = Term.info ~sdocs:"COMMON OPTIONS" +let term_info = Cmd.info ~sdocs:"COMMON OPTIONS" let coverage_files from_position = Arg.(value @@ pos_right (from_position - 1) string [] @@ @@ -295,9 +281,8 @@ let merge = (* Entry point. *) let () = - Term.(eval_choice - (ret (const (`Help (`Auto, None))), - term_info + Cmd.group + (term_info "bisect-ppx-report" ~doc:"Generate coverage reports for OCaml and Reason." ~man:[ @@ -308,6 +293,10 @@ let () = `P ("See bisect-ppx-report $(i,COMMAND) --help for further " ^ "information on each command, including options.") - ])) - [html; send_to; text; cobertura; coveralls; merge] - |> Term.exit + ] + ~exits:((Cmd.Exit.info ~doc:"on error." 1)::Cmd.Exit.defaults) + ) + ([html; send_to; text; cobertura; coveralls; merge] + |> List.map (fun (term, info) -> Cmd.v info term)) + |> Cmd.eval + |> exit diff --git a/test/report/send-to.t b/test/report/send-to.t index 7506a31..f0aee70 100644 --- a/test/report/send-to.t +++ b/test/report/send-to.t @@ -16,16 +16,16 @@ From Travis to Coveralls. $ bisect-ppx-report send-to --dry-run No-such-service --verbose 2>&1 | sed s/…/.../g | sed s/\`/\'/g + Usage: bisect-ppx-report send-to [--help] [OPTION]... SERVICE + [COVERAGE_FILES]... bisect-ppx-report: SERVICE argument: invalid value 'No-such-service', expected either 'Codecov' or 'Coveralls' - Usage: bisect-ppx-report send-to [OPTION]... SERVICE [COVERAGE_FILES]... - Try 'bisect-ppx-report send-to --help' or 'bisect-ppx-report --help' for more information. $ bisect-ppx-report send-to --dry-run coveralls --verbose 2>&1 | sed s/…/.../g | sed s/\`/\'/g + Usage: bisect-ppx-report send-to [--help] [OPTION]... SERVICE + [COVERAGE_FILES]... bisect-ppx-report: SERVICE argument: invalid value 'coveralls', expected either 'Codecov' or 'Coveralls' - Usage: bisect-ppx-report send-to [OPTION]... SERVICE [COVERAGE_FILES]... - Try 'bisect-ppx-report send-to --help' or 'bisect-ppx-report --help' for more information. $ bisect-ppx-report send-to --dry-run Coveralls --verbose Info: will write coverage report to 'coverage.json'