From b52c33aa40d7e5399e728bc2a2353916118841e9 Mon Sep 17 00:00:00 2001 From: Romain Bardou Date: Mon, 7 Nov 2022 16:30:53 +0100 Subject: [PATCH] Lwtreslib: port tests to Alcotezt --- manifest/main.ml | 38 +++++++----- opam/tezos-lwt-result-stdlib.opam | 4 +- src/lib_lwt_result_stdlib/test/dune | 93 +++++++++++------------------ tezt/tests/dune | 3 +- 4 files changed, 62 insertions(+), 76 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index 591b2d4290ef..682d4b96f1d8 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -389,11 +389,26 @@ let tezt_core_lib = let tezt_js_lib = external_sublib tezt_lib ~js_compatible:true "tezt.js" +let tezt ~opam ~path ?js_compatible ?modes ?(deps = []) ?dep_globs + ?opam_with_test ?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 + ?opam_with_test + l + (* 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 = +let alcotezt = public_lib "octez-alcotezt" ~path:"tezt/lib_alcotezt" @@ -607,12 +622,16 @@ let octez_lwt_result_stdlib_examples_traces = ~opam_with_test:Only_on_64_arch let _octez_lwt_result_stdlib_tests = - tests + tezt [ + "support"; + "traits_tiered"; "test_hashtbl"; "test_list_basic"; "test_list_basic_lwt"; "test_seq_basic"; + "test_fuzzing_helpers"; + "test_fuzzing_lib"; "test_fuzzing_seq_tiered"; "test_fuzzing_seq_against_stdlib"; "test_fuzzing_list_against_stdlib"; @@ -627,7 +646,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_; ] @@ -1533,19 +1552,6 @@ let octez_p2p = prometheus; ] -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" 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_lwt_result_stdlib/test/dune b/src/lib_lwt_result_stdlib/test/dune index 1db2686220b1..e157486abf08 100644 --- a/src/lib_lwt_result_stdlib/test/dune +++ b/src/lib_lwt_result_stdlib/test/dune @@ -1,76 +1,53 @@ ; 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_fuzzing_seq_tiered - test_fuzzing_seq_against_stdlib - test_fuzzing_list_against_stdlib - test_fuzzing_option_against_stdlib - test_fuzzing_set_against_stdlib - test_fuzzing_map_against_stdlib) +(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_fuzzing_seq_tiered.exe}))) - -(rule - (alias runtest) - (package tezos-lwt-result-stdlib) - (action (run %{dep:./test_fuzzing_seq_against_stdlib.exe}))) - -(rule - (alias runtest) - (package tezos-lwt-result-stdlib) - (action (run %{dep:./test_fuzzing_list_against_stdlib.exe}))) + -open Octez_alcotezt + -open Tezos_test_helpers) + (modules + support + traits_tiered + test_hashtbl + test_list_basic + test_list_basic_lwt + test_seq_basic + test_fuzzing_helpers + test_fuzzing_lib + test_fuzzing_seq_tiered + test_fuzzing_seq_against_stdlib + test_fuzzing_list_against_stdlib + test_fuzzing_option_against_stdlib + test_fuzzing_set_against_stdlib + test_fuzzing_map_against_stdlib)) -(rule - (alias runtest) - (package tezos-lwt-result-stdlib) - (action (run %{dep:./test_fuzzing_option_against_stdlib.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_set_against_stdlib.exe}))) + (action (run %{dep:./main.exe}))) (rule - (alias runtest) - (package tezos-lwt-result-stdlib) - (action (run %{dep:./test_fuzzing_map_against_stdlib.exe}))) + (targets main.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt.Test.run ()")))) diff --git a/tezt/tests/dune b/tezt/tests/dune index 5f6fea216d84..9c45c39e3c6a 100644 --- a/tezt/tests/dune +++ b/tezt/tests/dune @@ -16,7 +16,8 @@ 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_lib_p2p_tezt_tezt_lib) + src_lib_p2p_tezt_tezt_lib + src_lib_lwt_result_stdlib_test_tezt_lib) (flags (:standard) -open Tezt -- GitLab