From 798169c76c20d796b833310ea0b607239f28c8bb Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Tue, 24 Jan 2023 13:46:09 +0100 Subject: [PATCH 1/8] Tezt/lib_tezos: fix documentation error in [Michelson_script] --- tezt/lib_tezos/michelson_script.mli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tezt/lib_tezos/michelson_script.mli b/tezt/lib_tezos/michelson_script.mli index b30149ea199b..d566cc8887fc 100644 --- a/tezt/lib_tezos/michelson_script.mli +++ b/tezt/lib_tezos/michelson_script.mli @@ -87,7 +87,7 @@ val default_prefix : string val find : ?prefix:string -> ?maxdepth:int -> string list -> Protocol.t -> t (** [find_all ?prefix ?maxdepth protocol] returns all Michelson scripts for a given - protocol respecting [filter] up to a maxdepth [maxdepth]. Setting [~maxdepth:1] + protocol up to a maxdepth [maxdepth]. Setting [~maxdepth:1] is useful when you don't want to recurse into subdirectories. For instance, assume the following files exist: -- GitLab From 84ca0d0f9c512251546e3ffee18d38805f6ba140 Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Tue, 24 Jan 2023 13:46:28 +0100 Subject: [PATCH 2/8] Tezt/lib_tezos: add [find_all_in] to [Michelson_script] --- tezt/lib_tezos/michelson_script.ml | 3 +++ tezt/lib_tezos/michelson_script.mli | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/tezt/lib_tezos/michelson_script.ml b/tezt/lib_tezos/michelson_script.ml index 0fd860cf7a2c..8eea2b95cdce 100644 --- a/tezt/lib_tezos/michelson_script.ml +++ b/tezt/lib_tezos/michelson_script.ml @@ -309,6 +309,9 @@ let whitelist dirs ts = |> List.filter @@ fun (t : t) -> List.exists (fun dir -> List.equal String.equal dir t.dirname) dirs +let find_all_in ?prefix ?maxdepth protocol dirs = + find_all ?prefix ?maxdepth protocol |> whitelist [dirs] + let find_all_legacy ?prefix ?maxdepth protocol = find_all ?prefix ?maxdepth protocol |> whitelist [["legacy"]] diff --git a/tezt/lib_tezos/michelson_script.mli b/tezt/lib_tezos/michelson_script.mli index d566cc8887fc..26323013921e 100644 --- a/tezt/lib_tezos/michelson_script.mli +++ b/tezt/lib_tezos/michelson_script.mli @@ -115,6 +115,10 @@ val find_all_res : Protocol.t -> (t list, string * string) result +(** [find_all_in protocol dirs] returns all scripts in the folders [dirs] for the given protocol. *) +val find_all_in : + ?prefix:string -> ?maxdepth:int -> Protocol.t -> string list -> t list + (** Returns all scripts in the [legacy] directory for the given protocol. *) val find_all_legacy : ?prefix:string -> ?maxdepth:int -> Protocol.t -> t list -- GitLab From b348445690f630e09f465c1737e152e38c7ca3a1 Mon Sep 17 00:00:00 2001 From: Arvid Jakobsson Date: Tue, 24 Jan 2023 13:47:40 +0100 Subject: [PATCH 3/8] Tezt/lib_tezos: add [expand_macros] to [Client] --- tezt/lib_tezos/client.ml | 45 +++++++++++++++++++++++++++------------ tezt/lib_tezos/client.mli | 21 ++++++++++++++++++ 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/tezt/lib_tezos/client.ml b/tezt/lib_tezos/client.ml index 80623d17c188..20b7479ac7ad 100644 --- a/tezt/lib_tezos/client.ml +++ b/tezt/lib_tezos/client.ml @@ -164,7 +164,7 @@ let mode_arg client = let spawn_command ?log_command ?log_status_on_exit ?log_output ?(env = String_map.empty) ?endpoint ?hooks ?(admin = false) ?protocol_hash - ?config_file client command = + ?config_file ?(no_base_dir_warnings = false) client command = let env = (* Set disclaimer to "Y" if unspecified, otherwise use given value *) String_map.update @@ -174,6 +174,9 @@ let spawn_command ?log_command ?log_status_on_exit ?log_output in let protocol_arg = optional_arg "protocol" Fun.id protocol_hash in let config_file_arg = optional_arg "config-file" Fun.id config_file in + let no_base_dir_warnings_arg = + optional_switch "no-base-dir-warnings" no_base_dir_warnings + in Process.spawn ?runner:client.runner ~name:client.name @@ -186,7 +189,7 @@ let spawn_command ?log_command ?log_status_on_exit ?log_output (if admin then client.admin_path else client.path) @@ endpoint_arg ?endpoint client @ protocol_arg @ media_type_arg client.mode @ mode_arg client - @ base_dir_arg client @ config_file_arg @ command + @ base_dir_arg client @ config_file_arg @ no_base_dir_warnings_arg @ command let spawn_command_with_stdin ?log_command ?log_status_on_exit ?log_output ?(env = String_map.empty) ?endpoint ?hooks ?(admin = false) ?protocol_hash @@ -1578,12 +1581,11 @@ let stresstest ?endpoint ?source_aliases ?source_pkhs ?source_accounts ?seed client |> Process.check -let spawn_run_script ?hooks ?protocol_hash ?(no_base_dir_warnings = false) - ?balance ?self_address ?source ?payer ?gas ?(trace_stack = false) ?level - ~prg ~storage ~input client = - spawn_command ?hooks ?protocol_hash client - @@ optional_switch "no-base-dir-warnings" no_base_dir_warnings - @ ["run"; "script"; prg; "on"; "storage"; storage; "and"; "input"; input] +let spawn_run_script ?hooks ?protocol_hash ?no_base_dir_warnings ?balance + ?self_address ?source ?payer ?gas ?(trace_stack = false) ?level ~prg + ~storage ~input client = + spawn_command ?hooks ?protocol_hash ?no_base_dir_warnings client + @@ ["run"; "script"; prg; "on"; "storage"; storage; "and"; "input"; input] @ optional_arg "payer" Fun.id payer @ optional_arg "source" Fun.id source @ optional_arg "balance" Tez.to_string balance @@ -1843,15 +1845,14 @@ let normalize_type ?hooks ~typ client = let typecheck_data ~data ~typ ?gas ?(legacy = false) client = spawn_typecheck_data ~data ~typ ?gas ~legacy client |> Process.check -let spawn_typecheck_script ?hooks ?protocol_hash ~script - ?(no_base_dir_warnings = false) ?(details = false) ?(emacs = false) - ?(no_print_source = false) ?gas ?(legacy = false) client = +let spawn_typecheck_script ?hooks ?protocol_hash ~script ?no_base_dir_warnings + ?(details = false) ?(emacs = false) ?(no_print_source = false) ?gas + ?(legacy = false) client = let gas_cmd = Option.map Int.to_string gas |> Option.map (fun g -> ["--gas"; g]) in - spawn_command ?hooks ?protocol_hash client - @@ optional_switch "no-base-dir-warnings" no_base_dir_warnings - @ ["typecheck"; "script"; script] + spawn_command ?hooks ?protocol_hash ?no_base_dir_warnings client + @@ ["typecheck"; "script"; script] @ Option.value ~default:[] gas_cmd @ (if details then ["--details"] else []) @ (if emacs then ["--emacs"] else []) @@ -3940,3 +3941,19 @@ let prepare_multisig_transaction_set_threshold_and_public_keys ~multisig |> Process.check_and_read_stdout in return (String.trim client_output) + +let spawn_expand_macros ?endpoint ?hooks ?protocol_hash ?no_base_dir_warnings + client path = + spawn_command ?endpoint ?hooks ?protocol_hash ?no_base_dir_warnings client + @@ ["expand"; "macros"; "in"; path] + +let expand_macros ?endpoint ?hooks ?protocol_hash ?no_base_dir_warnings client + path = + spawn_expand_macros + ?endpoint + ?hooks + ?protocol_hash + ?no_base_dir_warnings + client + path + |> Process.check_and_read_stdout diff --git a/tezt/lib_tezos/client.mli b/tezt/lib_tezos/client.mli index 9e0c51318e8f..8209b9fe851b 100644 --- a/tezt/lib_tezos/client.mli +++ b/tezt/lib_tezos/client.mli @@ -2370,6 +2370,7 @@ val spawn_command : ?admin:bool -> ?protocol_hash:string -> ?config_file:string -> + ?no_base_dir_warnings:bool -> t -> string list -> Process.t @@ -2836,3 +2837,23 @@ val spawn_prepare_multisig_transaction_set_threshold_and_public_keys : ?bytes_only:bool -> t -> Process.t + +(** Run [tezos-client expand macros in