Micheline: fix dependencies in opam/dune

This commit is contained in:
Raphaël Proust 2019-02-21 11:55:10 +08:00
parent e4e30bb3d8
commit f6f047ea15
4 changed files with 32 additions and 8 deletions

View File

@ -23,6 +23,32 @@
(* *) (* *)
(*****************************************************************************) (*****************************************************************************)
(* Mini compatibility layer to avoid circular dependency *)
module Compat = struct
let failwith fmt = Format.kasprintf (fun s -> Lwt.return (Error s)) fmt
let return_unit = Lwt.return (Ok ())
let (>>=) = Lwt.bind
let (>>=?) v f =
v >>= function
| Error _ as err -> Lwt.return err
| Ok v -> f v
let rec iter2_p f l1 l2 =
match l1, l2 with
| [], [] -> return_unit
| [], _ | _, [] -> invalid_arg "Error_monad.iter2_p"
| x1 :: l1 , x2 :: l2 ->
let tx = f x1 x2 and tl = iter2_p f l1 l2 in
tx >>= fun tx_res ->
tl >>= fun tl_res ->
match tx_res, tl_res with
| Ok (), Ok () -> Lwt.return (Ok ())
| Error exn1, Error exn2 -> failwith "%s -- %s" exn1 exn2
| Ok (), Error exn
| Error exn, Ok () -> Lwt.return (Error exn)
end
open Compat
let fail loc printer given expected msg = let fail loc printer given expected msg =
failwith failwith
"@[<v 2> On %s : %s@ @[Given:\t%a@]@ @[Expected:\t%a@]@]" "@[<v 2> On %s : %s@ @[Given:\t%a@]@ @[Expected:\t%a@]@]"

View File

@ -1,12 +1,9 @@
(executables (executables
(names test_parser) (names test_parser)
(libraries tezos-stdlib-unix (libraries tezos-micheline
tezos-micheline
alcotest-lwt) alcotest-lwt)
(flags (:standard -w -9-32 -safe-string (flags (:standard -w -9-32 -safe-string
-open Tezos_base__TzPervasives -open Tezos_micheline)))
-open Tezos_micheline
-open Tezos_stdlib_unix)))
(alias (alias
(name buildtest) (name buildtest)

View File

@ -27,6 +27,8 @@
(* Token value *) (* Token value *)
(****************************************************************************) (****************************************************************************)
open Assert.Compat
let assert_tokenize ~loc given expected = let assert_tokenize ~loc given expected =
match Micheline_parser.tokenize given with match Micheline_parser.tokenize given with
| tokens, [] -> | tokens, [] ->
@ -454,9 +456,7 @@ let wrap (n, f) =
Alcotest_lwt.test_case n `Quick begin fun _ () -> Alcotest_lwt.test_case n `Quick begin fun _ () ->
f () >>= function f () >>= function
| Ok () -> Lwt.return_unit | Ok () -> Lwt.return_unit
| Error err -> | Error err -> Lwt.fail_with err
Tezos_stdlib_unix.Logging_unix.close () >>= fun () ->
Lwt.fail_with (Format.asprintf "%a" pp_print_error err)
end end
let () = let () =

View File

@ -11,6 +11,7 @@ depends: [
"tezos-data-encoding" "tezos-data-encoding"
"tezos-error-monad" "tezos-error-monad"
"uutf" "uutf"
"alcotest-lwt" { with-test }
] ]
build: [ build: [
[ "dune" "build" "-p" name "-j" jobs ] [ "dune" "build" "-p" name "-j" jobs ]