Skip to content

Commit fbc93fe

Browse files
committed
fix: refactor
Signed-off-by: Sachin Beniwal <s474996633@gmail.com>
1 parent 4539720 commit fbc93fe

File tree

7 files changed

+92
-53
lines changed

7 files changed

+92
-53
lines changed

bin/tools/tools_common.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ let exec_command dev_tool =
137137
let info =
138138
let doc =
139139
sprintf
140-
{|Wrapper for running %s. All positional arguments will be passed to the
140+
{|Wrapper for running %s intended to be run automatically
141+
by a text editor. All positional arguments will be passed to the
141142
%s executable (pass flags to %s after the '--'
142143
argument, such as 'dune tools exec %s -- --help').|}
143144
exe_name

doc/changes/added/12972.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/dune_pkg/dev_tool.ml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,10 @@ let exe_name = function
104104
| Opam_publish -> "opam-publish"
105105
| Dune_release -> "dune-release"
106106
| Ocaml_index -> "ocaml-index"
107-
| Merlin -> "merlin"
107+
| Merlin -> "ocamlmerlin"
108108
;;
109109

110-
let exe_path_components_within_package = function
111-
| Merlin -> [ "bin"; "ocamlmerlin" ]
112-
| t -> [ "bin"; exe_name t ]
113-
;;
110+
let exe_path_components_within_package t = [ "bin"; exe_name t ]
114111

115112
let needs_to_build_with_same_compiler_as_project = function
116113
| Ocamlformat -> false

test/blackbox-tests/test-cases/pkg/dev-tools-help-message.t

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,49 +18,53 @@ Output the help text:
1818

1919
COMMANDS
2020
dune-release [OPTION]… [ARGS]…
21-
Wrapper for running dune-release. All positional arguments will be
22-
passed to the dune-release executable (pass flags to dune-release
23-
after the '--' argument, such as 'dune tools exec dune-release --
24-
--help').
25-
26-
merlin [OPTION]… [ARGS]…
27-
Wrapper for running merlin. All positional arguments will be
28-
passed to the merlin executable (pass flags to merlin after the
29-
'--' argument, such as 'dune tools exec merlin -- --help').
21+
Wrapper for running dune-release intended to be run automatically
22+
by a text editor. All positional arguments will be passed to the
23+
dune-release executable (pass flags to dune-release after the '--'
24+
argument, such as 'dune tools exec dune-release -- --help').
3025

3126
ocaml-index [OPTION]… [ARGS]…
32-
Wrapper for running ocaml-index. All positional arguments will be
33-
passed to the ocaml-index executable (pass flags to ocaml-index
34-
after the '--' argument, such as 'dune tools exec ocaml-index --
35-
--help').
27+
Wrapper for running ocaml-index intended to be run automatically
28+
by a text editor. All positional arguments will be passed to the
29+
ocaml-index executable (pass flags to ocaml-index after the '--'
30+
argument, such as 'dune tools exec ocaml-index -- --help').
3631

3732
ocamlearlybird [OPTION]… [ARGS]…
38-
Wrapper for running ocamlearlybird. All positional arguments will
39-
be passed to the ocamlearlybird executable (pass flags to
33+
Wrapper for running ocamlearlybird intended to be run
34+
automatically by a text editor. All positional arguments will be
35+
passed to the ocamlearlybird executable (pass flags to
4036
ocamlearlybird after the '--' argument, such as 'dune tools exec
4137
ocamlearlybird -- --help').
4238

4339
ocamlformat [OPTION]… [ARGS]…
44-
Wrapper for running ocamlformat. All positional arguments will be
45-
passed to the ocamlformat executable (pass flags to ocamlformat
46-
after the '--' argument, such as 'dune tools exec ocamlformat --
47-
--help').
40+
Wrapper for running ocamlformat intended to be run automatically
41+
by a text editor. All positional arguments will be passed to the
42+
ocamlformat executable (pass flags to ocamlformat after the '--'
43+
argument, such as 'dune tools exec ocamlformat -- --help').
4844

4945
ocamllsp [OPTION]… [ARGS]…
50-
Wrapper for running ocamllsp. All positional arguments will be
51-
passed to the ocamllsp executable (pass flags to ocamllsp after
52-
the '--' argument, such as 'dune tools exec ocamllsp -- --help').
46+
Wrapper for running ocamllsp intended to be run automatically by a
47+
text editor. All positional arguments will be passed to the
48+
ocamllsp executable (pass flags to ocamllsp after the '--'
49+
argument, such as 'dune tools exec ocamllsp -- --help').
50+
51+
ocamlmerlin [OPTION]… [ARGS]…
52+
Wrapper for running ocamlmerlin intended to be run automatically
53+
by a text editor. All positional arguments will be passed to the
54+
ocamlmerlin executable (pass flags to ocamlmerlin after the '--'
55+
argument, such as 'dune tools exec ocamlmerlin -- --help').
5356

5457
odig [OPTION]… [ARGS]…
55-
Wrapper for running odig. All positional arguments will be passed
56-
to the odig executable (pass flags to odig after the '--'
57-
argument, such as 'dune tools exec odig -- --help').
58+
Wrapper for running odig intended to be run automatically by a
59+
text editor. All positional arguments will be passed to the odig
60+
executable (pass flags to odig after the '--' argument, such as
61+
'dune tools exec odig -- --help').
5862

5963
opam-publish [OPTION]… [ARGS]…
60-
Wrapper for running opam-publish. All positional arguments will be
61-
passed to the opam-publish executable (pass flags to opam-publish
62-
after the '--' argument, such as 'dune tools exec opam-publish --
63-
--help').
64+
Wrapper for running opam-publish intended to be run automatically
65+
by a text editor. All positional arguments will be passed to the
66+
opam-publish executable (pass flags to opam-publish after the '--'
67+
argument, such as 'dune tools exec opam-publish -- --help').
6468

6569
COMMON OPTIONS
6670
--help[=FMT] (default=auto)
@@ -86,3 +90,10 @@ Output the help text:
8690

8791

8892

93+
94+
95+
96+
97+
98+
99+

test/blackbox-tests/test-cases/pkg/merlin/dev-tool-merlin-basic.t

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Test that the "dune tools exec merlin" command causes merlin to be
1+
Test that the "dune tools exec ocamlmerlin" command causes merlin to be
22
locked, built and run when the command is run from a dune project with
33
a lockdir containing an "ocaml" lockfile.
44

@@ -24,15 +24,9 @@ a lockdir containing an "ocaml" lockfile.
2424
> (version 5.2.0)
2525
> EOF
2626

27-
$ dune tools exec merlin
27+
$ dune tools exec ocamlmerlin
2828
Solution for _build/.dev-tools.locks/merlin:
2929
- merlin.0.0.1
3030
- ocaml.5.2.0
31-
Running 'merlin'
31+
Running 'ocamlmerlin'
3232
hello from fake ocamlmerlin
33-
34-
Make sure that after evaling the output of 'dune tools env', the first ocamlmerlin
35-
executable in PATH is the one installed by dune as a dev tool.
36-
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled eval $(dune tools env)
37-
$ which ocamlmerlin
38-
$TESTCASE_ROOT/_build/_private/default/.dev-tool/merlin/target/bin/ocamlmerlin
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Test that after evaling the output of 'dune tools env', the first ocamlmerlin
2+
executable in PATH is the one installed by dune as a dev tool.
3+
4+
$ . ../helpers.sh
5+
$ . ./helpers.sh
6+
7+
$ mkrepo
8+
$ make_mock_merlin_package
9+
$ mkpkg ocaml 5.2.0
10+
11+
$ setup_merlin_workspace
12+
13+
$ cat > dune-project <<EOF
14+
> (lang dune 3.16)
15+
>
16+
> (package
17+
> (name foo)
18+
> (allow_empty))
19+
> EOF
20+
21+
$ make_lockdir
22+
$ make_lockpkg ocaml <<EOF
23+
> (version 5.2.0)
24+
> EOF
25+
26+
First install the tool:
27+
$ dune tools exec ocamlmerlin
28+
Solution for _build/.dev-tools.locks/merlin:
29+
- merlin.0.0.1
30+
- ocaml.5.2.0
31+
Running 'ocamlmerlin'
32+
hello from fake ocamlmerlin
33+
34+
Now check that 'dune tools env' puts the dev tool in PATH:
35+
$ eval $(dune tools env)
36+
$ which ocamlmerlin
37+
$TESTCASE_ROOT/_build/_private/default/.dev-tool/merlin/target/bin/ocamlmerlin

test/blackbox-tests/test-cases/pkg/merlin/dev-tool-merlin-relock-on-ocaml-version-change.t

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,35 @@ same version of the ocaml compiler as the code that it's analyzing.
2828
> EOF
2929

3030
Initially merlin will depend on ocaml.5.2.0 to match the project.
31-
$ dune tools exec merlin
31+
$ dune tools exec ocamlmerlin
3232
Solution for _build/.dev-tools.locks/merlin:
3333
- merlin.0.0.1
3434
- ocaml.5.2.0
35-
Running 'merlin'
35+
Running 'ocamlmerlin'
3636
hello from fake ocamlmerlin
3737
$ cat "${dev_tool_lock_dir}"/ocaml.pkg
3838
(version 5.2.0)
3939

40-
We can re-run "dune tools exec merlin" without relocking or rebuilding.
41-
$ dune tools exec merlin
42-
Running 'merlin'
40+
We can re-run "dune tools exec ocamlmerlin" without relocking or rebuilding.
41+
$ dune tools exec ocamlmerlin
42+
Running 'ocamlmerlin'
4343
hello from fake ocamlmerlin
4444

4545
Change the version of ocaml that the project depends on.
4646
$ make_lockpkg ocaml <<EOF
4747
> (version 5.1.0)
4848
> EOF
4949

50-
Running "dune tools exec merlin" causes merlin to be relocked and rebuilt
50+
Running "dune tools exec ocamlmerlin" causes merlin to be relocked and rebuilt
5151
before running. Merlin now depends on ocaml.5.1.0.
52-
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune tools exec merlin
52+
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune tools exec ocamlmerlin
5353
The version of the compiler package ("ocaml") in this project's lockdir has
5454
changed to 5.1.0 (formerly the compiler version was 5.2.0). The dev-tool
5555
"merlin" will be re-locked and rebuilt with this version of the compiler.
5656
Solution for _build/.dev-tools.locks/merlin:
5757
- merlin.0.0.1
5858
- ocaml.5.1.0
59-
Running 'merlin'
59+
Running 'ocamlmerlin'
6060
hello from fake ocamlmerlin
6161
$ cat "${dev_tool_lock_dir}"/ocaml.pkg
6262
(version 5.1.0)

0 commit comments

Comments
 (0)