Commit 12fd7781 authored by vbot's avatar vbot Committed by Raphaël Proust

Test/Micheline: clean-up & refactor of the test suite

parent 2d0c98b2
......@@ -23,15 +23,49 @@
(* *)
(*****************************************************************************)
let fail loc expected given msg =
Format.kasprintf Pervasives.failwith
"@[@[%s]@] - @[%s@ expected: %s@ got: %s@]"
loc msg expected given
let fail loc printer given expected msg =
failwith
"@[<v 2> On %s : %s@ @[Given:\t%a@]@ @[Expected:\t%a@]@]"
loc msg printer given printer expected
let default_printer _ = ""
let default_printer fmt _ = Format.fprintf fmt ""
let equal ~loc ?(eq=(=)) ?(print=default_printer) ?(msg="") x y =
if not (eq x y) then fail loc (print x) (print y) msg
let equal ~loc ?(eq=(=)) ?(printer=default_printer) ?(msg="") given expected =
if not (eq given expected) then
fail loc printer given expected msg
else
return_unit
let not_equal ~loc ?(eq=(=)) ?(print=default_printer) ?(msg="") x y =
if (eq x y) then fail loc (print x) (print y) msg
let not_equal ~loc ?(eq=(=)) ?(printer=default_printer) ?(msg="") given expected =
if eq given expected then
fail loc printer given expected msg
else
return_unit
let pp_tokens fmt tokens =
let token_value_printer fmt token_value =
Format.fprintf fmt "@[%s@]"
(let open Micheline_parser in
match token_value with
String s -> Format.sprintf "String %S" s
| Bytes s -> Format.sprintf "Bytes %S" s
| Int s -> Format.sprintf "Int %S" s
| Ident s -> Format.sprintf "Ident %S" s
| Annot s -> Format.sprintf "Annot %S" s
| Comment s -> Format.sprintf "Comment %S" s
| Eol_comment s -> Format.sprintf "Eol_comment %S" s
| Semi -> Format.sprintf "Semi"
| Open_paren -> Format.sprintf "Open_paren"
| Close_paren -> Format.sprintf "Close_paren"
| Open_brace -> Format.sprintf "Open_brace"
| Close_brace -> Format.sprintf "Close_brace"
) in
Format.fprintf fmt "%a"
(Format.pp_print_list token_value_printer)
tokens
let equal_tokens ~loc given expected =
equal ~loc ~eq:(=) ~printer:pp_tokens ~msg:"Tokens are not equal" given expected
let not_equal_tokens ~loc given expected =
not_equal ~loc ~eq:(=) ~printer:pp_tokens ~msg:"Tokens are equal" given expected
(executables
(names test_michelson_parser)
(libraries tezos-base
tezos-rpc-http
tezos-shell-services
tezos-client-base
tezos-client-genesis
tezos-client-alpha
tezos-baking-alpha
tezos-client-base-unix
tezos-signer-backends
tezos-micheline
(names test_parser)
(libraries tezos-stdlib-unix
tezos-micheline
alcotest-lwt)
(flags (:standard -w -9-32 -safe-string
-open Tezos_base__TzPervasives
-open Tezos_micheline
-open Tezos_rpc_http
-open Tezos_shell_services
-open Tezos_client_base
-open Tezos_client_genesis
-open Tezos_client_alpha
-open Tezos_baking_alpha
-open Tezos_client_base_unix)))
-open Tezos_base__TzPervasives
-open Tezos_micheline
-open Tezos_stdlib_unix)))
(alias
(name buildtest)
(deps test_michelson_parser.exe))
(name buildtest)
(deps test_parser.exe))
(alias
(name runtest_michelson_parser)
(action (run %{exe:test_michelson_parser.exe})))
(name runtest_micheline_parser)
(action (run %{exe:test_parser.exe})))
(alias
(name runtest)
(deps (alias runtest_michelson_parser)))
(name runtest)
(deps (alias runtest_micheline_parser)))
(alias
(name runtest_indent)
(deps (glob_files *.ml{,i}))
(action (run bash %{libexec:tezos-stdlib:test-ocp-indent.sh} %{deps})))
(name runtest_indent)
(deps (glob_files *.ml{,i}))
(action
(run bash
%{libexec:tezos-stdlib:test-ocp-indent.sh} %{deps})))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment