Skip to content

Commit 1b91a6e

Browse files
committed
test: switching to custom lock dir
Signed-off-by: Ali Caglayan <[email protected]>
1 parent 308cde2 commit 1b91a6e

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
This test checks what happens when you lock with default directory then change
2+
workspace to use a custom lock directory.
3+
4+
$ . ./helpers.sh
5+
$ mkrepo
6+
$ mkpkg foo
7+
$ add_mock_repo_if_needed
8+
9+
$ cat > dune-project <<EOF
10+
> (lang dune 3.21)
11+
> (package
12+
> (name myproject)
13+
> (depends foo))
14+
> EOF
15+
16+
Lock with default directory name:
17+
18+
$ dune pkg lock
19+
Solution for dune.lock
20+
21+
Dependencies common to all supported platforms:
22+
- foo.0.0.1
23+
24+
Now change the workspace to use a custom lock directory:
25+
26+
$ cat > dune-workspace <<EOF
27+
> (lang dune 3.21)
28+
> (lock_dir
29+
> (path custom.lock)
30+
> (repositories mock))
31+
> (repository
32+
> (name mock)
33+
> (url "file://$PWD/mock-opam-repository"))
34+
> EOF
35+
36+
$ cat > dune <<EOF
37+
> (executable
38+
> (public_name bar))
39+
> EOF
40+
41+
$ cat > bar.ml <<EOF
42+
> let () = print_endline "hello from bar" ;;
43+
> EOF
44+
45+
$ dune exec -- bar
46+
Error: No rule found for default/.lock/dune.lock (context _private)
47+
-> required by lock directory environment for context "default"
48+
-> required by base environment for context "default"
49+
-> required by loading findlib for context "default"
50+
-> required by creating installed environment for "default"
51+
[1]
52+
53+
Now try with a context stanza that references the custom lock directory with a
54+
context stanza:
55+
56+
$ cat > dune-workspace <<EOF
57+
> (lang dune 3.21)
58+
> (context
59+
> (default
60+
> (lock_dir custom.lock)))
61+
> (lock_dir
62+
> (path custom.lock)
63+
> (repositories mock))
64+
> (repository
65+
> (name mock)
66+
> (url "file://$PWD/mock-opam-repository"))
67+
> EOF
68+
69+
This is working as intended. The error is not relevant here.
70+
71+
$ dune exec -- bar
72+
hello from bar

0 commit comments

Comments
 (0)