From 623ebfc2daa0ada23f610a6dbb4e0ad19cb48420 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 1 May 2018 19:38:01 +0700 Subject: [PATCH] Add expectation test to parsing out of findlib toolchain config --- test/unit-tests/jbuild | 1 + test/unit-tests/tests.mlt | 35 ++++++++++++++++++++++++++++ test/unit-tests/toolchain.d/tlc.conf | 1 + 3 files changed, 37 insertions(+) create mode 100644 test/unit-tests/toolchain.d/tlc.conf diff --git a/test/unit-tests/jbuild b/test/unit-tests/jbuild index 729685a4..eae5a281 100644 --- a/test/unit-tests/jbuild +++ b/test/unit-tests/jbuild @@ -23,6 +23,7 @@ (deps (tests.mlt (glob_files ${SCOPE_ROOT}/src/.jbuilder.objs/*.cmi) (glob_files ${SCOPE_ROOT}/src/stdune/.stdune.objs/*.cmi) + (files_recursively_in toolchain.d) (files_recursively_in findlib-db))) (action (chdir ${SCOPE_ROOT} (progn diff --git a/test/unit-tests/tests.mlt b/test/unit-tests/tests.mlt index 0cded15a..c3fafb4e 100644 --- a/test/unit-tests/tests.mlt +++ b/test/unit-tests/tests.mlt @@ -77,3 +77,38 @@ val meta : Jbuilder.Meta.Simplified.t = ; subs = [] } |}] + +#install_printer Findlib.Config.pp;; + +let conf = + Findlib.Config.load (Path.of_string "test/unit-tests/toolchain") + ~toolchain:"tlc" ~context:"" + +[%%expect{| +val conf : Jbuilder.Findlib.Config.t = + { vars = + [ (FOO_BAR, { set_rules = + [ { preds_required = [ "tlc"; "env" ] + ; preds_forbidden = [] + ; value = "my variable" + } + ] + ; add_rules = [] + }) + ] + ; preds = [ "tlc" ] + } +|}] + +let env_pp fmt env = Sexp.pp fmt (Env.sexp_of_t env);; +#install_printer env_pp;; + +[%%expect{| +val env_pp : Format.formatter -> Jbuilder.Env.t -> unit = +|}] + +let env = Findlib.Config.env conf + +[%%expect{| +val env : Jbuilder.Env.t = ((FOO_BAR "my variable")) +|}] diff --git a/test/unit-tests/toolchain.d/tlc.conf b/test/unit-tests/toolchain.d/tlc.conf new file mode 100644 index 00000000..71f5150d --- /dev/null +++ b/test/unit-tests/toolchain.d/tlc.conf @@ -0,0 +1 @@ +FOO_BAR(tlc, env) = "my variable" \ No newline at end of file