diff --git a/CHANGES.org b/CHANGES.org index 8c7da77d..941c7f6e 100644 --- a/CHANGES.org +++ b/CHANGES.org @@ -10,6 +10,11 @@ without =ppx_driver.runner= (#37). These problem should go away soon when we start using =--cookie= +- Fix the interpretation of META files when there is more than one + applicable assignment. Before this fix, the one with the lowest + number of formal predicates was selected instead of the one with the + biggest number of formal predicates + * 1.0+beta5 (22/03/2017) - When =ocamlfind= is present in the =PATH=, do not attempt to call diff --git a/src/findlib.ml b/src/findlib.ml index 9036e632..3f5325e7 100644 --- a/src/findlib.ml +++ b/src/findlib.ml @@ -70,9 +70,9 @@ end (* Set of rules for a given variable of a package *) module Rules = struct - (* To implement the algorithm described in [1], [set_rules] is sorted by number of format - predicates, then according to the order of the META file. [add_rules] are in the same - order as in the META file. + (* To implement the algorithm described in [1], [set_rules] is sorted by decreasing + number of formal predicates, then according to the order of the META + file. [add_rules] are in the same order as in the META file. [1] http://projects.camlcity.org/projects/dl/findlib-1.6.3/doc/ref-html/r729.html *) type t = @@ -101,7 +101,7 @@ module Rules = struct let set_rules = List.map rules.set_rules ~f:Rule.make |> List.stable_sort ~cmp:(fun a b -> - compare (Rule.formal_predicates_count a) (Rule.formal_predicates_count b)) + compare (Rule.formal_predicates_count b) (Rule.formal_predicates_count a)) in { add_rules; set_rules } end diff --git a/test/expect-tests/expect_test.mll b/test/expect-tests/expect_test.mll index e4625dc8..aa3ae112 100644 --- a/test/expect-tests/expect_test.mll +++ b/test/expect-tests/expect_test.mll @@ -107,7 +107,7 @@ let main () = let corrected_fn = fn ^ ".corrected" in (* Temporary hack: *) - Sys.chdir "../.."; + (* Sys.chdir "../.."; *) if txt <> res then begin let oc = open_out_bin corrected_fn in output_string oc res; diff --git a/test/expect-tests/tests.mlt b/test/expect-tests/tests.mlt index 77dff60f..55499eaa 100644 --- a/test/expect-tests/tests.mlt +++ b/test/expect-tests/tests.mlt @@ -3,6 +3,7 @@ #warnings "-40";; open Jbuilder +open Import let print_pkg ppf pkg = Format.fprintf ppf "" pkg.Findlib.name @@ -35,5 +36,26 @@ val pkg : Jbuilder.Findlib.package = pkg.requires;; [%%expect{| -- : Jbuilder.Findlib.package list = [] +- : Jbuilder.Findlib.package list = [] +|}] + +(* +-----------------------------------------------------------------+ + | Meta parsing/simplification | + +-----------------------------------------------------------------+ *) + +open Meta + +let meta = + { name = "foo" + ; entries = Meta.load "test/expect-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"}]} |}]