Debian Codegraph @

test/blackbox-tests/test-cases/pkg/ocamllsp/dev-tool-ocamllsp-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 ocamllsp 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 ocamllsp 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_ocamllsp_package
9 $ mk_ocaml 5.2.0
10 $ mk_ocaml 5.1.0
11
12 $ setup_ocamllsp_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 ocamllsp will depend on ocaml-base-compiler.5.2.0 to match the project.
27 $ dune tools exec ocamllsp
28 Solution for _build/.dev-tools.locks/ocaml-lsp-server:
29 - ocaml-base-compiler.5.2.0
30 - ocaml-compiler.5.2.0
31 - ocaml-lsp-server.0.0.1
32 Running 'ocamllsp'
33 hello from fake ocamllsp
34 $ grep "version" "${dev_tool_lock_dir}"/ocaml-base-compiler.pkg
35 (version 5.2.0)
36
37
38 We can re-run "dune tools exec ocamllsp" without relocking or rebuilding.
39 $ dune tools exec ocamllsp
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 "ocaml-lsp-server" will be re-locked and rebuilt with this version
43 of the compiler.
44 Solution for _build/.dev-tools.locks/ocaml-lsp-server:
45 - ocaml-base-compiler.5.2.0
46 - ocaml-compiler.5.2.0
47 - ocaml-lsp-server.0.0.1
48 Running 'ocamllsp'
49 hello from fake ocamllsp
50
51 Change the version of ocaml that the project depends on.
52 $ cat > dune-project <<EOF
53 > (lang dune 3.16)
54 >
55 > (package
56 > (name foo)
57 > (allow_empty)
58 > (depends
59 > (ocaml (= 5.1.0))))
60 > EOF
61
62 $ dune build
63
64
65 Running "dune tools exec ocamllsp" causes ocamllsp to be relocked and rebuilt
66 before running. Ocamllsp now depends on ocaml.5.1.0.
67 $ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune tools exec ocamllsp
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 "ocaml-lsp-server" will be re-locked and rebuilt with this version
71 of the compiler.
72 Solution for _build/.dev-tools.locks/ocaml-lsp-server:
73 - ocaml-base-compiler.5.1.0
74 - ocaml-compiler.5.1.0
75 - ocaml-lsp-server.0.0.1
76 Running 'ocamllsp'
77 hello from fake ocamllsp
78 $ grep "version" "${dev_tool_lock_dir}"/ocaml-base-compiler.pkg
79 (version 5.1.0)