From cb31e42ab519b66b6a7e2fd8ed51d73068ee7f85 Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Thu, 2 Feb 2023 16:21:34 +0100 Subject: [PATCH] tezt: Add unit tests for lazy_context --- manifest/main.ml | 32 ++++----------- opam/tezos-context.opam | 4 +- src/lib_context/memory/test/dune | 30 +++++++++++--- src/lib_context/test/dune | 50 +++++++++++------------ src/lib_context/test/test.ml | 28 ------------- src/lib_context/test/test_context.ml | 6 ++- src/lib_context/test/test_context.mli | 26 ------------ src/lib_context/test/test_merkle_proof.ml | 1 + tezt/tests/dune | 2 + 9 files changed, 66 insertions(+), 113 deletions(-) delete mode 100644 src/lib_context/test/test.ml delete mode 100644 src/lib_context/test/test_context.mli diff --git a/manifest/main.ml b/manifest/main.ml index f5409335f0f5..828eac2db99e 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -1956,8 +1956,8 @@ let octez_context = ~deps:[octez_context_disk; octez_context_memory] let _octez_context_tests = - test - "test" + tezt + ["test_context"; "test_merkle_proof"] ~path:"src/lib_context/test" ~opam:"tezos-context" ~deps: @@ -1967,16 +1967,17 @@ let _octez_context_tests = octez_context_sigs; octez_context_disk; octez_context_memory; + octez_context_encoding; octez_stdlib_unix |> open_; octez_test_helpers |> open_; octez_test_helpers_extra; - alcotest_lwt; + qcheck_alcotest; + alcotezt; ] - ~modules:["test_context"; "test"] let _octez_context_memory_tests = - test - "test" + tezt + ["test"] ~path:"src/lib_context/memory/test" ~opam:"tezos-context" ~deps: @@ -1986,7 +1987,7 @@ let _octez_context_memory_tests = octez_context_disk; octez_context_memory; octez_stdlib_unix |> open_; - alcotest_lwt; + alcotezt; ] (* This binding assumes that librustzcash.a is installed in the system default @@ -2708,23 +2709,6 @@ let _octez_rpc_http_server_tests = alcotest_lwt; ] -let _octez_context_merkle_proof_tests = - test - "test_merkle_proof" - ~path:"src/lib_context/test" - ~opam:"tezos-context" - ~deps: - [ - octez_base |> open_ ~m:"TzPervasives"; - octez_base_unix; - octez_context_disk |> open_; - octez_context_encoding; - octez_stdlib_unix |> open_; - qcheck_alcotest; - octez_test_helpers |> open_; - ] - ~modules:["test_merkle_proof"] - let octez_client_base = public_lib "tezos-client-base" diff --git a/opam/tezos-context.opam b/opam/tezos-context.opam index ea039340e6ec..2f6b16ecb39d 100644 --- a/opam/tezos-context.opam +++ b/opam/tezos-context.opam @@ -18,14 +18,16 @@ depends: [ "fmt" { >= "0.8.7" } "bigstringaf" { >= "0.5.0" } "logs" + "tezt" { with-test & >= "3.0.0" } + "octez-alcotezt" {with-test} "tezos-test-helpers" {with-test} "tezos-test-helpers-extra" {with-test} - "alcotest-lwt" { with-test & >= "1.5.0" } "qcheck-alcotest" { with-test & >= "0.20" } ] build: [ ["rm" "-r" "vendors"] ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] {with-test} + ["dune" "build" "@runtezt" "-p" name "-j" jobs] {with-test} ] synopsis: "Tezos: on-disk context abstraction for `octez-node`" diff --git a/src/lib_context/memory/test/dune b/src/lib_context/memory/test/dune index 187be6350deb..a37f430e0551 100644 --- a/src/lib_context/memory/test/dune +++ b/src/lib_context/memory/test/dune @@ -1,21 +1,39 @@ ; This file was automatically generated, do not edit. ; Edit file manifest/main.ml instead. -(executable - (name test) +(library + (name src_lib_context_memory_test_tezt_lib) + (instrumentation (backend bisect_ppx)) (libraries + tezt.core tezos-base tezos-base.unix tezos-context.disk tezos-context.memory tezos-stdlib-unix - alcotest-lwt) + octez-alcotezt) + (library_flags (:standard -linkall)) (flags (:standard) + -open Tezt_core + -open Tezt_core.Base -open Tezos_base.TzPervasives - -open Tezos_stdlib_unix)) + -open Tezos_stdlib_unix + -open Octez_alcotezt) + (modules test)) + +(executable + (name main) + (libraries + src_lib_context_memory_test_tezt_lib + tezt) + (modules main)) (rule - (alias runtest) + (alias runtezt) (package tezos-context) - (action (run %{dep:./test.exe}))) + (action (run %{dep:./main.exe}))) + +(rule + (targets main.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt.Test.run ()")))) diff --git a/src/lib_context/test/dune b/src/lib_context/test/dune index 9fd1872ee1db..2f95b648b3d9 100644 --- a/src/lib_context/test/dune +++ b/src/lib_context/test/dune @@ -1,49 +1,45 @@ ; This file was automatically generated, do not edit. ; Edit file manifest/main.ml instead. -(executable - (name test) +(library + (name src_lib_context_test_tezt_lib) + (instrumentation (backend bisect_ppx)) (libraries + tezt.core tezos-base tezos-base.unix tezos-context.sigs tezos-context.disk tezos-context.memory + tezos-context.encoding tezos-stdlib-unix tezos-test-helpers tezos-test-helpers-extra - alcotest-lwt) + qcheck-alcotest + octez-alcotezt) + (library_flags (:standard -linkall)) (flags (:standard) + -open Tezt_core + -open Tezt_core.Base -open Tezos_base.TzPervasives -open Tezos_stdlib_unix - -open Tezos_test_helpers) - (modules test_context test)) - -(rule - (alias runtest) - (package tezos-context) - (action (run %{dep:./test.exe}))) + -open Tezos_test_helpers + -open Octez_alcotezt) + (modules test_context test_merkle_proof)) (executable - (name test_merkle_proof) + (name main) (libraries - tezos-base - tezos-base.unix - tezos-context.disk - tezos-context.encoding - tezos-stdlib-unix - qcheck-alcotest - tezos-test-helpers) - (flags - (:standard) - -open Tezos_base.TzPervasives - -open Tezos_context_disk - -open Tezos_stdlib_unix - -open Tezos_test_helpers) - (modules test_merkle_proof)) + src_lib_context_test_tezt_lib + tezt) + (modules main)) (rule - (alias runtest) + (alias runtezt) (package tezos-context) - (action (run %{dep:./test_merkle_proof.exe}))) + (action (run %{dep:./main.exe}))) + +(rule + (targets main.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt.Test.run ()")))) diff --git a/src/lib_context/test/test.ml b/src/lib_context/test/test.ml deleted file mode 100644 index 4f6e917a1aba..000000000000 --- a/src/lib_context/test/test.ml +++ /dev/null @@ -1,28 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -let () = - Lwt_main.run - (Alcotest_lwt.run "tezos-context" [("context", Test_context.tests)]) diff --git a/src/lib_context/test/test_context.ml b/src/lib_context/test/test_context.ml index 48e9f10ee57b..7140899796c5 100644 --- a/src/lib_context/test/test_context.ml +++ b/src/lib_context/test/test_context.ml @@ -693,4 +693,8 @@ module Generic_memory = end) (Tezos_context_memory.Context) -let tests = List.concat [Generic_disk.tests; Generic_memory.tests] +let () = + Lwt_main.run + (Alcotest_lwt.run + "tezos-context" + [("context", List.concat [Generic_disk.tests; Generic_memory.tests])]) diff --git a/src/lib_context/test/test_context.mli b/src/lib_context/test/test_context.mli deleted file mode 100644 index c938c9217a49..000000000000 --- a/src/lib_context/test/test_context.mli +++ /dev/null @@ -1,26 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -val tests : unit Alcotest_lwt.test_case list diff --git a/src/lib_context/test/test_merkle_proof.ml b/src/lib_context/test/test_merkle_proof.ml index 58ab6a3630bb..286716cf7d75 100644 --- a/src/lib_context/test/test_merkle_proof.ml +++ b/src/lib_context/test/test_merkle_proof.ml @@ -23,6 +23,7 @@ (* *) (*****************************************************************************) +open Tezos_context_disk open Context.Proof open Qcheck2_helpers open QCheck2 diff --git a/tezt/tests/dune b/tezt/tests/dune index c0efb967297d..8c2501b36dbd 100644 --- a/tezt/tests/dune +++ b/tezt/tests/dune @@ -30,6 +30,8 @@ src_lib_lwt_result_stdlib_test_tezt_lib src_lib_lazy_containers_test_tezt_lib src_lib_error_monad_test_tezt_lib + src_lib_context_test_tezt_lib + src_lib_context_memory_test_tezt_lib src_lib_clic_test_tezt_lib src_lib_benchmark_test_tezt_lib src_lib_base_test_tezt_lib) -- GitLab