From b16c12287a41e3bf82dc3df2a608d9acf28d682f Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Fri, 27 Jan 2023 10:00:29 +0100 Subject: [PATCH 01/13] Manifest: fix potential Not_found exception --- manifest/manifest.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manifest/manifest.ml b/manifest/manifest.ml index a0133835958e..fe21f9ea6bbf 100644 --- a/manifest/manifest.ml +++ b/manifest/manifest.ml @@ -3040,7 +3040,9 @@ let check_circular_opam_deps () = in while not (Queue.is_empty to_visit) do let elt = Queue.take to_visit in - let elt_path = Hashtbl.find shortest_path elt.kind in + let elt_path = + Option.value ~default:[] (Hashtbl.find_opt shortest_path elt.kind) + in list_iter (deps_of elt) (fun (dep : Target.internal) -> if not (Hashtbl.mem shortest_path dep.kind) then ( let path = dep :: elt_path in -- GitLab From 13e204d7aae5ca9e0d459723aae57e4c3189fb15 Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Fri, 27 Jan 2023 10:35:26 +0100 Subject: [PATCH 02/13] Manifest: move some tezt packages up in main.ml --- manifest/main.ml | 58 ++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index fa155f68c1f0..4c1762a11e85 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -333,22 +333,6 @@ let tezos_rust_lib = let tezos_rust_lib_sapling = opam_only ~can_vendor:false "tezos-rust-libs" V.(at_least "1.1") -let tezt_lib = - external_lib - ~js_compatible:false - "tezt" - V.(at_least "3.0.0") - ~main_module:"Tezt" - -let tezt_core_lib = - external_sublib - tezt_lib - ~js_compatible:true - "tezt.core" - ~main_module:"Tezt_core" - -let tezt_js_lib = external_sublib tezt_lib ~js_compatible:true "tezt.js" - let tls = external_lib "tls" V.(at_least "0.13.0") let unix = external_lib ~opam:"base-unix" "unix" V.True @@ -388,6 +372,35 @@ let () = (* INTERNAL LIBS *) +let tezt_lib = + external_lib + ~js_compatible:false + "tezt" + V.(at_least "3.0.0") + ~main_module:"Tezt" + +let tezt_core_lib = + external_sublib + tezt_lib + ~js_compatible:true + "tezt.core" + ~main_module:"Tezt_core" + +let tezt_js_lib = external_sublib tezt_lib ~js_compatible:true "tezt.js" + +let tezt ~opam ~path ?js_compatible ?modes ?(deps = []) ?dep_globs ?synopsis l = + tezt_without_tezt_lib_dependency + ~opam + ~path + ?synopsis + ?js_compatible + ?modes + ~lib_deps:((tezt_core_lib |> open_ |> open_ ~m:"Base") :: deps) + ~exe_deps:[tezt_lib] + ~js_deps:[tezt_js_lib] + ?dep_globs + l + let octez_test_helpers = public_lib "tezos-test-helpers" @@ -3070,19 +3083,6 @@ let octez_shell_benchmarks = ] ~linkall:true -let tezt ~opam ~path ?js_compatible ?modes ?(deps = []) ?dep_globs ?synopsis l = - tezt_without_tezt_lib_dependency - ~opam - ~path - ?synopsis - ?js_compatible - ?modes - ~lib_deps:((tezt_core_lib |> open_ |> open_ ~m:"Base") :: deps) - ~exe_deps:[tezt_lib] - ~js_deps:[tezt_js_lib] - ?dep_globs - l - let tezt_performance_regression = public_lib "tezt-performance-regression" -- GitLab From 7769f51da623ab2c1171098b254cba6db3e45459 Mon Sep 17 00:00:00 2001 From: Romain Bardou Date: Thu, 3 Nov 2022 14:43:51 +0100 Subject: [PATCH 03/13] Tezt: add octez-alcotezt --- manifest/main.ml | 14 ++++ tezt/lib_alcotezt/alcotest.ml | 109 +++++++++++++++++++++++++++++ tezt/lib_alcotezt/alcotest.mli | 93 ++++++++++++++++++++++++ tezt/lib_alcotezt/alcotest_lwt.ml | 64 +++++++++++++++++ tezt/lib_alcotezt/alcotest_lwt.mli | 67 ++++++++++++++++++ 5 files changed, 347 insertions(+) create mode 100644 tezt/lib_alcotezt/alcotest.ml create mode 100644 tezt/lib_alcotezt/alcotest.mli create mode 100644 tezt/lib_alcotezt/alcotest_lwt.ml create mode 100644 tezt/lib_alcotezt/alcotest_lwt.mli diff --git a/manifest/main.ml b/manifest/main.ml index 4c1762a11e85..3b86c682ba38 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -388,6 +388,20 @@ let tezt_core_lib = let tezt_js_lib = external_sublib tezt_lib ~js_compatible:true "tezt.js" +(* The main module [Octez_alcotest] is [open_] so that one can replace + the [alcotest] dependency with [alcotezt] and it just works. + If we use [~internal_name:"alcotest"] here, it would also work, + except in cases where the real Alcotest is also a dependency. *) +let alcotezt = + public_lib + "octez-alcotezt" + ~path:"tezt/lib_alcotezt" + ~synopsis: + "Provide the interface of Alcotest for Octez, but with Tezt as backend." + ~js_compatible:true + ~deps:[tezt_core_lib] + |> open_ + let tezt ~opam ~path ?js_compatible ?modes ?(deps = []) ?dep_globs ?synopsis l = tezt_without_tezt_lib_dependency ~opam diff --git a/tezt/lib_alcotezt/alcotest.ml b/tezt/lib_alcotezt/alcotest.ml new file mode 100644 index 000000000000..8809f5313a40 --- /dev/null +++ b/tezt/lib_alcotezt/alcotest.ml @@ -0,0 +1,109 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +open Tezt_core + +type return = unit + +type speed_level = [`Quick | `Slow] + +type 'a test_case = string * speed_level * ('a -> return) + +let test_case name speed_level body = (name, speed_level, body) + +exception Test_error + +type 'a test = string * 'a test_case list + +(* TODO: https://gitlab.com/tezos/tezos/-/issues/4726 + + group tests individually *) +let run library_name tests = + tests + |> List.iter @@ fun (test_name, test_cases) -> + Test.register + ~__FILE__:library_name + ~title:(library_name ^ ": " ^ test_name) + ~tags:["alcotest"] + @@ fun () -> + (test_cases + |> List.iter @@ fun (test_case_name, speed_level, body) -> + match speed_level with + | `Slow when Cli.get_bool ~default:false "quick" -> + Log.info "Skipped test: %s" test_case_name + | `Slow | `Quick -> + Log.info "Test: %s" test_case_name ; + body ()) ; + Base.unit + +type 'a testable = (module Tezt_core.Check.EQUALABLE with type t = 'a) + +let string : string testable = + (module struct + include String + + let pp = Format.pp_print_string + end) + +let result (type a e) (ok : a testable) (error : e testable) : + (a, e) result testable = + let module Ok = (val ok) in + let module Error = (val error) in + (module struct + type t = (a, e) result + + let pp fmt = function + | Ok x -> Format.fprintf fmt "@[Ok@ (%a)@]" Ok.pp x + | Error x -> Format.fprintf fmt "@[Error@ (%a)@]" Error.pp x + + let equal = Result.equal ~ok:Ok.equal ~error:Error.equal + end) + +let check testable msg expected actual = + Check.(expected = actual) + (Check.equalable_module testable) + ~error_msg:(msg ^ ": expected %L, got %R") + +let fail message = Test.fail "%s" message + +let failf x = Format.kasprintf fail x + +(* Some Octez tests use Format.eprintf directly. + Not even in the tests but in the libraries themselves. + We redirect the output to Tezt.Log. + + Ideally we would do the same for the Printf module, which is in particular + called by QCheck_alcotest to print the seed, but the Printf module cannot + redirect its output... *) +let redirect_formatter fmt = + let buffer = Buffer.create 256 in + Format.pp_set_formatter_output_functions fmt (Buffer.add_substring buffer) + @@ fun () -> + Log.info "%s" (String.trim (Buffer.contents buffer)) ; + Buffer.clear buffer + +let () = + redirect_formatter Format.std_formatter ; + redirect_formatter Format.err_formatter diff --git a/tezt/lib_alcotezt/alcotest.mli b/tezt/lib_alcotezt/alcotest.mli new file mode 100644 index 000000000000..c25a2396e514 --- /dev/null +++ b/tezt/lib_alcotezt/alcotest.mli @@ -0,0 +1,93 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +(** Wrapper to run Alcotest tests with Tezt as a backend. *) + +(** This module provides a subset of the interface of the [Alcotest] module + of the real Alcotest library. But instead of using Alcotest to run the tests, + it uses Tezt. This allows to transition from Alcotest to Tezt without + having to actually change the code. In turn, this allows to benefit from + Tezt features such as auto-balancing in the CI. One can then use Tezt's + modules in the test, to gradually migrate the test to Tezt and stop using + this wrapper. + + This module is intended as a way to help transition from Alcotest to Tezt, + not to use both at the same time forever. First use Alcotezt to have the test + runnable using Tezt, as a quick win to get auto-balancing etc. Then stop using + Alcotest functions and migrate existing calls at the pace that is convenient + for you. *) + +(** Return type for tests. *) +type return = unit + +(** Speed levels. + + In Alcotest, one can ask not to run slow tests with [-q] from the command-line. + In Tezt, the equivalent is [-a quick]. *) +type speed_level = [`Quick | `Slow] + +(** Test cases. + + The name of the Alcotest test case appears in Tezt's logs, + but it is not used in the Tezt test title, nor as a tag. *) +type 'a test_case = string * speed_level * ('a -> return) + +(** Make a test case. *) +val test_case : string -> speed_level -> ('a -> return) -> 'a test_case + +(** Can be raised to fail a test. *) +exception Test_error + +(** Tests. + + In Tezt, the name of the test is used as the title of the test. *) +type 'a test = string * 'a test_case list + +(** Run a test suite. + + In Tezt, this calls [Test.register] but does not actually run the test suite. + The name of the test suite is used as the filename for the Tezt test. *) +val run : string -> unit test list -> return + +(** Values that can be tested with {!check}. *) +type 'a testable = (module Tezt_core.Check.EQUALABLE with type t = 'a) + +(** The string testable type. *) +val string : string testable + +(** The result testable type. *) +val result : 'a testable -> 'e testable -> ('a, 'e) result testable + +(** Check that two values are equal. + + In Tezt, this becomes [Check.(=)] where [~error_msg] is + [msg ^ ": expected %L, got %R"] where [msg] is the [string] given to [check]. *) +val check : 'a testable -> string -> 'a -> 'a -> return + +(** Fail the current test (string version). *) +val fail : string -> 'a + +(** Fail the current test (format version). *) +val failf : ('a, Format.formatter, return, 'b) format4 -> 'a diff --git a/tezt/lib_alcotezt/alcotest_lwt.ml b/tezt/lib_alcotezt/alcotest_lwt.ml new file mode 100644 index 000000000000..72e3a809576f --- /dev/null +++ b/tezt/lib_alcotezt/alcotest_lwt.ml @@ -0,0 +1,64 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +open Tezt_core +open Tezt_core.Base + +type return = unit Lwt.t + +type speed_level = [`Quick | `Slow] + +type 'a test_case = string * speed_level * ('a -> return) + +let test_case name speed_level body = + (* Not sure this is the right way to create the switch, maybe it should have + a larger scope. *) + let body args = Lwt_switch.with_switch (fun sw -> body sw args) in + (name, speed_level, body) + +let test_case_sync name speed_level body = + let body arg = + body arg ; + unit + in + (name, speed_level, body) + +type 'a test = string * 'a test_case list + +let run library_name tests = + (tests + |> List.iter @@ fun (test_name, test_cases) -> + Test.register ~__FILE__:library_name ~title:test_name ~tags:["alcotest"] + @@ fun () -> + test_cases + |> Lwt_list.iter_s @@ fun (test_case_name, speed_level, body) -> + match speed_level with + | `Slow when Cli.get_bool ~default:false "quick" -> + Log.info "Skipped test: %s" test_case_name ; + unit + | `Slow | `Quick -> + Log.info "Test: %s" test_case_name ; + body ()) ; + unit diff --git a/tezt/lib_alcotezt/alcotest_lwt.mli b/tezt/lib_alcotezt/alcotest_lwt.mli new file mode 100644 index 000000000000..06c1af33f154 --- /dev/null +++ b/tezt/lib_alcotezt/alcotest_lwt.mli @@ -0,0 +1,67 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +(** Wrapper to run Alcotest tests with Tezt as a backend. *) + +(** This module provides a subset of the interface of the [Alcotest] module + of the real Alcotest library. But instead of using Alcotest to run the tests, + it uses Tezt. This allows to transition from Alcotest to Tezt without + having to actually change the code. In turn, this allows to benefit from + Tezt features such as auto-balancing in the CI. One can then use Tezt's + modules in the test, to gradually migrate the test to Tezt and stop using + this wrapper. *) + +(** Return type for tests. *) +type return = unit Lwt.t + +(** Speed levels. + + In Alcotest, one can ask not to run slow tests with [-q] from the command-line. + In Tezt, the equivalent is [-a quick]. *) +type speed_level = [`Quick | `Slow] + +(** Test cases. + + The name of the Alcotest test case appears in Tezt's logs, + but it is not used in the Tezt test title, nor as a tag. *) +type 'a test_case = string * speed_level * ('a -> return) + +(** Make a test case. *) +val test_case : + string -> speed_level -> (Lwt_switch.t -> 'a -> return) -> 'a test_case + +(** Make a test case (out of Lwt). *) +val test_case_sync : string -> speed_level -> ('a -> unit) -> 'a test_case + +(** Tests. + + In Tezt, the name of the test is used as the title of the test. *) +type 'a test = string * 'a test_case list + +(** Run a test suite. + + In Tezt, this calls [Test.register] but does not actually run the test suite. + The name of the test suite is used as the filename for the Tezt test. *) +val run : string -> unit test list -> return -- GitLab From ba7f7128206e1101a3935b7c2b9bd9b1f9b117f1 Mon Sep 17 00:00:00 2001 From: Romain Bardou Date: Thu, 3 Nov 2022 14:44:44 +0100 Subject: [PATCH 04/13] Error_monad: use octez-alcotezt instead of alcotest --- manifest/main.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index 3b86c682ba38..4f12b0cb93cf 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -796,12 +796,12 @@ let _octez_hacl_tests_1 = ~js_compatible:true let _octez_error_monad_tests = - tests + tezt ["test_registration"; "test_splitted_error_encoding"] ~path:"src/lib_error_monad/test" ~opam:"tezos-error-monad" ~modes:[Native; JS] - ~deps:[octez_error_monad |> open_; data_encoding; alcotest] + ~deps:[octez_error_monad |> open_; data_encoding; alcotezt] ~js_compatible:true let octez_rpc = -- GitLab From fa1abf1b5e220df8115cb730c34610ae4cedf7d1 Mon Sep 17 00:00:00 2001 From: Romain Bardou Date: Fri, 4 Nov 2022 10:31:55 +0100 Subject: [PATCH 05/13] Manifest: simplify lib_base test declaration --- manifest/main.ml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index 4f12b0cb93cf..56e99f1fef56 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -1132,9 +1132,11 @@ let octez_base_unix = uri; ] -let lib_base_tests ?dep_files names = +let _octez_base_tests = tests - names + [ + "test_bounded"; "test_time"; "test_protocol"; "test_p2p_addr"; "test_sized"; + ] ~path:"src/lib_base/test" ~opam:"tezos-base" ~deps: @@ -1145,18 +1147,14 @@ let lib_base_tests ?dep_files names = qcheck_alcotest; octez_test_helpers |> open_; ] - ?dep_files + ~dep_files: + [ + (* Note: those files are only actually needed by test_p2p_addr. *) + "points.ok"; + "points.ko"; + ] ~modes:[Native; JS] ~js_compatible:true - ~modules:names - -let _octez_base_tests_1 = - lib_base_tests ["test_bounded"; "test_time"; "test_protocol"] - -let _octez_base_tests_2 = - lib_base_tests ["test_p2p_addr"] ~dep_files:["points.ok"; "points.ko"] - -let _octez_base_tests_3 = lib_base_tests ["test_sized"] let _octez_base_unix_tests = test -- GitLab From 6ab1debf15e90e98116d4dd1a7d223a705970873 Mon Sep 17 00:00:00 2001 From: Romain Bardou Date: Fri, 4 Nov 2022 10:34:28 +0100 Subject: [PATCH 06/13] Manifest: add ?dep_files to val tezt --- manifest/main.ml | 4 +++- manifest/manifest.ml | 6 +++++- manifest/manifest.mli | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index 56e99f1fef56..ce1b9ff7ca75 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -402,7 +402,8 @@ let alcotezt = ~deps:[tezt_core_lib] |> open_ -let tezt ~opam ~path ?js_compatible ?modes ?(deps = []) ?dep_globs ?synopsis l = +let tezt ~opam ~path ?js_compatible ?modes ?(deps = []) ?dep_globs ?dep_files + ?synopsis l = tezt_without_tezt_lib_dependency ~opam ~path @@ -413,6 +414,7 @@ let tezt ~opam ~path ?js_compatible ?modes ?(deps = []) ?dep_globs ?synopsis l = ~exe_deps:[tezt_lib] ~js_deps:[tezt_js_lib] ?dep_globs + ?dep_files l let octez_test_helpers = diff --git a/manifest/manifest.ml b/manifest/manifest.ml index fe21f9ea6bbf..c4c3ed98ab57 100644 --- a/manifest/manifest.ml +++ b/manifest/manifest.ml @@ -1782,6 +1782,7 @@ type tezt_target = { exe_deps : target list; js_deps : target list; dep_globs : string list; + dep_files : string list; modules : string list; js_compatible : bool option; modes : Dune.mode list option; @@ -1791,7 +1792,7 @@ type tezt_target = { let tezt_targets_by_path : tezt_target String_map.t ref = ref String_map.empty let tezt ~opam ~path ?js_compatible ?modes ?(lib_deps = []) ?(exe_deps = []) - ?(js_deps = []) ?(dep_globs = []) ?synopsis modules = + ?(js_deps = []) ?(dep_globs = []) ?(dep_files = []) ?synopsis modules = if String_map.mem path !tezt_targets_by_path then invalid_arg ("cannot call Manifest.tezt twice for the same directory: " ^ path) ; @@ -1802,6 +1803,7 @@ let tezt ~opam ~path ?js_compatible ?modes ?(lib_deps = []) ?(exe_deps = []) exe_deps; js_deps; dep_globs; + dep_files; modules; js_compatible; modes; @@ -1819,6 +1821,7 @@ let register_tezt_targets ~make_tezt_exe = exe_deps; js_deps; dep_globs; + dep_files; modules; js_compatible; modes; @@ -1852,6 +1855,7 @@ let register_tezt_targets ~make_tezt_exe = ?modes ~deps:(lib :: deps) ~dep_globs + ~dep_files ~modules:[exe_name] ~dune: Dune. diff --git a/manifest/manifest.mli b/manifest/manifest.mli index 1cd25805387c..3aa9e70a3763 100644 --- a/manifest/manifest.mli +++ b/manifest/manifest.mli @@ -920,6 +920,7 @@ val tezt : ?exe_deps:target list -> ?js_deps:target list -> ?dep_globs:string list -> + ?dep_files:string list -> ?synopsis:string -> string list -> unit -- GitLab From a4f0df80fd52ef3d7d565f3ad3a239a3b58a12a3 Mon Sep 17 00:00:00 2001 From: Romain Bardou Date: Fri, 4 Nov 2022 10:57:01 +0100 Subject: [PATCH 07/13] Base: migrate tests to Alcotezt --- manifest/main.ml | 7 ++++--- src/lib_base/test/dune | 16 +++++++++++++--- src/lib_base/test/test_bounded.ml | 2 +- src/lib_base/test/test_p2p_addr.ml | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index ce1b9ff7ca75..1ad546c49cd6 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -397,7 +397,7 @@ let alcotezt = "octez-alcotezt" ~path:"tezt/lib_alcotezt" ~synopsis: - "Provide the interface of Alcotest for Octez, but with Tezt as backend." + "Provide the interface of Alcotest for Octez, but with Tezt as backend" ~js_compatible:true ~deps:[tezt_core_lib] |> open_ @@ -1135,7 +1135,7 @@ let octez_base_unix = ] let _octez_base_tests = - tests + tezt [ "test_bounded"; "test_time"; "test_protocol"; "test_p2p_addr"; "test_sized"; ] @@ -1146,8 +1146,9 @@ let _octez_base_tests = octez_base |> open_; octez_error_monad |> open_; data_encoding; - qcheck_alcotest; octez_test_helpers |> open_; + qcheck_alcotest; + alcotezt; ] ~dep_files: [ diff --git a/src/lib_base/test/dune b/src/lib_base/test/dune index af54f30a627d..6f592dc833b8 100644 --- a/src/lib_base/test/dune +++ b/src/lib_base/test/dune @@ -10,15 +10,25 @@ tezos-base tezos-error-monad data-encoding + tezos-test-helpers qcheck-alcotest - tezos-test-helpers) + octez-alcotezt) (js_of_ocaml) (flags (:standard) -open Tezos_base -open Tezos_error_monad - -open Tezos_test_helpers) - (modules test_bounded test_time test_protocol)) + -open Tezos_test_helpers + -open Octez_alcotezt) + (modules test_bounded test_time test_protocol test_p2p_addr test_sized)) + +(executable + (name main) + (modes native) + (libraries + src_lib_base_test_tezt_lib + tezt) + (modules main)) (rule (alias runtest) diff --git a/src/lib_base/test/test_bounded.ml b/src/lib_base/test/test_bounded.ml index c8795c8d9620..cfd150d44e73 100644 --- a/src/lib_base/test/test_bounded.ml +++ b/src/lib_base/test/test_bounded.ml @@ -266,7 +266,7 @@ end = struct in let* ety = oneofl values in match ety with - | E (type a) (ty : a Bounded.Internal_for_tests.t) -> + | E ty -> let* (module S : S) = gen_from_ty ty in let* element = S.gen in return (E' {bounded = (module S); element}) diff --git a/src/lib_base/test/test_p2p_addr.ml b/src/lib_base/test/test_p2p_addr.ml index 55b3b8e1daaf..5b87808e231f 100644 --- a/src/lib_base/test/test_p2p_addr.ml +++ b/src/lib_base/test/test_p2p_addr.ml @@ -117,7 +117,7 @@ let eq l r = eq_addr l.addr r.addr && l.port = r.port && eq_peer_id l.peer_id r.peer_id let process_points filename f = - let file = open_in filename in + let file = open_in (project_root // "src/lib_base/test" // filename) in try while true do f (input_line file) -- GitLab From 1ae7e21adff43c3f69f548cffbccae3a7d5e5dcb Mon Sep 17 00:00:00 2001 From: Romain Bardou Date: Fri, 4 Nov 2022 11:58:31 +0100 Subject: [PATCH 08/13] Benchmark: remove main.ml as it is unused --- src/lib_benchmark/test/main.ml | 28 ------------------------ src/lib_benchmark/test/test_inference.ml | 3 +++ 2 files changed, 3 insertions(+), 28 deletions(-) delete mode 100644 src/lib_benchmark/test/main.ml diff --git a/src/lib_benchmark/test/main.ml b/src/lib_benchmark/test/main.ml deleted file mode 100644 index 73de2b199b6f..000000000000 --- a/src/lib_benchmark/test/main.ml +++ /dev/null @@ -1,28 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2020 Nomadic Labs. *) -(* *) -(* 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 () = - Alcotest_lwt.run "tezos-benchmark" [("inference", Test_inference.tests)] - |> Lwt_main.run diff --git a/src/lib_benchmark/test/test_inference.ml b/src/lib_benchmark/test/test_inference.ml index 882d38d9ead5..c45f43a64155 100644 --- a/src/lib_benchmark/test/test_inference.ml +++ b/src/lib_benchmark/test/test_inference.ml @@ -116,3 +116,6 @@ let test () = 30.0 < T.const && T.const < 36.0 && T.quadratic_term =~ 0.042 let tests = [Test.tztest_assert "regression" `Quick @@ test] + +let () = + Alcotest_lwt.run "tezos-benchmark" [("inference", tests)] |> Lwt_main.run -- GitLab From a54a5f94a417f3df77f97948f69d7bf4ec036bc8 Mon Sep 17 00:00:00 2001 From: Romain Bardou Date: Fri, 4 Nov 2022 11:59:15 +0100 Subject: [PATCH 09/13] Benchmark: convert tests to Alcotezt --- manifest/main.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index 1ad546c49cd6..688b524bae67 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -3041,8 +3041,9 @@ let octez_benchmark_examples = ] let _octez_benchmark_tests = - tests + tezt [ + "test"; "test_sparse_vec"; "test_costlang"; "test_probe"; @@ -3054,7 +3055,7 @@ let _octez_benchmark_tests = ~synopsis:"Tezos: tests for lib-benchmarks" ~deps: [ - alcotest_lwt; + alcotezt; octez_base |> open_ ~m:"TzPervasives"; octez_base_unix; octez_stdlib_unix; -- GitLab From 1cc1be500da0128da09c53fc032e3d54beca0679 Mon Sep 17 00:00:00 2001 From: Romain Bardou Date: Mon, 7 Nov 2022 16:29:57 +0100 Subject: [PATCH 10/13] Manifest: add ?opam_with_test to tezt --- manifest/main.ml | 3 ++- manifest/manifest.ml | 7 ++++++- manifest/manifest.mli | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index 688b524bae67..47d455b7c792 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -403,7 +403,7 @@ let alcotezt = |> open_ let tezt ~opam ~path ?js_compatible ?modes ?(deps = []) ?dep_globs ?dep_files - ?synopsis l = + ?synopsis ?opam_with_test l = tezt_without_tezt_lib_dependency ~opam ~path @@ -415,6 +415,7 @@ let tezt ~opam ~path ?js_compatible ?modes ?(deps = []) ?dep_globs ?dep_files ~js_deps:[tezt_js_lib] ?dep_globs ?dep_files + ?opam_with_test l let octez_test_helpers = diff --git a/manifest/manifest.ml b/manifest/manifest.ml index c4c3ed98ab57..b8ff8c90f305 100644 --- a/manifest/manifest.ml +++ b/manifest/manifest.ml @@ -1787,12 +1787,14 @@ type tezt_target = { js_compatible : bool option; modes : Dune.mode list option; synopsis : string option; + opam_with_test : with_test option; } let tezt_targets_by_path : tezt_target String_map.t ref = ref String_map.empty let tezt ~opam ~path ?js_compatible ?modes ?(lib_deps = []) ?(exe_deps = []) - ?(js_deps = []) ?(dep_globs = []) ?(dep_files = []) ?synopsis modules = + ?(js_deps = []) ?(dep_globs = []) ?(dep_files = []) ?synopsis + ?opam_with_test modules = if String_map.mem path !tezt_targets_by_path then invalid_arg ("cannot call Manifest.tezt twice for the same directory: " ^ path) ; @@ -1808,6 +1810,7 @@ let tezt ~opam ~path ?js_compatible ?modes ?(lib_deps = []) ?(exe_deps = []) js_compatible; modes; synopsis; + opam_with_test; } in tezt_targets_by_path := String_map.add path tezt_target !tezt_targets_by_path @@ -1826,6 +1829,7 @@ let register_tezt_targets ~make_tezt_exe = js_compatible; modes; synopsis; + opam_with_test; } = let path_with_underscores = String.map (function '-' | '/' -> '_' | c -> c) path @@ -1857,6 +1861,7 @@ let register_tezt_targets ~make_tezt_exe = ~dep_globs ~dep_files ~modules:[exe_name] + ?opam_with_test ~dune: Dune. [ diff --git a/manifest/manifest.mli b/manifest/manifest.mli index 3aa9e70a3763..83cee60178c6 100644 --- a/manifest/manifest.mli +++ b/manifest/manifest.mli @@ -922,6 +922,7 @@ val tezt : ?dep_globs:string list -> ?dep_files:string list -> ?synopsis:string -> + ?opam_with_test:with_test -> string list -> unit -- GitLab From 85fabe4be9734a71df0bd5645964263a18ba97cc Mon Sep 17 00:00:00 2001 From: Romain Bardou Date: Mon, 7 Nov 2022 16:30:53 +0100 Subject: [PATCH 11/13] Lwtreslib: port tests to Alcotezt --- manifest/main.ml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index 47d455b7c792..0541a9f24253 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -616,13 +616,18 @@ let octez_lwt_result_stdlib_examples_traces = ~opam_with_test:Only_on_64_arch let _octez_lwt_result_stdlib_tests = - tests + tezt [ + "support"; + "traits"; + "traits_tiered"; "test_hashtbl"; "test_list_basic"; "test_list_basic_lwt"; "test_seq_basic"; "test_generic"; + "test_fuzzing_tests"; + "test_fuzzing_helpers"; "test_fuzzing_seq"; "test_fuzzing_list"; "test_fuzzing_set"; @@ -636,7 +641,7 @@ let _octez_lwt_result_stdlib_tests = octez_lwt_result_stdlib |> open_; octez_lwt_result_stdlib_examples_traces; lwt_unix; - alcotest_lwt; + alcotezt; qcheck_alcotest; octez_test_helpers |> open_; ] -- GitLab From 9816feb743240bcba12b84b5b4bad9b049b9064b Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Fri, 27 Jan 2023 12:11:40 +0100 Subject: [PATCH 12/13] Manifest: generate --- .gitlab/ci/jobs/packaging/opam_package.yml | 2 + dune-project | 1 + opam/octez-alcotezt.opam | 20 +++++ opam/tezos-base.opam | 5 +- opam/tezos-benchmark-tests.opam | 4 +- opam/tezos-error-monad.opam | 4 +- opam/tezos-lwt-result-stdlib.opam | 4 +- src/lib_base/test/dune | 95 +++++----------------- src/lib_benchmark/test/dune | 55 ++++++------- src/lib_error_monad/test/dune | 51 ++++++++---- src/lib_lwt_result_stdlib/test/dune | 94 ++++++++------------- tezt/lib_alcotezt/dune | 10 +++ tezt/tests/dune | 6 +- 13 files changed, 171 insertions(+), 180 deletions(-) create mode 100644 opam/octez-alcotezt.opam create mode 100644 tezt/lib_alcotezt/dune diff --git a/.gitlab/ci/jobs/packaging/opam_package.yml b/.gitlab/ci/jobs/packaging/opam_package.yml index 7c4053d2bc47..2f6403646568 100644 --- a/.gitlab/ci/jobs/packaging/opam_package.yml +++ b/.gitlab/ci/jobs/packaging/opam_package.yml @@ -215,6 +215,8 @@ opam:octez-accuser-PtMumbai: # Ignoring unreleased package octez-accuser-alpha. +# Ignoring unreleased package octez-alcotezt. + opam:octez-baker-PtLimaPt: extends: - .opam_template diff --git a/dune-project b/dune-project index 4565a0c8033c..00f4e61be533 100644 --- a/dune-project +++ b/dune-project @@ -6,6 +6,7 @@ (package (name octez-accuser-PtLimaPt)) (package (name octez-accuser-PtMumbai)) (package (name octez-accuser-alpha)) +(package (name octez-alcotezt)) (package (name octez-baker-PtLimaPt)) (package (name octez-baker-PtMumbai)) (package (name octez-baker-alpha)) diff --git a/opam/octez-alcotezt.opam b/opam/octez-alcotezt.opam new file mode 100644 index 000000000000..92de02f5e009 --- /dev/null +++ b/opam/octez-alcotezt.opam @@ -0,0 +1,20 @@ +# This file was automatically generated, do not edit. +# Edit file manifest/main.ml instead. +opam-version: "2.0" +maintainer: "contact@tezos.com" +authors: ["Tezos devteam"] +homepage: "https://www.tezos.com/" +bug-reports: "https://gitlab.com/tezos/tezos/issues" +dev-repo: "git+https://gitlab.com/tezos/tezos.git" +license: "MIT" +depends: [ + "dune" { >= "3.0" } + "ocaml" { >= "4.14" } + "tezt" { >= "3.0.0" } +] +build: [ + ["rm" "-r" "vendors"] + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] +synopsis: "Provide the interface of Alcotest for Octez, but with Tezt as backend" diff --git a/opam/tezos-base.opam b/opam/tezos-base.opam index ccae4c4d6f5a..c8ad4e8bb842 100644 --- a/opam/tezos-base.opam +++ b/opam/tezos-base.opam @@ -24,12 +24,15 @@ depends: [ "uri" { >= "3.1.0" } "tezos-hacl" "tezos-stdlib-unix" - "qcheck-alcotest" { with-test & >= "0.20" } "tezos-test-helpers" {with-test} + "qcheck-alcotest" { with-test & >= "0.20" } + "tezt" { with-test & >= "3.0.0" } + "octez-alcotezt" {with-test} ] 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: meta-package and pervasive type definitions for Tezos" diff --git a/opam/tezos-benchmark-tests.opam b/opam/tezos-benchmark-tests.opam index d542840b3295..2f7622e316ad 100644 --- a/opam/tezos-benchmark-tests.opam +++ b/opam/tezos-benchmark-tests.opam @@ -10,7 +10,8 @@ license: "MIT" depends: [ "dune" { >= "3.0" } "ocaml" { >= "4.14" } - "alcotest-lwt" { with-test & >= "1.5.0" } + "tezt" { with-test & >= "3.0.0" } + "octez-alcotezt" {with-test} "tezos-base" {with-test} "tezos-stdlib-unix" {with-test} "tezos-micheline" {with-test} @@ -22,5 +23,6 @@ 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: tests for lib-benchmarks" diff --git a/opam/tezos-error-monad.opam b/opam/tezos-error-monad.opam index 401f99dacd55..3074dc58273e 100644 --- a/opam/tezos-error-monad.opam +++ b/opam/tezos-error-monad.opam @@ -15,7 +15,8 @@ depends: [ "lwt-canceler" { >= "0.3" & < "0.4" } "lwt" { >= "5.6.0" } "tezos-lwt-result-stdlib" - "alcotest" { with-test & >= "1.5.0" } + "tezt" { with-test & >= "3.0.0" } + "octez-alcotezt" {with-test} ] conflicts: [ "result" { < "1.5" } @@ -24,5 +25,6 @@ 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: error monad" diff --git a/opam/tezos-lwt-result-stdlib.opam b/opam/tezos-lwt-result-stdlib.opam index 275f1eb38155..d24b598a9d8c 100644 --- a/opam/tezos-lwt-result-stdlib.opam +++ b/opam/tezos-lwt-result-stdlib.opam @@ -11,7 +11,8 @@ depends: [ "dune" { >= "3.0" } "ocaml" { >= "4.14" } "lwt" { >= "5.6.0" } - "alcotest-lwt" { with-test & >= "1.5.0" } + "tezt" { with-test & >= "3.0.0" } + "octez-alcotezt" {with-test} "qcheck-alcotest" { with-test & >= "0.20" } "tezos-test-helpers" {with-test} ] @@ -19,5 +20,6 @@ build: [ ["rm" "-r" "vendors"] ["dune" "build" "-p" name "-j" jobs] ["dune" "runtest" "-p" name "-j" jobs] { with-test & arch != "arm32" & arch != "x86_32" } + ["dune" "build" "@runtezt" "-p" name "-j" jobs] { with-test & arch != "arm32" & arch != "x86_32" } ] synopsis: "Tezos: error-aware stdlib replacement" diff --git a/src/lib_base/test/dune b/src/lib_base/test/dune index 6f592dc833b8..f70a1b5aeef2 100644 --- a/src/lib_base/test/dune +++ b/src/lib_base/test/dune @@ -3,10 +3,11 @@ (env (_ (env-vars (NODE_PRELOAD hacl-wasm,ocaml-bls12-381,secp256k1-wasm)))) -(executables - (names test_bounded test_time test_protocol) - (modes native js) +(library + (name src_lib_base_test_tezt_lib) + (instrumentation (backend bisect_ppx)) (libraries + tezt.core tezos-base tezos-error-monad data-encoding @@ -14,8 +15,11 @@ qcheck-alcotest octez-alcotezt) (js_of_ocaml) + (library_flags (:standard -linkall)) (flags (:standard) + -open Tezt_core + -open Tezt_core.Base -open Tezos_base -open Tezos_error_monad -open Tezos_test_helpers @@ -31,87 +35,30 @@ (modules main)) (rule - (alias runtest) - (package tezos-base) - (action (run %{dep:./test_bounded.exe}))) - -(rule - (alias runtest) - (package tezos-base) - (action (run %{dep:./test_time.exe}))) - -(rule - (alias runtest) - (package tezos-base) - (action (run %{dep:./test_protocol.exe}))) - -(rule - (alias runtest_js) - (package tezos-base) - (action (run node %{dep:./test_bounded.bc.js}))) - -(rule - (alias runtest_js) - (package tezos-base) - (action (run node %{dep:./test_time.bc.js}))) - -(rule - (alias runtest_js) - (package tezos-base) - (action (run node %{dep:./test_protocol.bc.js}))) - -(executable - (name test_p2p_addr) - (modes native js) - (libraries - tezos-base - tezos-error-monad - data-encoding - qcheck-alcotest - tezos-test-helpers) - (js_of_ocaml) - (flags - (:standard) - -open Tezos_base - -open Tezos_error_monad - -open Tezos_test_helpers) - (modules test_p2p_addr)) - -(rule - (alias runtest) + (alias runtezt) (package tezos-base) (deps points.ok points.ko) - (action (run %{dep:./test_p2p_addr.exe}))) + (action (run %{dep:./main.exe}))) (rule - (alias runtest_js) - (package tezos-base) - (deps points.ok points.ko) - (action (run node %{dep:./test_p2p_addr.bc.js}))) + (targets main.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt.Test.run ()")))) (executable - (name test_sized) - (modes native js) + (name main_js) + (modes js) (libraries - tezos-base - tezos-error-monad - data-encoding - qcheck-alcotest - tezos-test-helpers) + src_lib_base_test_tezt_lib + tezt.js) (js_of_ocaml) - (flags - (:standard) - -open Tezos_base - -open Tezos_error_monad - -open Tezos_test_helpers) - (modules test_sized)) + (modules main_js)) (rule - (alias runtest) + (alias runtezt_js) (package tezos-base) - (action (run %{dep:./test_sized.exe}))) + (deps points.ok points.ko) + (action (run node %{dep:./main_js.bc.js}))) (rule - (alias runtest_js) - (package tezos-base) - (action (run node %{dep:./test_sized.bc.js}))) + (targets main_js.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt_js.Test.run ()")))) diff --git a/src/lib_benchmark/test/dune b/src/lib_benchmark/test/dune index 9c04c4134e76..8ce01ffb4c92 100644 --- a/src/lib_benchmark/test/dune +++ b/src/lib_benchmark/test/dune @@ -1,15 +1,12 @@ ; This file was automatically generated, do not edit. ; Edit file manifest/main.ml instead. -(executables - (names - test_sparse_vec - test_costlang - test_probe - test_measure - test_benchmark_helpers) +(library + (name src_lib_benchmark_test_tezt_lib) + (instrumentation (backend bisect_ppx)) (libraries - alcotest-lwt + tezt.core + octez-alcotezt tezos-base tezos-base.unix tezos-stdlib-unix @@ -17,31 +14,33 @@ tezos-crypto tezos-benchmark tezos-benchmark-examples) + (library_flags (:standard -linkall)) (flags (:standard) - -open Tezos_base.TzPervasives)) - -(rule - (alias runtest) - (package tezos-benchmark-tests) - (action (run %{dep:./test_sparse_vec.exe}))) - -(rule - (alias runtest) - (package tezos-benchmark-tests) - (action (run %{dep:./test_costlang.exe}))) + -open Tezt_core + -open Tezt_core.Base + -open Octez_alcotezt + -open Tezos_base.TzPervasives) + (modules + test + test_sparse_vec + test_costlang + test_probe + test_measure + test_benchmark_helpers)) -(rule - (alias runtest) - (package tezos-benchmark-tests) - (action (run %{dep:./test_probe.exe}))) +(executable + (name main) + (libraries + src_lib_benchmark_test_tezt_lib + tezt) + (modules main)) (rule - (alias runtest) + (alias runtezt) (package tezos-benchmark-tests) - (action (run %{dep:./test_measure.exe}))) + (action (run %{dep:./main.exe}))) (rule - (alias runtest) - (package tezos-benchmark-tests) - (action (run %{dep:./test_benchmark_helpers.exe}))) + (targets main.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt.Test.run ()")))) diff --git a/src/lib_error_monad/test/dune b/src/lib_error_monad/test/dune index 8af814890519..384c1c1638e7 100644 --- a/src/lib_error_monad/test/dune +++ b/src/lib_error_monad/test/dune @@ -1,34 +1,55 @@ ; This file was automatically generated, do not edit. ; Edit file manifest/main.ml instead. -(executables - (names test_registration test_splitted_error_encoding) - (modes native js) +(library + (name src_lib_error_monad_test_tezt_lib) + (instrumentation (backend bisect_ppx)) (libraries + tezt.core tezos-error-monad data-encoding - alcotest) + octez-alcotezt) (js_of_ocaml) + (library_flags (:standard -linkall)) (flags (:standard) - -open Tezos_error_monad)) + -open Tezt_core + -open Tezt_core.Base + -open Tezos_error_monad + -open Octez_alcotezt) + (modules test_registration test_splitted_error_encoding)) + +(executable + (name main) + (modes native) + (libraries + src_lib_error_monad_test_tezt_lib + tezt) + (modules main)) (rule - (alias runtest) + (alias runtezt) (package tezos-error-monad) - (action (run %{dep:./test_registration.exe}))) + (action (run %{dep:./main.exe}))) (rule - (alias runtest) - (package tezos-error-monad) - (action (run %{dep:./test_splitted_error_encoding.exe}))) + (targets main.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt.Test.run ()")))) + +(executable + (name main_js) + (modes js) + (libraries + src_lib_error_monad_test_tezt_lib + tezt.js) + (js_of_ocaml) + (modules main_js)) (rule - (alias runtest_js) + (alias runtezt_js) (package tezos-error-monad) - (action (run node %{dep:./test_registration.bc.js}))) + (action (run node %{dep:./main_js.bc.js}))) (rule - (alias runtest_js) - (package tezos-error-monad) - (action (run node %{dep:./test_splitted_error_encoding.bc.js}))) + (targets main_js.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt_js.Test.run ()")))) diff --git a/src/lib_lwt_result_stdlib/test/dune b/src/lib_lwt_result_stdlib/test/dune index 3c0211239106..e4cbb73ad6bb 100644 --- a/src/lib_lwt_result_stdlib/test/dune +++ b/src/lib_lwt_result_stdlib/test/dune @@ -1,76 +1,54 @@ ; This file was automatically generated, do not edit. ; Edit file manifest/main.ml instead. -(executables - (names - test_hashtbl - test_list_basic - test_list_basic_lwt - test_seq_basic - test_generic - test_fuzzing_seq - test_fuzzing_list - test_fuzzing_set - test_fuzzing_seq_tiered - test_fuzzing_option) +(library + (name src_lib_lwt_result_stdlib_test_tezt_lib) + (instrumentation (backend bisect_ppx)) (libraries + tezt.core tezos-lwt-result-stdlib tezos-lwt-result-stdlib.examples.traces lwt.unix - alcotest-lwt + octez-alcotezt qcheck-alcotest tezos-test-helpers) + (library_flags (:standard -linkall)) (flags (:standard) + -open Tezt_core + -open Tezt_core.Base -open Tezos_lwt_result_stdlib - -open Tezos_test_helpers)) - -(rule - (alias runtest) - (package tezos-lwt-result-stdlib) - (action (run %{dep:./test_hashtbl.exe}))) - -(rule - (alias runtest) - (package tezos-lwt-result-stdlib) - (action (run %{dep:./test_list_basic.exe}))) - -(rule - (alias runtest) - (package tezos-lwt-result-stdlib) - (action (run %{dep:./test_list_basic_lwt.exe}))) - -(rule - (alias runtest) - (package tezos-lwt-result-stdlib) - (action (run %{dep:./test_seq_basic.exe}))) - -(rule - (alias runtest) - (package tezos-lwt-result-stdlib) - (action (run %{dep:./test_generic.exe}))) - -(rule - (alias runtest) - (package tezos-lwt-result-stdlib) - (action (run %{dep:./test_fuzzing_seq.exe}))) - -(rule - (alias runtest) - (package tezos-lwt-result-stdlib) - (action (run %{dep:./test_fuzzing_list.exe}))) + -open Octez_alcotezt + -open Tezos_test_helpers) + (modules + support + traits + traits_tiered + test_hashtbl + test_list_basic + test_list_basic_lwt + test_seq_basic + test_generic + test_fuzzing_tests + test_fuzzing_helpers + test_fuzzing_seq + test_fuzzing_list + test_fuzzing_set + test_fuzzing_seq_tiered + test_fuzzing_option)) -(rule - (alias runtest) - (package tezos-lwt-result-stdlib) - (action (run %{dep:./test_fuzzing_set.exe}))) +(executable + (name main) + (libraries + src_lib_lwt_result_stdlib_test_tezt_lib + tezt) + (modules main)) (rule - (alias runtest) + (alias runtezt) (package tezos-lwt-result-stdlib) - (action (run %{dep:./test_fuzzing_seq_tiered.exe}))) + (action (run %{dep:./main.exe}))) (rule - (alias runtest) - (package tezos-lwt-result-stdlib) - (action (run %{dep:./test_fuzzing_option.exe}))) + (targets main.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt.Test.run ()")))) diff --git a/tezt/lib_alcotezt/dune b/tezt/lib_alcotezt/dune new file mode 100644 index 000000000000..a89575f1e1e2 --- /dev/null +++ b/tezt/lib_alcotezt/dune @@ -0,0 +1,10 @@ +; This file was automatically generated, do not edit. +; Edit file manifest/main.ml instead. + +(library + (name octez_alcotezt) + (public_name octez-alcotezt) + (instrumentation (backend bisect_ppx)) + (libraries + tezt.core) + (js_of_ocaml)) diff --git a/tezt/tests/dune b/tezt/tests/dune index 3c2151e23c03..24a1289a86af 100644 --- a/tezt/tests/dune +++ b/tezt/tests/dune @@ -15,7 +15,11 @@ tezos-protocol-alpha src_proto_alpha_lib_protocol_test_regression_tezt_lib src_proto_016_PtMumbai_lib_protocol_test_regression_tezt_lib - src_proto_015_PtLimaPt_lib_protocol_test_regression_tezt_lib) + src_proto_015_PtLimaPt_lib_protocol_test_regression_tezt_lib + src_lib_lwt_result_stdlib_test_tezt_lib + src_lib_error_monad_test_tezt_lib + src_lib_benchmark_test_tezt_lib + src_lib_base_test_tezt_lib) (flags (:standard) -open Tezt -- GitLab From 2d8ea68c68d633658044216045691475a45f8240 Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Tue, 31 Jan 2023 15:44:52 +0100 Subject: [PATCH 13/13] Manifest: make octez-alcotezt a release package --- .gitlab/ci/jobs/packaging/opam_package.yml | 7 ++++++- manifest/main.ml | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/jobs/packaging/opam_package.yml b/.gitlab/ci/jobs/packaging/opam_package.yml index 2f6403646568..fad56f2e5608 100644 --- a/.gitlab/ci/jobs/packaging/opam_package.yml +++ b/.gitlab/ci/jobs/packaging/opam_package.yml @@ -215,7 +215,12 @@ opam:octez-accuser-PtMumbai: # Ignoring unreleased package octez-accuser-alpha. -# Ignoring unreleased package octez-alcotezt. +opam:octez-alcotezt: + extends: + - .opam_template + - .rules_template__trigger_opam_batch_7 + variables: + package: octez-alcotezt opam:octez-baker-PtLimaPt: extends: diff --git a/manifest/main.ml b/manifest/main.ml index 0541a9f24253..4741d79ba572 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -396,6 +396,12 @@ let alcotezt = public_lib "octez-alcotezt" ~path:"tezt/lib_alcotezt" + (* TODO: https://gitlab.com/tezos/tezos/-/issues/4727 + + we mark "octez-alcotezt" as released but the real solution is to + modify the manifest to add build instructions for dune to be + used `with-test` *) + ~release_status:Released ~synopsis: "Provide the interface of Alcotest for Octez, but with Tezt as backend" ~js_compatible:true -- GitLab