Skip to content

Commit 2d8dffb

Browse files
committed
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.
1 parent 7dbf341 commit 2d8dffb

File tree

5 files changed

+21
-33
lines changed

5 files changed

+21
-33
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ jobs:
4040
- 4.10.2
4141
- 4.09.1
4242
- 4.08.1
43-
- 4.07.1
44-
- 4.06.1
45-
- 4.05.0
46-
- 4.04.2
4743
include:
4844
- os: macos-latest
4945
ocaml: 4.12.1
@@ -87,6 +83,9 @@ jobs:
8783
- name: Build
8884
run: opam exec -- make build
8985

86+
# The @compatible alias can be removed since due to a constraint in
87+
# cmdliner, we can no longer test against OCaml < 4.08. Remove it if we
88+
# commit to not supporting older versions of OCaml.
9089
- name: Test
9190
if: ${{runner.os != 'Windows'}}
9291
run: |

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TEST := @runtest
1010

1111
.PHONY : test
1212
test : build
13-
dune build -p bisect_ppx $(TEST)
13+
NO_COLOR=yes dune build -p bisect_ppx $(TEST)
1414

1515
.PHONY : promote
1616
promote :

bisect_ppx.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ maintainer: [
1919

2020
depends: [
2121
"base-unix"
22-
"cmdliner" {>= "1.0.0"}
22+
"cmdliner" {>= "1.3.0"}
2323
"dune" {>= "2.7.0"}
2424
"ocaml" {>= "4.03.0"}
2525
"ppxlib" {>= "0.28.0"}

src/report/main.ml

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,15 @@ let esy_source_dir =
2121
| exception Not_found -> []
2222
| directory -> [Filename.concat directory "default"]
2323

24-
(* Many of the values used from Cmdliner.Term are deprecated in favor of values
25-
from Cmdliner.Cmd. However, Cmdliner.Cmd was introduced in Cmdliner 1.1.0,
26-
which requires OCaml 4.08.0. Bisect_ppx still supports OCaml 4.04, so Bisect
27-
cannot use this recent version of Cmdliner. The 4.04 constraint itself is
28-
only due to ppxlib.
29-
30-
So, suppress the deprecation warnings. *)
31-
module Term =
32-
struct
33-
include Cmdliner.Term
34-
35-
let eval_choice = Cmdliner.Term.eval_choice [@ocaml.warning "-3"]
36-
let exit = Cmdliner.Term.exit [@ocaml.warning "-3"]
37-
let info = Cmdliner.Term.info [@ocaml.warning "-3"]
38-
end
39-
4024
module Arg = Cmdliner.Arg
25+
module Cmd = Cmdliner.Cmd
26+
module Term = Cmdliner.Term
4127

4228

4329

4430
(* Common arguments. *)
4531

46-
let term_info = Term.info ~sdocs:"COMMON OPTIONS"
32+
let term_info = Cmd.info ~sdocs:"COMMON OPTIONS"
4733

4834
let coverage_files from_position =
4935
Arg.(value @@ pos_right (from_position - 1) string [] @@
@@ -303,9 +289,8 @@ let merge =
303289
(* Entry point. *)
304290

305291
let () =
306-
Term.(eval_choice
307-
(ret (const (`Help (`Auto, None))),
308-
term_info
292+
Cmd.group
293+
(term_info
309294
"bisect-ppx-report"
310295
~doc:"Generate coverage reports for OCaml and Reason."
311296
~man:[
@@ -316,6 +301,10 @@ let () =
316301
`P
317302
("See bisect-ppx-report $(i,COMMAND) --help for further " ^
318303
"information on each command, including options.")
319-
]))
320-
[html; send_to; text; cobertura; coveralls; merge]
321-
|> Term.exit
304+
]
305+
~exits:((Cmd.Exit.info ~doc:"on error." 1)::Cmd.Exit.defaults)
306+
)
307+
([html; send_to; text; cobertura; coveralls; merge]
308+
|> List.map (fun (term, info) -> Cmd.v info term))
309+
|> Cmd.eval
310+
|> exit

test/report/send-to.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
From Travis to Coveralls.
1717

1818
$ bisect-ppx-report send-to --dry-run No-such-service --verbose 2>&1 | sed s//.../g | sed s/\`/\'/g
19+
Usage: bisect-ppx-report send-to [--help] [OPTION]... SERVICE
20+
[COVERAGE_FILES]...
1921
bisect-ppx-report: SERVICE argument: invalid value 'No-such-service',
2022
expected either 'Codecov' or 'Coveralls'
21-
Usage: bisect-ppx-report send-to [OPTION]... SERVICE [COVERAGE_FILES]...
22-
Try 'bisect-ppx-report send-to --help' or 'bisect-ppx-report --help' for more information.
2323

2424
$ bisect-ppx-report send-to --dry-run coveralls --verbose 2>&1 | sed s//.../g | sed s/\`/\'/g
25+
Usage: bisect-ppx-report send-to [--help] [OPTION]... SERVICE
26+
[COVERAGE_FILES]...
2527
bisect-ppx-report: SERVICE argument: invalid value 'coveralls', expected
2628
either 'Codecov' or 'Coveralls'
27-
Usage: bisect-ppx-report send-to [OPTION]... SERVICE [COVERAGE_FILES]...
28-
Try 'bisect-ppx-report send-to --help' or 'bisect-ppx-report --help' for more information.
2929

3030
$ bisect-ppx-report send-to --dry-run Coveralls --verbose
3131
Info: will write coverage report to 'coverage.json'

0 commit comments

Comments
 (0)