Debian Codegraph @

otherlibs/dune-site/test/opam-uninstall.t

raw
1 Test an approximation of an OPAM install / uninstall of a plugin package
2
3 This takes the sites-plugin.t blackbox test extracted from the manual and
4 changes its end to cover:
5 - dune install of both the application and its plugin,
6 - dune uninstall of the plugin, leaving an empty directory as OPAM would.
7
8 $ cat > dune-project <<EOF
9 > (lang dune 3.8)
10 > (using dune_site 0.1)
11 > (name app)
12 >
13 > (package
14 > (name app)
15 > (sites (lib plugins)))
16 > EOF
17
18 $ cat > dune <<EOF
19 > (executable
20 > (public_name app)
21 > (modules sites app)
22 > (libraries app.register dune-site dune-site.plugins))
23 >
24 > (library
25 > (public_name app.register)
26 > (name registration)
27 > (modules registration))
28 >
29 > (generate_sites_module
30 > (module sites)
31 > (plugins (app plugins)))
32 > EOF
33
34 $ cat > registration.ml <<EOF
35 > let todo : (unit -> unit) Queue.t = Queue.create ()
36 > EOF
37
38 $ cat > app.ml <<EOF
39 > (* load all the available plugins *)
40 > let () = Sites.Plugins.Plugins.load_all ()
41 >
42 > let () = print_endline "Main app starts..."
43 > (* Execute the code registered by the plugins *)
44 > let () = Queue.iter (fun f -> f ()) Registration.todo
45 > EOF
46
47
48 $ mkdir plugin
49 $ cat > plugin/dune-project <<EOF
50 > (lang dune 3.8)
51 > (using dune_site 0.1)
52 >
53 > (generate_opam_files true)
54 >
55 > (package
56 > (name plugin1))
57 > EOF
58
59 $ cat > plugin/dune <<EOF
60 > (library
61 > (public_name plugin1.plugin1_impl)
62 > (name plugin1_impl)
63 > (modules plugin1_impl)
64 > (libraries app.register))
65 >
66 > (plugin
67 > (name plugin1)
68 > (libraries plugin1.plugin1_impl)
69 > (site (app plugins)))
70 > EOF
71
72 $ cat > plugin/plugin1_impl.ml <<EOF
73 > let () =
74 > print_endline "Registration of Plugin1";
75 > Queue.add (fun () -> print_endline "Plugin1 is doing something...") Registration.todo
76 > EOF
77
78 $ dune build @install
79 $ dune install --prefix _install
80
81 $ OCAMLPATH=_install/lib:$OCAMLPATH _install/bin/app
82 Registration of Plugin1
83 Main app starts...
84 Plugin1 is doing something...
85
86 $ dune uninstall --prefix _install plugin1
87
88 Unfortunately, the fact that the `lib/app/plugins/plugin1` directory should be
89 removed along with plugin1 is lost in the OPAM metadata, so we simulate this
90 issue by recreating this empty directory.
91
92 $ mkdir -p _install/lib/app/plugins/plugin1
93
94 $ OCAMLPATH=_install/lib:$OCAMLPATH _install/bin/app
95 Main app starts...
96