Skip to content

Commit d4419bf

Browse files
committed
Fix tool-name and test --main-module ignored warning
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
1 parent e076743 commit d4419bf

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

bin/api_diff.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
let tool_name = "api-diff"
2+
13
let run (`Main_module main_module) (`Ref_cmi reference) (`Current_cmi current) =
24
let open CCResult.Infix in
35
let* reference_sig, current_sig, module_name =
@@ -15,8 +17,8 @@ let run (`Main_module main_module) (`Ref_cmi reference) (`Current_cmi current) =
1517
| None -> ()
1618
| Some _ ->
1719
Printf.eprintf
18-
"%s: --main-module ignored when diffing single .cmi files"
19-
Sys.executable_name
20+
"%s: --main-module ignored when diffing single .cmi files\n"
21+
tool_name
2022
in
2123
let+ reference_cmi, _ = Api_watch.Library.load_cmi reference
2224
and+ current_cmi, module_name = Api_watch.Library.load_cmi current in
@@ -73,7 +75,7 @@ let current_cmi =
7375

7476
let info =
7577
let open Cmdliner in
76-
Cmd.info "api-watcher" ~version:"%%VERSION%%" ~exits:Cmd.Exit.defaults
78+
Cmd.info tool_name ~version:"%%VERSION%%" ~exits:Cmd.Exit.defaults
7779
~doc:"List API changes between two versions of a library"
7880

7981
let term = Cmdliner.Term.(const run $ main_module $ ref_cmi $ current_cmi)

tests/api-diff/errors.t

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@ diff a .cmi file with another .cmi file or a directory with a directory
44
$ mkdir test
55
$ touch test.cmi
66
$ api-diff test test.cmi
7-
api-watcher: Arguments must either both be directories or both single .cmi files.
7+
api-diff: Arguments must either both be directories or both single .cmi files.
88
[123]
99

1010
When diffing all libraries, the --main-module argument is mandatory
1111

1212
$ mkdir test2
1313
$ api-diff test test2
14-
api-watcher: --main-module must be provided when diffing entire libraries.
14+
api-diff: --main-module must be provided when diffing entire libraries.
15+
[123]
16+
17+
When passing --main-module while diffing single .cmi files, the user will be warn
18+
that it is ignored
19+
20+
$ touch test2.cmi
21+
$ api-diff --main-module main test.cmi test2.cmi
22+
api-diff: --main-module ignored when diffing single .cmi files
23+
api-diff: Cmi_format.Error(_)
1524
[123]

0 commit comments

Comments
 (0)