| 1 |
Test that ocamllsp uses a pinned compiler branch instead of fetching from |
| 2 |
opam-repository. |
| 3 |
|
| 4 |
$ mkrepo |
| 5 |
$ make_mock_ocamllsp_package |
| 6 |
$ mk_ocaml 5.2.0 |
| 7 |
|
| 8 |
Create a fake pinned compiler source. This simulates a scenario where the user |
| 9 |
has pinned a custom compiler branch (e.g., OxCaml). |
| 10 |
|
| 11 |
$ mkdir -p pinned-compiler |
| 12 |
$ cat > pinned-compiler/ocaml-base-compiler.opam <<EOF |
| 13 |
> opam-version: "2.0" |
| 14 |
> version: "5.2.0+custom" |
| 15 |
> flags: compiler |
| 16 |
> conflict-class: "ocaml-core-compiler" |
| 17 |
> EOF |
| 18 |
|
| 19 |
Set up the dune-project with a pin for the ocaml-base-compiler pointing to our custom source. |
| 20 |
|
| 21 |
$ cat > dune-project <<EOF |
| 22 |
> (lang dune 3.21) |
| 23 |
> (pin |
| 24 |
> (url "file://$PWD/pinned-compiler") |
| 25 |
> (package (name ocaml-base-compiler))) |
| 26 |
> (package |
| 27 |
> (name foo) |
| 28 |
> (allow_empty) |
| 29 |
> (depends ocaml-base-compiler)) |
| 30 |
> EOF |
| 31 |
|
| 32 |
$ setup_ocamllsp_workspace |
| 33 |
|
| 34 |
Lock the project first to establish the pinned compiler in the lockfile. |
| 35 |
|
| 36 |
$ dune pkg lock 2>&1 | head -20 |
| 37 |
Solution for dune.lock |
| 38 |
|
| 39 |
Dependencies common to all supported platforms: |
| 40 |
- ocaml-base-compiler.dev |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
Check the lockfile to verify the compiler is set. |
| 45 |
|
| 46 |
$ cat dune.lock/lock.dune | grep ocaml |
| 47 |
(ocaml ocaml-base-compiler) |
| 48 |
|
| 49 |
Now install ocamllsp. It should use the pinned compiler, not fetch from opam-repository. |
| 50 |
The key indicator is that we see "ocaml-base-compiler.dev" in the solution (from our pin), |
| 51 |
rather than "ocaml-base-compiler.5.2.0" from opam-repository. |
| 52 |
|
| 53 |
$ dune tools install ocamllsp 2>&1 | head -10 |
| 54 |
Solution for _build/.dev-tools.locks/ocaml-lsp-server: |
| 55 |
- ocaml-base-compiler.dev |
| 56 |
- ocaml-lsp-server.0.0.1 |
| 57 |
|
| 58 |
$ dune tools exec ocamllsp |
| 59 |
The version of the compiler package ("ocaml-base-compiler") in this project's |
| 60 |
lockdir has changed to dev (formerly the compiler version was dev). The |
| 61 |
dev-tool "ocaml-lsp-server" will be re-locked and rebuilt with this version |
| 62 |
of the compiler. |
| 63 |
Solution for _build/.dev-tools.locks/ocaml-lsp-server: |
| 64 |
- ocaml-base-compiler.dev |
| 65 |
- ocaml-lsp-server.0.0.1 |
| 66 |
Running 'ocamllsp' |
| 67 |
hello from fake ocamllsp |