diff --git a/manifest/main.ml b/manifest/main.ml index 2bcf8e723d374d4b2a72ae5f9e5426d1a1fcf290..1e6c7067b6af06f3fc4ff6e8644b076491822a3d 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -458,6 +458,7 @@ let octez_test_helpers = ~deps:[uri; fmt; qcheck_alcotest; lwt; pure_splitmix; data_encoding] ~js_compatible:true ~linkall:true + ~release_status:Released ~dune: Dune. [ @@ -1713,7 +1714,7 @@ let octez_event_logging_test_helpers = octez_error_monad |> open_ |> open_ ~m:"TzLwtreslib"; octez_event_logging |> open_; octez_test_helpers |> open_; - alcotest; + alcotezt; ] ~js_compatible:true ~linkall:true @@ -1942,12 +1943,12 @@ let octez_base_test_helpers = octez_stdlib_unix; octez_event_logging_test_helpers; octez_test_helpers |> open_; - alcotest; - alcotest_lwt; + alcotezt; qcheck_alcotest; ] ~linkall:true ~bisect_ppx:No + ~release_status:Released let octez_context_sigs = public_lib @@ -2337,8 +2338,10 @@ let _octez_p2p_tests = "test_p2p_connect_handler"; "test_p2p_maintenance"; ] + ~bisect_ppx:With_sigterm ~path:"src/lib_p2p/test" ~opam:"tezos-p2p" + ~locks:"/locks/p2p" ~deps: [ octez_base |> open_ ~m:"TzPervasives"; @@ -2352,74 +2355,9 @@ let _octez_p2p_tests = octez_p2p_test_common |> open_; octez_p2p_services |> open_; tezt_tezos; - alcotest_lwt; + alcotezt; astring; ] - ~linkall:true - ~alias:"" - ~dune: - Dune.( - (* At the termination of the tests, or if an unexpected - error occurs, detached processes are terminated through a - SIGKILL. - See https://github.com/aantron/bisect_ppx/blob/master/doc/advanced.md#SIGTERM - See https://gitlab.com/tezos/tezos/-/issues/1946 *) - let run_exe prog args = - setenv "BISECT_SIGTERM" "yes" @@ run_exe prog args - in - [ - alias_rule - "runtest_p2p_pool" - ~locks:"/ports/49152-65535" - ~action:(run_exe "test_p2p_pool" []); - alias_rule - "runtest_p2p_broadcast" - ~locks:"/ports/49152-65535" - ~action:(run_exe "test_p2p_broadcast" []); - alias_rule - "runtest_p2p_io_scheduler" - ~locks:"/ports/49152-65535" - ~action:(run_exe "test_p2p_io_scheduler" []); - alias_rule - "runtest_p2p_socket" - ~locks:"/ports/49152-65535" - ~action:(run_exe "test_p2p_socket" []); - alias_rule - "runtest_p2p_node" - ~locks:"/ports/49152-65535" - ~action:(run_exe "test_p2p_node" []); - alias_rule - "runtest_p2p_peerset" - ~action:(run_exe "test_p2p_peerset" []); - alias_rule - "runtest_p2p_buffer_reader" - ~action:(run_exe "test_p2p_buffer_reader" []); - alias_rule - "runtest_p2p_banned_peers" - ~action:(run_exe "test_p2p_banned_peers" []); - alias_rule - "runtest_p2p_connect_handler" - ~action:(run_exe "test_p2p_connect_handler" []); - alias_rule - "runtest_p2p_maintenance" - ~action:(run_exe "test_p2p_maintenance" []); - alias_rule - "runtest" - ~package:"tezos-p2p" - ~alias_deps: - [ - "runtest_p2p_socket"; - "runtest_p2p_pool"; - "runtest_p2p_broadcast"; - "runtest_p2p_io_scheduler"; - "runtest_p2p_peerset"; - "runtest_p2p_buffer_reader"; - "runtest_p2p_banned_peers"; - "runtest_p2p_node"; - "runtest_p2p_connect_handler"; - "runtest_p2p_maintenance"; - ]; - ]) let octez_gossipsub = public_lib diff --git a/manifest/manifest.ml b/manifest/manifest.ml index fe1a23403b298f371489af71c925c8057431a7db..116e62fa47498b66eed2e5a35031456cc2d6e8b4 100644 --- a/manifest/manifest.ml +++ b/manifest/manifest.ml @@ -330,7 +330,7 @@ module Dune = struct let glob_files_rec expr = [S "glob_files_rec"; S expr] - let runtest ?(alias = "runtest") ?action ?package ~dep_files ~dep_globs + let runtest ?(alias = "runtest") ?action ?package ?locks ~dep_files ~dep_globs ~dep_globs_rec name = let deps_dune = let files = List.map (fun s -> S s) dep_files in @@ -343,12 +343,20 @@ module Dune = struct let action = Option.value ~default:[S "run"; S ("%{dep:./" ^ name ^ ".exe}")] action in - alias_rule alias ?package ?deps_dune ~action + alias_rule alias ?package ?deps_dune ?locks ~action - let runtest_js ?(alias = "runtest_js") ?package ~dep_files ~dep_globs + let runtest_js ?(alias = "runtest_js") ?package ?locks ~dep_files ~dep_globs ~dep_globs_rec name = let action = [S "run"; S "node"; S ("%{dep:./" ^ name ^ ".bc.js}")] in - runtest ~alias ~action ?package ~dep_files ~dep_globs ~dep_globs_rec name + runtest + ~alias + ~action + ?package + ?locks + ~dep_files + ~dep_globs + ~dep_globs_rec + name let setenv name value followup = [G [S "setenv"; S name; S value]; followup] @@ -999,6 +1007,7 @@ module Target = struct | Test_executable of { names : string Ne_list.t; runtest_alias : string option; + locks : string option; } type preprocessor_dep = File of string @@ -1525,7 +1534,8 @@ module Target = struct | Some modes -> List.mem Dune.Native modes in match (kind, opam, dep_files) with - | Test_executable {names; runtest_alias = Some alias}, package, _ -> + | Test_executable {names; runtest_alias = Some alias; locks}, package, _ + -> let runtest_js_rules = if run_js then List.map @@ -1535,6 +1545,7 @@ module Target = struct ~dep_files ~dep_globs ~dep_globs_rec + ?locks ?package name) (Ne_list.to_list names) @@ -1549,13 +1560,16 @@ module Target = struct ~dep_files ~dep_globs ~dep_globs_rec + ?locks ?package name) (Ne_list.to_list names) else [] in runtest_rules @ runtest_js_rules - | Test_executable {names = name, _; runtest_alias = None}, _, _ :: _ -> + | ( Test_executable {names = name, _; runtest_alias = None; locks = _}, + _, + _ :: _ ) -> invalid_argf "for targets which provide test executables such as %S, ~dep_files \ is only meaningful for the runtest alias. It cannot be used with \ @@ -1671,17 +1685,18 @@ module Target = struct | [] -> invalid_argf "Target.private_exes: at least one name must be given" | head :: tail -> Private_executable (head, tail) - let test ?(alias = "runtest") ?dep_files ?dep_globs ?dep_globs_rec = + let test ?(alias = "runtest") ?dep_files ?dep_globs ?dep_globs_rec ?locks = let runtest_alias = if alias = "" then None else Some alias in internal ?dep_files ?dep_globs ?dep_globs_rec @@ fun test_name -> - Test_executable {names = (test_name, []); runtest_alias} + Test_executable {names = (test_name, []); runtest_alias; locks} - let tests ?(alias = "runtest") ?dep_files ?dep_globs ?dep_globs_rec = + let tests ?(alias = "runtest") ?dep_files ?dep_globs ?dep_globs_rec ?locks = let runtest_alias = if alias = "" then None else Some alias in internal ?dep_files ?dep_globs ?dep_globs_rec @@ fun test_names -> match test_names with | [] -> invalid_arg "Target.tests: at least one name must be given" - | head :: tail -> Test_executable {names = (head, tail); runtest_alias} + | head :: tail -> + Test_executable {names = (head, tail); runtest_alias; locks} let vendored_lib ?(released_on_opam = true) ?main_module ?(js_compatible = false) ?(npm_deps = []) name version = diff --git a/manifest/manifest.mli b/manifest/manifest.mli index c31ae7c784b2554004e2d4da14d3b01072ea9f89..e61d68dd85f0d972130cc434462b16e90f65d58f 100644 --- a/manifest/manifest.mli +++ b/manifest/manifest.mli @@ -889,7 +889,8 @@ val private_exes : string list maker - [alias]: if non-empty, an alias is set up for the given test, named [alias]. Default is ["runtest"]. Note that for JS tests, ["_js"] is appended to this alias. Also note that if [alias] is non-empty, the target must belong to an opam package - (i.e. [~opam] must also be non-empty). + (i.e. [~opam] must also be non-empty). If given, [locks] is set for this alias + (see {!Dune.alias_rule} for more information). - [dep_files]: a list of files to add as dependencies using [(deps (file ...))] in the [runtest] alias. @@ -907,6 +908,7 @@ val test : ?dep_files:string list -> ?dep_globs:string list -> ?dep_globs_rec:string list -> + ?locks:string -> string maker (** Same as {!test} but with several names, to define multiple tests at once. *) @@ -915,6 +917,7 @@ val tests : ?dep_files:string list -> ?dep_globs:string list -> ?dep_globs_rec:string list -> + ?locks:string -> string list maker (** Register a Tezt test. diff --git a/opam/tezos-base-test-helpers.opam b/opam/tezos-base-test-helpers.opam index b90aaa1d71d2f70f805efb5b0731c020ee546417..af84036676ee699febcd1e9fd7b1187cc02b4458 100644 --- a/opam/tezos-base-test-helpers.opam +++ b/opam/tezos-base-test-helpers.opam @@ -14,8 +14,7 @@ depends: [ "tezos-stdlib-unix" "tezos-event-logging-test-helpers" "tezos-test-helpers" - "alcotest" { >= "1.5.0" } - "alcotest-lwt" { >= "1.5.0" } + "octez-alcotezt" "qcheck-alcotest" { >= "0.20" } ] build: [ diff --git a/opam/tezos-event-logging-test-helpers.opam b/opam/tezos-event-logging-test-helpers.opam index a7c013a54a95e4d2dfa28920e2039c700d488d1b..da842a3c3272142866160fca609631c65e788595 100644 --- a/opam/tezos-event-logging-test-helpers.opam +++ b/opam/tezos-event-logging-test-helpers.opam @@ -16,7 +16,7 @@ depends: [ "tezos-error-monad" "tezos-event-logging" "tezos-test-helpers" - "alcotest" { >= "1.5.0" } + "octez-alcotezt" ] build: [ ["rm" "-r" "vendors"] diff --git a/opam/tezos-p2p.opam b/opam/tezos-p2p.opam index 50bafcf58fe4ca85a19d1e48afb2f7d86b98d17e..2e713cf759e02775388d309cec85525cb4aa4e82 100644 --- a/opam/tezos-p2p.opam +++ b/opam/tezos-p2p.opam @@ -24,7 +24,7 @@ depends: [ "tezos-base-test-helpers" {with-test} "tezos-event-logging-test-helpers" {with-test} "tezt-tezos" {with-test} - "alcotest-lwt" { with-test & >= "1.5.0" } + "octez-alcotezt" {with-test} "astring" {with-test} "tezt" { with-test & >= "3.0.0" } ] diff --git a/src/lib_base/test_helpers/dune b/src/lib_base/test_helpers/dune index 05c6ec897486d31959ab903043ede3eeda0fe09a..7484d79600a736da95284d176c641509d3444b4f 100644 --- a/src/lib_base/test_helpers/dune +++ b/src/lib_base/test_helpers/dune @@ -10,11 +10,11 @@ tezos-stdlib-unix tezos-event-logging-test-helpers tezos-test-helpers - alcotest - alcotest-lwt + octez-alcotezt qcheck-alcotest) (library_flags (:standard -linkall)) (flags (:standard) -open Tezos_base.TzPervasives - -open Tezos_test_helpers)) + -open Tezos_test_helpers + -open Octez_alcotezt)) diff --git a/src/lib_event_logging/test_helpers/dune b/src/lib_event_logging/test_helpers/dune index a5049f113411a27f7eb1f2e0c5721a3c0cd9973f..430c015900196e1d1c1cd1e813512a5791628598 100644 --- a/src/lib_event_logging/test_helpers/dune +++ b/src/lib_event_logging/test_helpers/dune @@ -11,7 +11,7 @@ tezos-error-monad tezos-event-logging tezos-test-helpers - alcotest) + octez-alcotezt) (js_of_ocaml) (library_flags (:standard -linkall)) (flags @@ -19,4 +19,5 @@ -open Tezos_error_monad -open Tezos_error_monad.TzLwtreslib -open Tezos_event_logging - -open Tezos_test_helpers)) + -open Tezos_test_helpers + -open Octez_alcotezt)) diff --git a/src/lib_p2p/test/dune b/src/lib_p2p/test/dune index 35cfff9d0e3de4ec5b4c90155ac3b1d4d03a2796..b0c7e80f9c47b382497e2c613cb54bf71d768547 100644 --- a/src/lib_p2p/test/dune +++ b/src/lib_p2p/test/dune @@ -13,6 +13,7 @@ test_p2p_node test_p2p_connect_handler test_p2p_maintenance) + (instrumentation (backend bisect_ppx --bisect-sigterm)) (libraries tezos-base tezos-base.unix @@ -25,11 +26,8 @@ tezos_p2p_test_common tezos-p2p-services tezt-tezos - alcotest-lwt + octez-alcotezt astring) - (link_flags - (:standard) - (-linkall)) (flags (:standard) -open Tezos_base.TzPervasives @@ -40,66 +38,65 @@ -open Tezos_base_test_helpers -open Tezos_event_logging_test_helpers -open Tezos_p2p_test_common - -open Tezos_p2p_services)) - -(rule - (alias runtest_p2p_pool) - (locks /ports/49152-65535) - (action (setenv BISECT_SIGTERM yes (run %{exe:test_p2p_pool.exe})))) + -open Tezos_p2p_services + -open Octez_alcotezt)) (rule - (alias runtest_p2p_broadcast) - (locks /ports/49152-65535) - (action (setenv BISECT_SIGTERM yes (run %{exe:test_p2p_broadcast.exe})))) + (alias runtest) + (package tezos-p2p) + (locks /locks/p2p) + (action (run %{dep:./test_p2p_socket.exe}))) (rule - (alias runtest_p2p_io_scheduler) - (locks /ports/49152-65535) - (action (setenv BISECT_SIGTERM yes (run %{exe:test_p2p_io_scheduler.exe})))) + (alias runtest) + (package tezos-p2p) + (locks /locks/p2p) + (action (run %{dep:./test_p2p_pool.exe}))) (rule - (alias runtest_p2p_socket) - (locks /ports/49152-65535) - (action (setenv BISECT_SIGTERM yes (run %{exe:test_p2p_socket.exe})))) + (alias runtest) + (package tezos-p2p) + (locks /locks/p2p) + (action (run %{dep:./test_p2p_broadcast.exe}))) (rule - (alias runtest_p2p_node) - (locks /ports/49152-65535) - (action (setenv BISECT_SIGTERM yes (run %{exe:test_p2p_node.exe})))) + (alias runtest) + (package tezos-p2p) + (locks /locks/p2p) + (action (run %{dep:./test_p2p_io_scheduler.exe}))) (rule - (alias runtest_p2p_peerset) - (action (setenv BISECT_SIGTERM yes (run %{exe:test_p2p_peerset.exe})))) + (alias runtest) + (package tezos-p2p) + (locks /locks/p2p) + (action (run %{dep:./test_p2p_peerset.exe}))) (rule - (alias runtest_p2p_buffer_reader) - (action (setenv BISECT_SIGTERM yes (run %{exe:test_p2p_buffer_reader.exe})))) + (alias runtest) + (package tezos-p2p) + (locks /locks/p2p) + (action (run %{dep:./test_p2p_buffer_reader.exe}))) (rule - (alias runtest_p2p_banned_peers) - (action (setenv BISECT_SIGTERM yes (run %{exe:test_p2p_banned_peers.exe})))) + (alias runtest) + (package tezos-p2p) + (locks /locks/p2p) + (action (run %{dep:./test_p2p_banned_peers.exe}))) (rule - (alias runtest_p2p_connect_handler) - (action - (setenv BISECT_SIGTERM yes (run %{exe:test_p2p_connect_handler.exe})))) + (alias runtest) + (package tezos-p2p) + (locks /locks/p2p) + (action (run %{dep:./test_p2p_node.exe}))) (rule - (alias runtest_p2p_maintenance) - (action (setenv BISECT_SIGTERM yes (run %{exe:test_p2p_maintenance.exe})))) + (alias runtest) + (package tezos-p2p) + (locks /locks/p2p) + (action (run %{dep:./test_p2p_connect_handler.exe}))) (rule (alias runtest) (package tezos-p2p) - (deps - (alias runtest_p2p_socket) - (alias runtest_p2p_pool) - (alias runtest_p2p_broadcast) - (alias runtest_p2p_io_scheduler) - (alias runtest_p2p_peerset) - (alias runtest_p2p_buffer_reader) - (alias runtest_p2p_banned_peers) - (alias runtest_p2p_node) - (alias runtest_p2p_connect_handler) - (alias runtest_p2p_maintenance)) - (action (progn))) + (locks /locks/p2p) + (action (run %{dep:./test_p2p_maintenance.exe}))) diff --git a/src/lib_p2p/test/test_p2p_banned_peers.ml b/src/lib_p2p/test/test_p2p_banned_peers.ml index 7bad6c3604726b67585603afabb1a6c0bdb8733f..b495aaaa2b08ab125ace5dc2a933500a847b87b3 100644 --- a/src/lib_p2p/test/test_p2p_banned_peers.ml +++ b/src/lib_p2p/test/test_p2p_banned_peers.ml @@ -26,7 +26,7 @@ (** Testing ------- Component: P2P - Invocation: dune build @src/lib_p2p/test/runtest_p2p_banned_peers + Invocation: dune exec src/lib_p2p/test/test_p2p_banned_peers.exe Subject: On banning peers and usage of Access Control Lists (ACL) using sets and POSIX timestamps. *) @@ -139,9 +139,10 @@ let () = f ()) in Alcotest_lwt.run + ~__FILE__ "tezos-p2p" [ - ( "p2p.peerset", + ( "p2p.banned", List.map wrap [ @@ -154,3 +155,5 @@ let () = ] ); ] |> Lwt_main.run + +let () = Tezt.Test.run () diff --git a/src/lib_p2p/test/test_p2p_broadcast.ml b/src/lib_p2p/test/test_p2p_broadcast.ml index 824566da4a711595d54cb9458ac99618f9f1b961..d579e97498ab23e4dae224e76902c7c02ee005ec 100644 --- a/src/lib_p2p/test/test_p2p_broadcast.ml +++ b/src/lib_p2p/test/test_p2p_broadcast.ml @@ -26,7 +26,7 @@ (** Testing ------- Component: P2P - Invocation: dune build @src/lib_p2p/test/runtest_p2p_broadcast + Invocation: dune exec src/lib_p2p/test/test_p2p_broadcast.exe Dependencies: src/lib_p2p/test/process.ml Subject: Testing of the Broadcast Each test launches nodes in separate process, each node @@ -311,9 +311,12 @@ let main () = let addr = Node.default_ipv6_addr in Lwt_main.run @@ Alcotest_lwt.run + ~__FILE__ "tezos-p2p-broadcast" [("p2p-broadcast", [wrap addr "simple" Simple.run])] let () = Sys.catch_break true ; try main () with _ -> () + +let () = Tezt.Test.run () diff --git a/src/lib_p2p/test/test_p2p_buffer_reader.ml b/src/lib_p2p/test/test_p2p_buffer_reader.ml index 791c204101d25ba72ee8aab110b43ed8a77656cd..db9c8c5e91191197a532b64ddfea15a91338e2ab 100644 --- a/src/lib_p2p/test/test_p2p_buffer_reader.ml +++ b/src/lib_p2p/test/test_p2p_buffer_reader.ml @@ -27,7 +27,7 @@ (** Testing ------- Component: P2P - Invocation: dune build @src/lib_p2p/test/runtest_p2p_buffer_reader + Invocation: dune exec src/lib_p2p/test/test_p2p_buffer_reader.exe Subject: Tests [P2p_buffer_reader] *) @@ -342,6 +342,7 @@ let test_read_full_waits = let () = Alcotest.run + ~__FILE__ "P2p_buffer_reader" [ ( "mk_buffer", @@ -358,3 +359,5 @@ let () = :: qcheck_wrap [test_read_less_than_length; test_read_partial] ); ("read_full", qcheck_wrap [test_read_full_basic; test_read_full_waits]); ] + +let () = Tezt.Test.run () diff --git a/src/lib_p2p/test/test_p2p_connect_handler.ml b/src/lib_p2p/test/test_p2p_connect_handler.ml index bdb0c9018a979fe6c1c6b6f9fe9b8a3432eebadb..a106bb180617fc65abc0ab06b1553337a284a883 100644 --- a/src/lib_p2p/test/test_p2p_connect_handler.ml +++ b/src/lib_p2p/test/test_p2p_connect_handler.ml @@ -26,7 +26,7 @@ (** Testing ------- Component: P2P - Invocation: dune build @src/lib_p2p/test/runtest_p2p_connect_handler + Invocation: dune exec src/lib_p2p/test/test_p2p_connect_handler.exe Subject: Test that P2p_connect_handler is well-behaved *) @@ -142,5 +142,7 @@ let tests = ] let () = - Alcotest_lwt.run "P2p_connect_handler" [("P2p_connect_handler", tests)] + Alcotest_lwt.run ~__FILE__ "tezos-p2p" [("p2p.connect_handler", tests)] |> Lwt_main.run + +let () = Tezt.Test.run () diff --git a/src/lib_p2p/test/test_p2p_io_scheduler.ml b/src/lib_p2p/test/test_p2p_io_scheduler.ml index e109386732c67624c996b247d1affc1d32a6cc03..9a23e722bec5a0b815e7bec3a6b9db1242aea221 100644 --- a/src/lib_p2p/test/test_p2p_io_scheduler.ml +++ b/src/lib_p2p/test/test_p2p_io_scheduler.ml @@ -27,7 +27,7 @@ (** Testing ------- Component: P2P - Invocation: dune build @src/lib_p2p/test/runtest_p2p_io_scheduler + Invocation: dune exec src/lib_p2p/test/test_p2p_io_scheduler.exe Dependencies: src/lib_p2p/test/process.ml Subject: On I/O scheduling of client-server connections. *) @@ -261,6 +261,7 @@ let () = let clients = 8 in Lwt_main.run @@ Alcotest_lwt.run + ~__FILE__ "tezos-p2p" [ ( "p2p.io-scheduler", @@ -278,3 +279,5 @@ let () = clients); ] ); ] + +let () = Tezt.Test.run () diff --git a/src/lib_p2p/test/test_p2p_maintenance.ml b/src/lib_p2p/test/test_p2p_maintenance.ml index bbaa1817e421b1831490aef64feb60c8f14a9313..2494a3dcd794e0f427aeebf4185688adb0d6b742 100644 --- a/src/lib_p2p/test/test_p2p_maintenance.ml +++ b/src/lib_p2p/test/test_p2p_maintenance.ml @@ -26,7 +26,7 @@ (* Testing ------- Component: lib_p2p - Invocation: dune build @src/lib_p2p/test/runtest_p2p_maintenance + Invocation: dune exec src/lib_p2p/test/test_p2p_maintenance.exe Subject: Check maintenance mechanism. *) @@ -532,6 +532,7 @@ let main () = let addr = Node.default_ipv6_addr in Lwt_main.run @@ Alcotest_lwt.run + ~__FILE__ "tezos-p2p" [ ( "p2p-maintenance", @@ -546,3 +547,5 @@ let main () = let () = Sys.catch_break true ; try main () with _ -> () + +let () = Tezt.Test.run () diff --git a/src/lib_p2p/test/test_p2p_node.ml b/src/lib_p2p/test/test_p2p_node.ml index 31d46098f581cf118f0be5cbc25e95f92897f4f5..5ae9d89eb4f50b79351fb6b505c2a94dbfd3ab09 100644 --- a/src/lib_p2p/test/test_p2p_node.ml +++ b/src/lib_p2p/test/test_p2p_node.ml @@ -106,6 +106,7 @@ let main () = let addr = Node.default_ipv6_addr in Lwt_main.run @@ Alcotest_lwt.run + ~__FILE__ "tezos-p2p" [ ( "p2p-node", @@ -118,3 +119,5 @@ let main () = let () = Sys.catch_break true ; try main () with _ -> () + +let () = Tezt.Test.run () diff --git a/src/lib_p2p/test/test_p2p_peerset.ml b/src/lib_p2p/test/test_p2p_peerset.ml index 01648efd012fe71ec22e479806bc0083e78e1117..8226ff915a6a19558af854c2173f6baf0bc8bac6 100644 --- a/src/lib_p2p/test/test_p2p_peerset.ml +++ b/src/lib_p2p/test/test_p2p_peerset.ml @@ -26,7 +26,7 @@ (** Testing ------- Component: P2P - Invocation: dune build @src/lib_p2p/test/runtest_p2p_peerset + Invocation: dune exec src/lib_p2p/test/test_p2p_peerset.exe Subject: On banning peers and usage of Access Control Lists (ACL) using FIFO caches filled with peers' ids. *) @@ -100,6 +100,7 @@ let test_LRU_overflow _ = let () = Alcotest.run + ~__FILE__ "tezos-p2p" [ ( "p2p.peerset", @@ -110,3 +111,5 @@ let () = ("remove", `Quick, test_remove); ] ); ] + +let () = Tezt.Test.run () diff --git a/src/lib_p2p/test/test_p2p_pool.ml b/src/lib_p2p/test/test_p2p_pool.ml index cd27e5bac6bfc9cca97aefeac8464438f77ca505..14aabeb7c644f47573ba5da110a771da361a0780 100644 --- a/src/lib_p2p/test/test_p2p_pool.ml +++ b/src/lib_p2p/test/test_p2p_pool.ml @@ -27,7 +27,7 @@ (** Testing ------- Component: P2P - Invocation: dune build @src/lib_p2p/test/runtest_p2p_pool + Invocation: dune exec src/lib_p2p/test/test_p2p_pool.exe Dependencies: src/lib_p2p/test/process.ml Subject: Testing of the Pool Each test launches nodes in separate process, each node @@ -742,6 +742,7 @@ let () = let repeat_connections = 5 in Lwt_main.run @@ Alcotest_lwt.run + ~__FILE__ "tezos-p2p" [ ( "p2p-connection-pool", @@ -757,3 +758,5 @@ let () = No_common_network.run points); ] ); ] + +let () = Tezt.Test.run () diff --git a/src/lib_p2p/test/test_p2p_socket.ml b/src/lib_p2p/test/test_p2p_socket.ml index e895f823920607a99c5cd3b745c68d6d96f9bf42..471f1b6bd25fa1193421072cd632636e00c19650 100644 --- a/src/lib_p2p/test/test_p2p_socket.ml +++ b/src/lib_p2p/test/test_p2p_socket.ml @@ -27,7 +27,7 @@ (** Testing ------- Component: P2P - Invocation: dune build @src/lib_p2p/test/runtest_p2p_socket + Invocation: dune exec src/lib_p2p/test/test_p2p_socket.exe Dependencies: src/lib_p2p/test/process.ml Subject: Sockets and client-server communications. *) @@ -534,6 +534,7 @@ let wrap n f = let main () = Lwt_main.run @@ Alcotest_lwt.run + ~__FILE__ "tezos-p2p" [ ( "p2p-socket.", @@ -554,3 +555,5 @@ let main () = let () = Sys.catch_break true ; try main () with _ -> () + +let () = Tezt.Test.run () diff --git a/tezt/lib_alcotezt/alcotest.ml b/tezt/lib_alcotezt/alcotest.ml index b4ffc81f6223c5aaf045eb140db384df9115028d..282886208f4a98578b8a8bd83628ad5fd71293ca 100644 --- a/tezt/lib_alcotezt/alcotest.ml +++ b/tezt/lib_alcotezt/alcotest.ml @@ -54,6 +54,17 @@ let run ~__FILE__ library_name tests = body () ; Base.unit +module type TESTABLE = sig + (** The type to test. *) + type t + + (** A way to pretty-print the value. *) + val pp : Format.formatter -> t -> unit + + (** Test for equality between two values. *) + val equal : t -> t -> bool +end + type 'a testable = (module Tezt_core.Check.EQUALABLE with type t = 'a) let testable (type a) (pp : Format.formatter -> a -> return) diff --git a/tezt/lib_alcotezt/alcotest.mli b/tezt/lib_alcotezt/alcotest.mli index 07de2f82128b49ba9df776a4b86f0ccc79b22020..4faa3780ce2e19b3d5d17ec6fb1bc1e84183d994 100644 --- a/tezt/lib_alcotezt/alcotest.mli +++ b/tezt/lib_alcotezt/alcotest.mli @@ -71,8 +71,19 @@ type 'a test = string * 'a test_case list The name of the test suite is used as the filename for the Tezt test. *) val run : __FILE__:string -> string -> unit test list -> return +module type TESTABLE = sig + (** The type to test. *) + type t + + (** A way to pretty-print the value. *) + val pp : Format.formatter -> t -> unit + + (** Test for equality between two values. *) + val equal : t -> t -> bool +end + (** Values that can be tested with {!check}. *) -type 'a testable = (module Tezt_core.Check.EQUALABLE with type t = 'a) +type 'a testable = (module TESTABLE with type t = 'a) (** [testable pp eq] is a new {!type-testable} with the pretty-printer [pp] and equality [eq]. *)