Debian Codegraph @

otherlibs/dune-site/test/plugin_with_dot.t

raw
1 $ mkdir -p b c
2
3 $ for i in b; do
4 > mkdir -p $i
5 > cat >$i/dune-project <<EOF
6 > (lang dune 3.0)
7 > (using dune_site 0.1)
8 > (name $i)
9 > (package (name $i) (depends c))
10 > EOF
11 > done
12
13 $ for i in c; do
14 > mkdir -p $i
15 > cat >$i/dune-project <<EOF
16 > (lang dune 3.0)
17 > (using dune_site 0.1)
18 > (name $i)
19 > (package (name $i) (sites (share data) (lib plugins)))
20 > EOF
21 > done
22
23 $ cat >b/dune <<EOF
24 > (library
25 > (public_name b.b.b)
26 > (name b)
27 > (libraries c.register dune-site))
28 > (generate_sites_module (module sites) (sites b))
29 > (plugin (name c-plugins-b.b) (libraries b.b.b) (site (c plugins)))
30 > EOF
31
32 $ cat >b/b.ml <<EOF
33 > let v = "b"
34 > let () = Printf.printf "run b\n%!"
35 > let () = C_register.registered := "b"::!C_register.registered
36 > EOF
37
38 $ cat >c/dune <<EOF
39 > (executable
40 > (public_name c)
41 > (promote (until-clean))
42 > (modules c sites)
43 > (libraries c.register dune-site dune-site.plugins))
44 > (library
45 > (public_name c.register)
46 > (name c_register)
47 > (modules c_register))
48 > (generate_sites_module (module sites) (plugins (c plugins)))
49 > (rule
50 > (targets out.log)
51 > (deps (package c))
52 > (action (with-stdout-to out.log (run %{bin:c} "c-plugins-b.b"))))
53 > EOF
54
55 $ cat >c/c_register.ml <<EOF
56 > let registered : string list ref = ref []
57 > EOF
58
59 $ cat >c/c.ml <<EOF
60 > let () = try Sites.Plugins.Plugins.load Sys.argv.(1)
61 > with exn -> print_endline (Printexc.to_string exn)
62 > let () = Printf.printf "run c: registered:%s.\n%!" (String.concat "," !C_register.registered)
63 > EOF
64
65 $ cat > dune-project << EOF
66 > (lang dune 2.2)
67 > EOF
68
69 Build everything
70 ----------------
71
72 $ dune build
73
74 Test with dune exec
75 --------------------------------
76 $ dune exec -- c/c.exe "c-plugins-b.b"
77 run b
78 run c: registered:b.
79
80 Test error messages
81 --------------------------------
82 $ dune exec -- c/c.exe "inexistent"
83 The plugin "inexistent" can't be found in the search paths "$TESTCASE_ROOT/_build/install/default/lib/c/plugins".
84 run c: registered:.
85
86 $ cat >c/c.ml <<EOF
87 > let l = Lazy.force Dune_site.Private_.Helpers.ocamlpath
88 > let l = List.map (Printf.sprintf "OCAMLPATH=%s") l
89 > let () = print_string (String.concat ":" l)
90 > EOF
91
92 $ export BUILD_PATH_PREFIX_MAP="$(dune exe -- c/c.exe):$BUILD_PATH_PREFIX_MAP"
93
94 $ cat >c/c.ml <<EOF
95 > let () = try Dune_site_plugins.V1.load Sys.argv.(1)
96 > with exn -> print_endline (Printexc.to_string exn)
97 > EOF
98
99 $ dune exec -- c/c.exe "inexistent" 2>&1 | sed -e 's&default/lib:.*&default/lib:..."&g'
100 The library "inexistent" can't be found in the search paths "$TESTCASE_ROOT/_build/install/default/lib:..."
101
102 $ dune exec -- c/c.exe "b.b.b"
103 run b
104
105 $ dune exec -- c/c.exe "b.b.inexistent" 2>&1 | sed -e 's&default/lib:.*&default/lib:..."&g'
106 The sub-library "inexistent" can't be found in the library b.b in the search paths "$TESTCASE_ROOT/_build/install/default/lib:..."