Skip to content

Commit

Permalink
Add a test case
Browse files Browse the repository at this point in the history
Signed-off-by: Alpha DIALLO <[email protected]>
  • Loading branch information
moyodiallo committed Nov 7, 2024
1 parent 64bcacf commit b92b7af
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/blackbox-tests/test-cases/pkg/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,15 @@ print_source() {
solve() {
make_project $@ | solve_project
}

make_mock_tool_package() {
package=$1
binary=$2
mkpkg $package <<EOF
install: [
[ "sh" "-c" "echo '#!/bin/sh' > %{bin}%/$binary" ]
[ "sh" "-c" "echo 'echo hello from fake $binary' >> %{bin}%/$binary" ]
[ "sh" "-c" "chmod a+x %{bin}%/$binary" ]
]
EOF
}
57 changes: 57 additions & 0 deletions test/blackbox-tests/test-cases/pkg/tools-install.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
$ . ./helpers.sh

Test for "dune tools install" command which installs all the available dev-tools .
The command locks and builds those dev-tools.

$ mkrepo
$ make_mock_tool_package odoc odoc
$ make_mock_tool_package ocaml-lsp-server ocamllsp
$ make_mock_tool_package ocamlformat ocamlformat
$ mkpkg ocaml 5.2.0

Each dev-tool has it own lock-dir
$ cat > dune-workspace <<EOF
> (lang dune 3.16)
> (lock_dir
> (path "dev-tools.locks/odoc")
> (repositories mock))
> (lock_dir
> (path "dev-tools.locks/ocamlformat")
> (repositories mock))
> (lock_dir
> (path "dev-tools.locks/ocaml-lsp-server")
> (repositories mock))
> (lock_dir
> (repositories mock))
> (repository
> (name mock)
> (source "file://$(pwd)/mock-opam-repository"))
> EOF

$ cat > dune-project <<EOF
> (lang dune 3.16)
> (package
> (name foo)
> (depends ocaml))
> EOF

Building dev-tool requires the project been locked.
$ dune pkg lock
Solution for dune.lock:
- ocaml.5.2.0

$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune tools install
Solution for dev-tools.locks/ocamlformat:
- ocamlformat.0.0.1
Solution for dev-tools.locks/odoc:
- ocaml.5.2.0
- odoc.0.0.1
Solution for dev-tools.locks/ocaml-lsp-server:
- ocaml.5.2.0
- ocaml-lsp-server.0.0.1

Check, if the dev-tools are built.
$ ls ./_build/_private/default/.dev-tool
ocaml-lsp-server
ocamlformat
odoc

0 comments on commit b92b7af

Please sign in to comment.