From f515fa83d4a42e5ab35c113e8aa3cf63490b7a36 Mon Sep 17 00:00:00 2001 From: Alpha DIALLO Date: Thu, 7 Nov 2024 16:23:02 +0100 Subject: [PATCH] Add a test case Signed-off-by: Alpha DIALLO --- test/blackbox-tests/test-cases/pkg/helpers.sh | 12 +++++ .../test-cases/pkg/tools-install.t | 50 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 test/blackbox-tests/test-cases/pkg/tools-install.t diff --git a/test/blackbox-tests/test-cases/pkg/helpers.sh b/test/blackbox-tests/test-cases/pkg/helpers.sh index e407ffb48a4..5e7d98650cb 100644 --- a/test/blackbox-tests/test-cases/pkg/helpers.sh +++ b/test/blackbox-tests/test-cases/pkg/helpers.sh @@ -117,3 +117,15 @@ print_source() { solve() { make_project $@ | solve_project } + +make_mock_tool_package() { + package=$1 + binary=$2 + mkpkg $package < %{bin}%/$binary" ] + [ "sh" "-c" "echo 'echo hello from fake $binary' >> %{bin}%/$binary" ] + [ "sh" "-c" "chmod a+x %{bin}%/$binary" ] +] +EOF +} diff --git a/test/blackbox-tests/test-cases/pkg/tools-install.t b/test/blackbox-tests/test-cases/pkg/tools-install.t new file mode 100644 index 00000000000..67b67126154 --- /dev/null +++ b/test/blackbox-tests/test-cases/pkg/tools-install.t @@ -0,0 +1,50 @@ + $ . ./helpers.sh + + $ 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 + + $ cat > dune-workspace < (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 < (lang dune 3.16) + > + > (package + > (name foo) + > (depends ocaml)) + > EOF + + $ 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 + $ ls ./_build/_private/default/.dev-tool + ocaml-lsp-server + ocamlformat + odoc