diff --git a/irmin/README.md b/irmin/README.md index e92f1c2cb3c6571b7d05592bbff5e7090aa01538..8047db5d35643c4d861a4a5abb8c014741ae501d 100644 --- a/irmin/README.md +++ b/irmin/README.md @@ -32,6 +32,13 @@ directory is under the \*`test` is a directory containing **unforked** tests from built for octez purposes that are using the `irmin` libraries. +### Tests + +| Category | Local path | Upstream | +| -------- | --------- | -------- | +| `irmin-mem` | `./test/irmin-mem` | [`test/irmin-mem`](https://github.com/mirage/irmin/tree/main/test/irmin-mem) | + + ## To-do before modifying the code - Import Irmin's tests, and ideally benches. diff --git a/irmin/test/helpers/irmin_test.mli b/irmin/test/helpers/irmin_test.mli index 52fa646d486b03c7c91ea00c7a8775966d7dddde..429fa5175e3cd5e035c92b6e5712c5e23cc1a563 100644 --- a/irmin/test/helpers/irmin_test.mli +++ b/irmin/test/helpers/irmin_test.mli @@ -62,6 +62,7 @@ val checks : 'a Irmin.Type.t -> string -> 'a list -> 'a list -> unit module Store : sig val run : + __FILE__:string -> string -> ?slow:bool -> ?random_seed:int -> diff --git a/irmin/test/helpers/store.ml b/irmin/test/helpers/store.ml index 44e1bc57e888d2e15808f79412ac90756ef9247e..a251af14f199b91fe1dc18d32c4e74dd55952102 100644 --- a/irmin/test/helpers/store.ml +++ b/irmin/test/helpers/store.ml @@ -2480,7 +2480,7 @@ let slow_suite (speed, x) = ] (speed, x) -let run name ?(slow = false) ?random_seed ~sleep ~misc tl = +let run ~__FILE__ name ?(slow = false) ?random_seed ~sleep ~misc tl = let () = match random_seed with | Some x -> Random.init x diff --git a/irmin/test/helpers/store.mli b/irmin/test/helpers/store.mli index 57aeeb89dc4b7e139abb096cc525b1ef1f1f49dd..8d5d6a923b63bddc47380e52420cb8b780e36547 100644 --- a/irmin/test/helpers/store.mli +++ b/irmin/test/helpers/store.mli @@ -15,6 +15,7 @@ *) val run : + __FILE__:string -> string -> ?slow:bool -> ?random_seed:int -> diff --git a/irmin/test/irmin-mem/bench.ml b/irmin/test/irmin-mem/bench.ml new file mode 100644 index 0000000000000000000000000000000000000000..c4bc86d41e5741fc544e88930967c33632e63152 --- /dev/null +++ b/irmin/test/irmin-mem/bench.ml @@ -0,0 +1,23 @@ +(* + * Copyright (c) 2013-2022 Thomas Gazagnaire + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + *) + +let config ~root:_ = Irmin_mem.config () + +module KV = Irmin_mem.KV.Make (Irmin.Contents.String) +module Bench = Irmin_bench.Make (KV) + +let size ~root:_ = 0 +let () = Bench.run ~config ~size diff --git a/irmin/test/irmin-mem/dune b/irmin/test/irmin-mem/dune new file mode 100644 index 0000000000000000000000000000000000000000..b90121ca75572a5bdaa4ea97fd06b05520d81fbc --- /dev/null +++ b/irmin/test/irmin-mem/dune @@ -0,0 +1,39 @@ +; This file was automatically generated, do not edit. +; Edit file manifest/main.ml instead. + +(library + (name irmin_test_irmin_mem_tezt_lib) + (instrumentation (backend bisect_ppx)) + (libraries + tezt.core + octez-libs.tezos-context.memory + octez-internal-libs.irmin_test_helpers + octez-libs.test-helpers + tezt) + (library_flags (:standard -linkall)) + (flags + (:standard) + -open Tezt_core + -open Tezt_core.Base + -open Tezos_test_helpers + -open Tezt + -open Tezt.Base) + (modules test test_mem)) + +(executable + (name main) + (instrumentation (backend bisect_ppx --bisect-sigterm)) + (libraries + irmin_test_irmin_mem_tezt_lib + tezt) + (modules main)) + +(rule + (alias runtest) + (package tezos_internal_irmin_tests) + (enabled_if (<> false %{env:RUNTEZTALIAS=true})) + (action (run %{dep:./main.exe}))) + +(rule + (targets main.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt.Test.run ()")))) diff --git a/irmin/test/irmin-mem/test.ml b/irmin/test/irmin-mem/test.ml new file mode 100644 index 0000000000000000000000000000000000000000..31a7402ba157b3c70bd3b90a507f2feb7fb74602 --- /dev/null +++ b/irmin/test/irmin-mem/test.ml @@ -0,0 +1,28 @@ +(* + * Copyright (c) 2013-2022 Thomas Gazagnaire + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + *) + +(** Testing + ------- + Component: Irmin-mem + Invocation: dune exec irmin/test/irmin-mem/main.exe + Subject: This file is the entrypoint of all Irmin-mem Tezt tests. It dispatches to other files. +*) + +let () = + Lwt_main.run + @@ Irmin_test_helpers.Irmin_test.Store.run ~__FILE__ "irmin-mem" ~slow:true + ~misc:[] ~sleep:Lwt_unix.sleep + [ (`Quick, Test_mem.suite) ] diff --git a/irmin/test/irmin-mem/test.mli b/irmin/test/irmin-mem/test.mli new file mode 100644 index 0000000000000000000000000000000000000000..e790aeb70f0d9753901aea2af96010955b2bdddd --- /dev/null +++ b/irmin/test/irmin-mem/test.mli @@ -0,0 +1 @@ +(* empty *) diff --git a/irmin/test/irmin-mem/test_mem.ml b/irmin/test/irmin-mem/test_mem.ml new file mode 100644 index 0000000000000000000000000000000000000000..0fce312e6307ddc8131bb232658d46b8dd6f036c --- /dev/null +++ b/irmin/test/irmin-mem/test_mem.ml @@ -0,0 +1,26 @@ +(* + * Copyright (c) 2013-2022 Thomas Gazagnaire + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + *) + +let store = + Irmin_test_helpers.Irmin_test.store + (module Irmin_mem) + (module Irmin.Metadata.None) + +let config = Irmin_mem.config () +let init ~config:_ = Lwt.return_unit + +let suite = + Irmin_test_helpers.Irmin_test.Suite.create ~name:"MEM" ~init ~store ~config () diff --git a/manifest/product_octez.ml b/manifest/product_octez.ml index 89fd5832a68479a629bfcc5d36045c967159f723..58e73b4659a39b5d170e6f426352d7d045a79ea0 100644 --- a/manifest/product_octez.ml +++ b/manifest/product_octez.ml @@ -2754,6 +2754,20 @@ let _irmin_tests = tezt_lib |> open_ |> open_ ~m:"Base"; ] +let _irmin_mem_tests = + tezt + ["test"; "test_mem"] + ~path:"irmin/test/irmin-mem" + ~opam:"tezos_internal_irmin_tests" + ~synopsis:"Tezos internal irmin tests" + ~deps: + [ + octez_context_memory; + irmin_test_helpers; + octez_test_helpers |> open_; + tezt_lib |> open_ |> open_ ~m:"Base"; + ] + (* This binding assumes that librustzcash.a is installed in the system default directories or in: $OPAM_SWITCH_PREFIX/lib diff --git a/tezt/tests/dune b/tezt/tests/dune index 0cc97784788e49bf699698438d89c77f0b641049..490bad26c87caf756122649d6d54cad434a1c6c5 100644 --- a/tezt/tests/dune +++ b/tezt/tests/dune @@ -118,6 +118,7 @@ src_lib_benchmark_lib_micheline_rewriting_test_tezt_lib src_lib_base_unix_test_tezt_lib src_lib_base_test_tezt_lib + irmin_test_irmin_mem_tezt_lib irmin_test_tezt_lib etherlink_tezt_tests_tezt_lib etherlink_bin_node_test_tezt_lib)