Debian Codegraph @

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

raw
1 Test that if the version of the "ocaml" package in the project's
2 lockdir changes then the merlin dev tool is re-locked to be built
3 with the version of the ocaml compiler now in the project's
4 lockdir. This is necessary because merlin must be compiled with the
5 same version of the ocaml compiler as the code that it's analyzing.
6
7 $ mkrepo
8 $ make_mock_merlin_package
9 $ mk_ocaml 5.2.0
10 $ mk_ocaml 5.1.0
11
12 $ setup_merlin_workspace
13
14 $ cat > dune-project <<EOF
15 > (lang dune 3.16)
16 >
17 > (package
18 > (name foo)
19 > (allow_empty)
20 > (depends
21 > (ocaml (= 5.2.0))))
22 > EOF
23
24 $ dune build
25
26 Initially merlin will depend on ocaml-base-compiler.5.2.0 to match the project.
27
28 $ dune tools exec ocamlmerlin
29 Solution for _build/.dev-tools.locks/merlin:
30 - merlin.0.0.1
31 - ocaml-base-compiler.5.2.0
32 - ocaml-compiler.5.2.0
33 Running 'ocamlmerlin'
34 hello from fake ocamlmerlin
35 $ grep "version" "${dev_tool_lock_dir}"/ocaml-base-compiler.pkg
36 (version 5.2.0)
37
38 We can re-run "dune tools exec ocamlmerlin" without relocking or rebuilding.
39 $ dune tools exec ocamlmerlin
40 The version of the compiler package ("ocaml-base-compiler") in this project's
41 lockdir has changed to 5.2.0 (formerly the compiler version was 5.2.0). The
42 dev-tool "merlin" will be re-locked and rebuilt with this version of the
43 compiler.
44 Solution for _build/.dev-tools.locks/merlin:
45 - merlin.0.0.1
46 - ocaml-base-compiler.5.2.0
47 - ocaml-compiler.5.2.0
48 Running 'ocamlmerlin'
49 hello from fake ocamlmerlin
50
51 Change the version of ocaml that the project depends on.
52
53 $ cat > dune-project <<EOF
54 > (lang dune 3.16)
55 >
56 > (package
57 > (name foo)
58 > (allow_empty)
59 > (depends
60 > (ocaml (= 5.1.0))))
61 > EOF
62
63 $ dune build
64
65 Running "dune tools exec ocamlmerlin" causes merlin to be relocked and rebuilt
66 before running. Merlin now depends on ocaml.5.1.0.
67 $ dune tools exec ocamlmerlin
68 The version of the compiler package ("ocaml-base-compiler") in this project's
69 lockdir has changed to 5.1.0 (formerly the compiler version was 5.2.0). The
70 dev-tool "merlin" will be re-locked and rebuilt with this version of the
71 compiler.
72 Solution for _build/.dev-tools.locks/merlin:
73 - merlin.0.0.1
74 - ocaml-base-compiler.5.1.0
75 - ocaml-compiler.5.1.0
76 Running 'ocamlmerlin'
77 hello from fake ocamlmerlin
78 $ grep "version" "${dev_tool_lock_dir}"/ocaml-base-compiler.pkg
79 (version 5.1.0)