This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,32 @@
|
|||
Test that the "dune tools exec ocamllsp" command causes ocamllsp to be
|
||||
locked, built and run when the command is run from a dune project with
|
||||
a lockdir containing an "ocaml" lockfile.
|
||||
|
||||
$ . ../helpers.sh
|
||||
$ . ./helpers.sh
|
||||
|
||||
$ mkrepo
|
||||
$ make_mock_ocamllsp_package
|
||||
$ mkpkg ocaml 5.2.0
|
||||
|
||||
$ setup_ocamllsp_workspace
|
||||
|
||||
$ cat > dune-project <<EOF
|
||||
> (lang dune 3.16)
|
||||
>
|
||||
> (package
|
||||
> (name foo)
|
||||
> (allow_empty))
|
||||
> EOF
|
||||
|
||||
$ make_lockdir
|
||||
$ cat > dune.lock/ocaml.pkg <<EOF
|
||||
> (version 5.2.0)
|
||||
> EOF
|
||||
|
||||
$ dune tools exec ocamllsp
|
||||
Solution for dev-tools.locks/ocaml-lsp-server:
|
||||
- ocaml.5.2.0
|
||||
- ocaml-lsp-server.0.0.1
|
||||
Running 'ocamllsp'
|
||||
hello from fake ocamllsp
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
Test that the ocamllsp dev tool executes in an environment where other dev
|
||||
tools are in PATH.
|
||||
|
||||
$ . ../helpers.sh
|
||||
$ . ./helpers.sh
|
||||
|
||||
$ mkrepo
|
||||
$ mkpkg ocaml 5.2.0
|
||||
$ setup_ocamllsp_workspace
|
||||
|
||||
Make a fake ocamllsp package that prints out the PATH variable:
|
||||
$ mkpkg ocaml-lsp-server <<EOF
|
||||
> install: [
|
||||
> [ "sh" "-c" "echo '#!/bin/sh' > %{bin}%/ocamllsp" ]
|
||||
> [ "sh" "-c" "echo 'echo \$PATH' >> %{bin}%/ocamllsp" ]
|
||||
> [ "sh" "-c" "chmod a+x %{bin}%/ocamllsp" ]
|
||||
> ]
|
||||
> EOF
|
||||
|
||||
$ make_lockdir
|
||||
$ cat > dune.lock/ocaml.pkg <<EOF
|
||||
> (version 5.2.0)
|
||||
> EOF
|
||||
|
||||
Confirm that each dev tool's bin directory is now in PATH:
|
||||
$ dune tools exec ocamllsp | tr : '\n' | grep '_build/_private/default/.dev-tool'
|
||||
Solution for dev-tools.locks/ocaml-lsp-server:
|
||||
- ocaml.5.2.0
|
||||
- ocaml-lsp-server.0.0.1
|
||||
Running 'ocamllsp'
|
||||
$TESTCASE_ROOT/_build/_private/default/.dev-tool/earlybird/earlybird/target/bin
|
||||
$TESTCASE_ROOT/_build/_private/default/.dev-tool/utop/utop/target/bin
|
||||
$TESTCASE_ROOT/_build/_private/default/.dev-tool/ocaml-lsp-server/ocaml-lsp-server/target/bin
|
||||
$TESTCASE_ROOT/_build/_private/default/.dev-tool/odoc/odoc/target/bin
|
||||
$TESTCASE_ROOT/_build/_private/default/.dev-tool/ocamlformat/ocamlformat/target/bin
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
Test that ocamllsp can be installed while dune is running in watch mode.
|
||||
|
||||
$ . ../helpers.sh
|
||||
$ . ./helpers.sh
|
||||
|
||||
$ mkrepo
|
||||
$ make_mock_ocamllsp_package
|
||||
$ mkpkg ocaml 5.2.0
|
||||
|
||||
$ setup_ocamllsp_workspace
|
||||
|
||||
$ cat > dune-project <<EOF
|
||||
> (lang dune 3.18)
|
||||
>
|
||||
> (package
|
||||
> (name foo))
|
||||
> EOF
|
||||
|
||||
$ make_lockdir
|
||||
$ cat > dune.lock/ocaml.pkg <<EOF
|
||||
> (version 5.2.0)
|
||||
> EOF
|
||||
|
||||
$ cat > foo.ml <<EOF
|
||||
> let () = print_endline "hi"
|
||||
> EOF
|
||||
|
||||
$ cat > dune <<EOF
|
||||
> (executable (public_name foo))
|
||||
> EOF
|
||||
|
||||
$ dune build --watch &
|
||||
Success, waiting for filesystem changes...
|
||||
Success, waiting for filesystem changes...
|
||||
|
||||
$ dune tools exec ocamllsp
|
||||
Solution for dev-tools.locks/ocaml-lsp-server:
|
||||
- ocaml.5.2.0
|
||||
- ocaml-lsp-server.0.0.1
|
||||
Running 'ocamllsp'
|
||||
hello from fake ocamllsp
|
||||
|
||||
$ dune shutdown
|
||||
$ wait
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
Exercise the behaviour of "dune tools exec ocamllsp" when run in a
|
||||
dune project with no lockdir.
|
||||
|
||||
$ cat > dune-project <<EOF
|
||||
> (lang dune 3.16)
|
||||
>
|
||||
> (package
|
||||
> (name foo)
|
||||
> (allow_empty))
|
||||
> EOF
|
||||
|
||||
$ dune tools exec ocamllsp
|
||||
Error: Unable to load the lockdir for the default build context.
|
||||
Hint: Try running 'dune pkg lock'
|
||||
[1]
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
Exercise the behaviour of "dune tools exec ocamllsp" when the lockdir
|
||||
doesn't contain a lockfile for the "ocaml" package.
|
||||
|
||||
$ . ../helpers.sh
|
||||
|
||||
$ cat > dune-project <<EOF
|
||||
> (lang dune 3.16)
|
||||
>
|
||||
> (package
|
||||
> (name foo)
|
||||
> (allow_empty))
|
||||
> EOF
|
||||
|
||||
$ make_lockdir
|
||||
|
||||
$ dune tools exec ocamllsp
|
||||
Error: The lockdir doesn't contain a lockfile for the package "ocaml".
|
||||
Hint: Add a dependency on "ocaml" to one of the packages in dune-project and
|
||||
then run 'dune pkg lock'
|
||||
[1]
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
Test that the ocamllsp dev tool can see the ocamlformat dev tool.
|
||||
|
||||
$ . ../helpers.sh
|
||||
$ . ./helpers.sh
|
||||
|
||||
$ mkrepo
|
||||
$ mkpkg ocaml 5.2.0
|
||||
|
||||
$ cat > dune-workspace <<EOF
|
||||
> (lang dune 3.16)
|
||||
> (lock_dir
|
||||
> (path "dev-tools.locks/ocaml-lsp-server")
|
||||
> (repositories mock))
|
||||
> (lock_dir
|
||||
> (path "dev-tools.locks/ocamlformat")
|
||||
> (repositories mock))
|
||||
> (lock_dir
|
||||
> (repositories mock))
|
||||
> (repository
|
||||
> (name mock)
|
||||
> (url "file://$(pwd)/mock-opam-repository"))
|
||||
> EOF
|
||||
|
||||
Make a fake ocamllsp package that prints out the PATH variable:
|
||||
$ mkpkg ocaml-lsp-server <<EOF
|
||||
> install: [
|
||||
> [ "sh" "-c" "echo '#!/bin/sh' > %{bin}%/ocamllsp" ]
|
||||
> [ "sh" "-c" "echo 'echo fake ocamllsp will now run fake ocamlformat:' >> %{bin}%/ocamllsp" ]
|
||||
> [ "sh" "-c" "echo 'ocamlformat' >> %{bin}%/ocamllsp" ]
|
||||
> [ "sh" "-c" "chmod a+x %{bin}%/ocamllsp" ]
|
||||
> ]
|
||||
> EOF
|
||||
|
||||
Make a fake ocamlformat
|
||||
$ mkpkg ocamlformat <<EOF
|
||||
> install: [
|
||||
> [ "sh" "-c" "echo '#!/bin/sh' > %{bin}%/ocamlformat" ]
|
||||
> [ "sh" "-c" "echo 'echo hello from fake ocamlformat' >> %{bin}%/ocamlformat" ]
|
||||
> [ "sh" "-c" "chmod a+x %{bin}%/ocamlformat" ]
|
||||
> ]
|
||||
> EOF
|
||||
|
||||
$ make_lockdir
|
||||
$ cat > dune.lock/ocaml.pkg <<EOF
|
||||
> (version 5.2.0)
|
||||
> EOF
|
||||
|
||||
$ dune tools install ocamlformat
|
||||
Solution for dev-tools.locks/ocamlformat:
|
||||
- ocamlformat.0.0.1
|
||||
|
||||
$ dune tools exec ocamllsp
|
||||
Solution for dev-tools.locks/ocaml-lsp-server:
|
||||
- ocaml.5.2.0
|
||||
- ocaml-lsp-server.0.0.1
|
||||
Running 'ocamllsp'
|
||||
fake ocamllsp will now run fake ocamlformat:
|
||||
hello from fake ocamlformat
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
Exercise the behaviour of "dune tools exec ocamllsp" when run outside
|
||||
of a dune project.
|
||||
|
||||
|
||||
This is necessary for dune to act as it normally would outside of a
|
||||
dune workspace.
|
||||
$ unset INSIDE_DUNE
|
||||
|
||||
Run the wrapper command from a temporary directory. With INSIDE_DUNE
|
||||
unset dune would otherwise pick up the dune project itself as the
|
||||
current workspace.
|
||||
$ cd $(mktemp -d)
|
||||
|
||||
$ dune tools exec ocamllsp
|
||||
Error: I cannot find the root of the current workspace/project.
|
||||
If you would like to create a new dune project, you can type:
|
||||
|
||||
dune init project NAME
|
||||
|
||||
Otherwise, please make sure to run dune inside an existing project or
|
||||
workspace. For more information about how dune identifies the root of the
|
||||
current workspace/project, please refer to
|
||||
https://dune.readthedocs.io/en/stable/usage.html#finding-the-root
|
||||
[1]
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
Test that if the version of the "ocaml" package in the project's
|
||||
lockdir changes then the ocamllsp dev tool is re-locked to be built
|
||||
with the version of the ocaml compiler now in the project's
|
||||
lockdir. This is necessary because ocamllsp must be compiled with the
|
||||
same version of the ocaml compiler as the code that it's analyzing.
|
||||
|
||||
$ . ../helpers.sh
|
||||
$ . ./helpers.sh
|
||||
|
||||
$ mkrepo
|
||||
$ make_mock_ocamllsp_package
|
||||
$ mkpkg ocaml 5.2.0
|
||||
$ mkpkg ocaml 5.1.0
|
||||
|
||||
$ setup_ocamllsp_workspace
|
||||
|
||||
$ cat > dune-project <<EOF
|
||||
> (lang dune 3.16)
|
||||
>
|
||||
> (package
|
||||
> (name foo)
|
||||
> (allow_empty))
|
||||
> EOF
|
||||
|
||||
$ make_lockdir
|
||||
$ cat > dune.lock/ocaml.pkg <<EOF
|
||||
> (version 5.2.0)
|
||||
> EOF
|
||||
|
||||
Initially ocamllsp will be depend on ocaml.5.2.0 to match the project.
|
||||
$ dune tools exec ocamllsp
|
||||
Solution for dev-tools.locks/ocaml-lsp-server:
|
||||
- ocaml.5.2.0
|
||||
- ocaml-lsp-server.0.0.1
|
||||
Running 'ocamllsp'
|
||||
hello from fake ocamllsp
|
||||
$ cat dev-tools.locks/ocaml-lsp-server/ocaml.pkg
|
||||
(version 5.2.0)
|
||||
|
||||
We can re-run "dune tools exec ocamllsp" without relocking or rebuilding.
|
||||
$ dune tools exec ocamllsp
|
||||
Running 'ocamllsp'
|
||||
hello from fake ocamllsp
|
||||
|
||||
Change the version of ocaml that the project depends on.
|
||||
$ cat > dune.lock/ocaml.pkg <<EOF
|
||||
> (version 5.1.0)
|
||||
> EOF
|
||||
|
||||
Running "dune tools exec ocamllsp" causes ocamllsp to be relocked and rebuilt
|
||||
before running. Ocamllsp now depends on ocaml.5.1.0.
|
||||
$ dune tools exec ocamllsp
|
||||
The version of the compiler package ("ocaml") in this project's lockdir has
|
||||
changed to 5.1.0 (formerly the compiler version was 5.2.0). The dev-tool
|
||||
"ocaml-lsp-server" will be re-locked and rebuilt with this version of the
|
||||
compiler.
|
||||
Solution for dev-tools.locks/ocaml-lsp-server:
|
||||
- ocaml.5.1.0
|
||||
- ocaml-lsp-server.0.0.1
|
||||
Running 'ocamllsp'
|
||||
hello from fake ocamllsp
|
||||
$ cat dev-tools.locks/ocaml-lsp-server/ocaml.pkg
|
||||
(version 5.1.0)
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
(cram
|
||||
(deps helpers.sh)
|
||||
(applies_to :whole_subtree))
|
||||
|
||||
;; flaky https://github.com/ocaml/dune/actions/runs/15262698269/job/42923225446
|
||||
|
||||
(cram
|
||||
(applies_to dev-tool-ocamllsp-install-concurrent-with-watch-server)
|
||||
(enabled_if false))
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
# Create a dune-workspace file with mock repos set up for the main
|
||||
# project and the ocamllsp lockdir.
|
||||
setup_ocamllsp_workspace() {
|
||||
cat > dune-workspace <<EOF
|
||||
(lang dune 3.16)
|
||||
(lock_dir
|
||||
(path "dev-tools.locks/ocaml-lsp-server")
|
||||
(repositories mock))
|
||||
(lock_dir
|
||||
(repositories mock))
|
||||
(repository
|
||||
(name mock)
|
||||
(url "file://$(pwd)/mock-opam-repository"))
|
||||
EOF
|
||||
}
|
||||
|
||||
# Create a fake ocaml-lsp-server package containing an executable that
|
||||
# just prints a message.
|
||||
make_mock_ocamllsp_package() {
|
||||
mkpkg ocaml-lsp-server <<EOF
|
||||
install: [
|
||||
[ "sh" "-c" "echo '#!/bin/sh' > %{bin}%/ocamllsp" ]
|
||||
[ "sh" "-c" "echo 'echo hello from fake ocamllsp' >> %{bin}%/ocamllsp" ]
|
||||
[ "sh" "-c" "chmod a+x %{bin}%/ocamllsp" ]
|
||||
]
|
||||
EOF
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue