From 388fc4c1836abec25ad6d53dab48e361cef19d5b Mon Sep 17 00:00:00 2001 From: Lucas Randazzo Date: Mon, 26 Feb 2024 10:43:30 +0100 Subject: [PATCH] Snoop: fix standard output not appearing --- manifest/main.ml | 9 ++-- opam/octez-protocol-alpha-libs.opam | 3 +- src/lib_benchmark/format.ml | 13 ----- .../lib_protocol/test/helpers/dune | 5 +- .../lib_protocol/test/helpers/scenario_dsl.ml | 53 +++++++++++++------ .../integration/test_scenario_autostaking.ml | 3 +- .../test/integration/test_scenario_base.ml | 4 +- .../test/integration/test_scenario_rewards.ml | 3 +- .../integration/test_scenario_slashing.ml | 3 +- .../test/integration/test_scenario_stake.ml | 4 +- 10 files changed, 50 insertions(+), 50 deletions(-) delete mode 100644 src/lib_benchmark/format.ml diff --git a/manifest/main.ml b/manifest/main.ml index 874a6d863bd8..cfb30afff2cc 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -6202,18 +6202,17 @@ let hash = Protocol.hash only_if active @@ fun () -> octez_protocol_lib "test-helpers" - ~path: - (if active then path // "lib_protocol/test/helpers" - else path // "lib_protocol") + ~path:(path // "lib_protocol/test/helpers") ~internal_name:(sf "tezos_%s_test_helpers" name_underscore) ~synopsis:"Protocol testing framework" ~opam_only_deps:[octez_protocol_environment; parameters |> if_some] ~deps: [ tezt_core_lib |> if_ N.(number >= 019) |> open_ |> open_ ~m:"Base"; - alcotezt |> if_ N.(number >= 019); + alcotezt |> if_ N.(number == 019); + tezt_tezos |> if_ N.(number >= 020); tezt_lib |> if_ N.(number >= 019); - octez_base_test_helpers |> if_ N.(number >= 019) |> open_; + octez_base_test_helpers |> if_ N.(number == 019) |> open_; qcheck_alcotest; octez_test_helpers; octez_base |> open_ ~m:"TzPervasives" diff --git a/opam/octez-protocol-alpha-libs.opam b/opam/octez-protocol-alpha-libs.opam index 3f654a0561db..988ff93938c0 100644 --- a/opam/octez-protocol-alpha-libs.opam +++ b/opam/octez-protocol-alpha-libs.opam @@ -16,7 +16,7 @@ depends: [ "octez-shell-libs" "uri" { >= "3.1.0" } "tezt" { >= "4.0.0" & < "5.0.0" } - "octez-alcotezt" + "tezt-tezos" "qcheck-alcotest" { >= "0.20" } "octez-proto-libs" "octez-version" @@ -30,6 +30,7 @@ depends: [ "tezos-dac-client-lib" "octez-injector" "octez-l2-libs" + "octez-alcotezt" {with-test} "tezos-dac-node-lib" {with-test} ] build: [ diff --git a/src/lib_benchmark/format.ml b/src/lib_benchmark/format.ml deleted file mode 100644 index 310366d2a83e..000000000000 --- a/src/lib_benchmark/format.ml +++ /dev/null @@ -1,13 +0,0 @@ -(*****************************************************************************) -(* *) -(* SPDX-License-Identifier: MIT *) -(* Copyright (c) 2024 Nomadic Labs, *) -(* *) -(*****************************************************************************) - -include Stdlib.Format - -let err_formatter = Stdlib.Format.formatter_of_out_channel Stdlib.stderr - -let eprintf (fmt : ('a, formatter, unit) format) : 'a = - Stdlib.Format.fprintf err_formatter fmt diff --git a/src/proto_alpha/lib_protocol/test/helpers/dune b/src/proto_alpha/lib_protocol/test/helpers/dune index 44f497de504e..a0289674cc39 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/dune +++ b/src/proto_alpha/lib_protocol/test/helpers/dune @@ -7,9 +7,8 @@ (instrumentation (backend bisect_ppx)) (libraries tezt.core - octez-alcotezt + tezt-tezos tezt - octez-libs.base-test-helpers qcheck-alcotest octez-libs.test-helpers octez-libs.base @@ -28,8 +27,6 @@ (:standard) -open Tezt_core -open Tezt_core.Base - -open Octez_alcotezt - -open Tezos_base_test_helpers -open Tezos_base.TzPervasives -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals -open Tezos_micheline diff --git a/src/proto_alpha/lib_protocol/test/helpers/scenario_dsl.ml b/src/proto_alpha/lib_protocol/test/helpers/scenario_dsl.ml index efaa8c6986f4..efb4686a6592 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/scenario_dsl.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/scenario_dsl.ml @@ -66,20 +66,43 @@ let rec run_scenario : let* result = action input in run_scenario next result +type test_closure = string * bool * (Tezt_tezos.Protocol.t -> unit Lwt.t) + let unfolded_to_test : - (unit, unit) single_scenario * string list * bool -> - unit Alcotest_lwt.test_case = - fun (s, name, b) -> - let speed = if b then `Slow else `Quick in - let name = - match name with - | [] -> "" - | [n] -> n - | title :: tags -> - (* We chose to separate all tags with a comma, and use the head tag as a title for the test *) - title ^ ": " ^ String.concat ", " tags - in - Tztest.tztest name speed (run_scenario s) + (unit, unit) single_scenario * string list * bool -> test_closure = + let open Lwt_syntax in + fun (s, title, is_slow) -> + let title = + match title with + | [] -> "" + | [n] -> n + | header :: tags -> + (* We chose to separate all tags with a comma, and use the head tag as a header for the test *) + header ^ ": " ^ String.concat ", " tags + in + ( title, + is_slow, + fun _proto -> + let* _ = (run_scenario s) () in + return_unit ) + +let register_test ~__FILE__ ~tags ((title, is_slow, test) : test_closure) : unit + = + let tags = if is_slow then Tezos_test_helpers.Tag.slow :: tags else tags in + Tezt_tezos.Protocol.( + register_test + ~__FILE__ + ~title + ~tags + ~uses:(fun _ -> []) + ~uses_node:false + ~uses_client:false + ~uses_admin_client:false + test + [Alpha]) + +let register_tests ~__FILE__ ~tags (l : test_closure list) : unit = + List.iter (register_test ~__FILE__ ~tags) l (** Useful aliases and operators *) @@ -129,9 +152,9 @@ let end_test : ('a, unit) scenarios = Log.info ~color:begin_end_color "-- End test --" ; return_unit) -(** Transforms scenarios into Alcotest tests *) +(** Transforms scenarios into tests *) let tests_of_scenarios : - (string * (unit, 't) scenarios) list -> unit Alcotest_lwt.test_case list = + (string * (unit, 't) scenarios) list -> test_closure list = fun scenarios -> List.map (fun (s, x) -> Tag s --> x --> end_test) scenarios |> function | [] -> [] diff --git a/src/proto_alpha/lib_protocol/test/integration/test_scenario_autostaking.ml b/src/proto_alpha/lib_protocol/test/integration/test_scenario_autostaking.ml index 8c6ce71b2798..2239559e442c 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_scenario_autostaking.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_scenario_autostaking.ml @@ -186,5 +186,4 @@ let tests = ] let () = - Alcotest_lwt.run ~__FILE__ Protocol.name [("protocol autostaking", tests)] - |> Lwt_main.run + register_tests ~__FILE__ ~tags:["protocol"; "scenario"; "autostaking"] tests diff --git a/src/proto_alpha/lib_protocol/test/integration/test_scenario_base.ml b/src/proto_alpha/lib_protocol/test/integration/test_scenario_base.ml index 9d0248d64af9..d4f8a14ae732 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_scenario_base.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_scenario_base.ml @@ -139,6 +139,4 @@ let tests = ("Test init", init_scenario () --> Action (fun _ -> return_unit)); ] -let () = - Alcotest_lwt.run ~__FILE__ Protocol.name [("protocol scenario base", tests)] - |> Lwt_main.run +let () = register_tests ~__FILE__ ~tags:["protocol"; "scenario"; "base"] tests diff --git a/src/proto_alpha/lib_protocol/test/integration/test_scenario_rewards.ml b/src/proto_alpha/lib_protocol/test/integration/test_scenario_rewards.ml index d25e1fc65b69..4a042ae3452a 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_scenario_rewards.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_scenario_rewards.ml @@ -156,5 +156,4 @@ let tests = ] let () = - Alcotest_lwt.run ~__FILE__ Protocol.name [("protocol rewards", tests)] - |> Lwt_main.run + register_tests ~__FILE__ ~tags:["protocol"; "scenario"; "rewards"] tests diff --git a/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing.ml b/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing.ml index ff26ffb6a0d4..5e85c36b61d5 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing.ml @@ -448,5 +448,4 @@ let tests = ] let () = - Alcotest_lwt.run ~__FILE__ Protocol.name [("protocol slashing", tests)] - |> Lwt_main.run + register_tests ~__FILE__ ~tags:["protocol"; "scenario"; "slashing"] tests diff --git a/src/proto_alpha/lib_protocol/test/integration/test_scenario_stake.ml b/src/proto_alpha/lib_protocol/test/integration/test_scenario_stake.ml index 74f51dbb8b56..f5474e2eeaa4 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_scenario_stake.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_scenario_stake.ml @@ -290,6 +290,4 @@ let tests = ("Test stake from unstake", shorter_roundtrip_for_baker); ] -let () = - Alcotest_lwt.run ~__FILE__ Protocol.name [("protocol stake unstake", tests)] - |> Lwt_main.run +let () = register_tests ~__FILE__ ~tags:["protocol"; "scenario"; "stake"] tests -- GitLab