62 lines
1.3 KiB
Plaintext
62 lines
1.3 KiB
Plaintext
(* -*- tuareg -*- *)
|
|
|
|
#warnings "-40";;
|
|
|
|
open Jbuilder
|
|
open Import
|
|
|
|
let print_pkg ppf pkg =
|
|
Format.fprintf ppf "<package:%s>" pkg.Findlib.name
|
|
;;
|
|
|
|
#install_printer print_pkg;;
|
|
|
|
[%%expect{|
|
|
val print_pkg : Format.formatter -> Jbuilder.Findlib.package -> unit = <fun>
|
|
|}]
|
|
|
|
let findlib =
|
|
let cwd = Path.absolute (Sys.getcwd ()) in
|
|
Findlib.create
|
|
~stdlib_dir:cwd
|
|
~path:[Path.relative cwd "test/unit-tests/findlib-db"]
|
|
;;
|
|
|
|
[%%expect{|
|
|
val findlib : Jbuilder.Findlib.t = <abstr>
|
|
|}]
|
|
|
|
let pkg = Findlib.find_exn findlib ~required_by:[] "foo";;
|
|
|
|
[%%expect{|
|
|
val pkg : Jbuilder.Findlib.package = <package:foo>
|
|
|}]
|
|
|
|
(* "foo" should depend on "baz" *)
|
|
pkg.requires;;
|
|
|
|
[%%expect{|
|
|
- : Jbuilder.Findlib.package list = [<package:baz>]
|
|
|}]
|
|
|
|
(* +-----------------------------------------------------------------+
|
|
| Meta parsing/simplification |
|
|
+-----------------------------------------------------------------+ *)
|
|
|
|
open Meta
|
|
|
|
let meta =
|
|
{ name = "foo"
|
|
; entries = Meta.load "test/unit-tests/findlib-db/foo/META"
|
|
}
|
|
|
|
[%%expect{|
|
|
val meta : Jbuilder.Meta.t =
|
|
{name = "foo";
|
|
entries =
|
|
[Rule {var = "requires"; predicates = []; action = Set; value = "bar"};
|
|
Rule
|
|
{var = "requires"; predicates = [Pos "ppx_driver"]; action = Set;
|
|
value = "baz"}]}
|
|
|}]
|