File tree Expand file tree Collapse file tree 3 files changed +101
-1
lines changed
test/blackbox-tests/test-cases/pkg/ocamllsp Expand file tree Collapse file tree 3 files changed +101
-1
lines changed Original file line number Diff line number Diff line change 11open ! Import
22module Pkg_dev_tool = Dune_rules. Pkg_dev_tool
33
4+ let add_dev_tools_to_path env =
5+ List. fold_left Pkg_dev_tool. all ~init: env ~f: (fun acc tool ->
6+ let dir = Pkg_dev_tool. exe_path tool |> Path.Build. parent_exn |> Path. build in
7+ Env_path. cons acc ~dir )
8+ ;;
9+
410let dev_tool_exe_path dev_tool = Path. build @@ Pkg_dev_tool. exe_path dev_tool
511
612let dev_tool_build_target dev_tool =
@@ -47,7 +53,8 @@ let run_dev_tool workspace_root dev_tool ~args =
4753 ~verb: " Running"
4854 ~object_: (User_message. command (String. concat ~sep: " " (exe_name :: args))));
4955 Console. finish () ;
50- restore_cwd_and_execve workspace_root exe_path_string args Env. initial
56+ let env = add_dev_tools_to_path Env. initial in
57+ restore_cwd_and_execve workspace_root exe_path_string args env
5158;;
5259
5360let lock_build_and_run_dev_tool ~common ~config dev_tool ~args =
Original file line number Diff line number Diff line change 1+ Test that the ocamllsp dev tool executes in an environment where other dev
2+ tools are in PATH.
3+
4+ $ . .. / helpers. sh
5+ $ . ./ helpers. sh
6+
7+ $ mkrepo
8+ $ mkpkg ocaml 5.2 . 0
9+ $ setup_ocamllsp_workspace
10+
11+ Make a fake ocamllsp package that prints out the PATH variable:
12+ $ mkpkg ocaml-lsp-server << EOF
13+ > install: [
14+ > [ " sh" " -c" " echo '#!/bin/sh' > %{ bin} %/ocamllsp" ]
15+ > [ " sh" " -c" " echo 'echo \$PATH' >> %{ bin} %/ocamllsp" ]
16+ > [ " sh" " -c" " chmod a+x %{ bin} %/ocamllsp" ]
17+ > ]
18+ > EOF
19+
20+ $ make_lockdir
21+ $ cat > dune. lock/ ocaml. pkg << EOF
22+ > (version 5.2 . 0)
23+ > EOF
24+
25+ Confirm that each dev tool's bin directory is now in PATH:
26+ $ dune tools exec ocamllsp | tr : ' \n' | grep ' _build/_private/default/.dev-tool'
27+ Solution for dev-tools. locks/ ocaml-lsp-server:
28+ - ocaml. 5. 2. 0
29+ - ocaml-lsp-server. 0. 0. 1
30+ Running ' ocamllsp'
31+ $ TESTCASE_ROOT / _build/ _private/ default /. dev-tool/ earlybird/ earlybird/ target/ bin
32+ $ TESTCASE_ROOT / _build/ _private/ default /. dev-tool/ utop/ utop/ target/ bin
33+ $ TESTCASE_ROOT / _build/ _private/ default /. dev-tool/ ocaml-lsp-server/ ocaml-lsp-server/ target/ bin
34+ $ TESTCASE_ROOT / _build/ _private/ default /. dev-tool/ odoc/ odoc/ target/ bin
35+ $ TESTCASE_ROOT / _build/ _private/ default /. dev-tool/ ocamlformat/ ocamlformat/ target/ bin
Original file line number Diff line number Diff line change 1+ Test that the ocamllsp dev tool can see the ocamlformat dev tool.
2+
3+ $ . .. / helpers. sh
4+ $ . ./ helpers. sh
5+
6+ $ mkrepo
7+ $ mkpkg ocaml 5.2 . 0
8+
9+ $ cat > dune-workspace << EOF
10+ > (lang dune 3.16 )
11+ > (lock_dir
12+ > (path " dev-tools.locks/ocaml-lsp-server" )
13+ > (repositories mock))
14+ > (lock_dir
15+ > (path " dev-tools.locks/ocamlformat" )
16+ > (repositories mock))
17+ > (lock_dir
18+ > (repositories mock))
19+ > (repository
20+ > (name mock)
21+ > (url " file://$(pwd)/mock-opam-repository" ))
22+ > EOF
23+
24+ Make a fake ocamllsp package that prints out the PATH variable:
25+ $ mkpkg ocaml-lsp-server << EOF
26+ > install: [
27+ > [ " sh" " -c" " echo '#!/bin/sh' > %{ bin} %/ocamllsp" ]
28+ > [ " sh" " -c" " echo 'echo fake ocamllsp will now run fake ocamlformat:' >> %{ bin} %/ocamllsp" ]
29+ > [ " sh" " -c" " echo 'ocamlformat' >> %{ bin} %/ocamllsp" ]
30+ > [ " sh" " -c" " chmod a+x %{ bin} %/ocamllsp" ]
31+ > ]
32+ > EOF
33+
34+ Make a fake ocamlformat
35+ $ mkpkg ocamlformat << EOF
36+ > install: [
37+ > [ " sh" " -c" " echo '#!/bin/sh' > %{ bin} %/ocamlformat" ]
38+ > [ " sh" " -c" " echo 'echo hello from fake ocamlformat' >> %{ bin} %/ocamlformat" ]
39+ > [ " sh" " -c" " chmod a+x %{ bin} %/ocamlformat" ]
40+ > ]
41+ > EOF
42+
43+ $ make_lockdir
44+ $ cat > dune. lock/ ocaml. pkg << EOF
45+ > (version 5.2 . 0)
46+ > EOF
47+
48+ $ dune tools install ocamlformat
49+ Solution for dev-tools. locks/ ocamlformat:
50+ - ocamlformat. 0. 0. 1
51+
52+ $ dune tools exec ocamllsp
53+ Solution for dev-tools. locks/ ocaml-lsp-server:
54+ - ocaml. 5. 2. 0
55+ - ocaml-lsp-server. 0. 0. 1
56+ Running ' ocamllsp'
57+ fake ocamllsp will now run fake ocamlformat:
58+ hello from fake ocamlformat
You can’t perform that action at this time.
0 commit comments