From f5f8c53d5eabfda7bf182c6202de4af3db1e0acd Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Fri, 10 Mar 2023 13:54:13 +0100 Subject: [PATCH] lib_webassembly: port tests to alcotezt --- manifest/main.ml | 9 ++++---- manifest/manifest.ml | 7 +++++- manifest/manifest.mli | 1 + opam/tezos-webassembly-interpreter.opam | 4 +++- src/lib_webassembly/tests/dune | 30 ++++++++++++++++++++----- src/lib_webassembly/tests/main.ml | 3 --- src/lib_webassembly/tests/smallint.ml | 4 +++- tezt/tests/dune | 1 + 8 files changed, 43 insertions(+), 16 deletions(-) delete mode 100644 src/lib_webassembly/tests/main.ml diff --git a/manifest/main.ml b/manifest/main.ml index d96046e6704e..e70d83d46042 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -387,7 +387,7 @@ let tezt_js_lib = external_sublib tezt_lib ~js_compatible:true "tezt.js" let tezt ~opam ~path ?js_compatible ?modes ?(deps = []) ?dep_globs ?dep_globs_rec ?dep_files ?opam_with_test ?synopsis - ?(with_macos_security_framework = false) l = + ?(with_macos_security_framework = false) ?dune l = tezt_without_tezt_lib_dependency ~with_macos_security_framework ~opam @@ -402,6 +402,7 @@ let tezt ~opam ~path ?js_compatible ?modes ?(deps = []) ?dep_globs ?dep_globs_rec ?dep_files ?opam_with_test + ?dune l (* The main module [Octez_alcotest] is [open_] so that one can replace @@ -1347,12 +1348,12 @@ let _octez_webassembly_repl = ] let _octez_webassembly_test = - test - "main" + tezt + ["smallint"] ~path:"src/lib_webassembly/tests" ~opam:"tezos-webassembly-interpreter" ~dune:Dune.[[S "include_subdirs"; S "no"]] - ~deps:[octez_webassembly_interpreter |> open_; alcotest] + ~deps:[octez_webassembly_interpreter |> open_; alcotezt] let octez_version_parser = public_lib diff --git a/manifest/manifest.ml b/manifest/manifest.ml index 7863af64a763..8a799c691026 100644 --- a/manifest/manifest.ml +++ b/manifest/manifest.ml @@ -1797,13 +1797,15 @@ type tezt_target = { synopsis : string option; opam_with_test : with_test option; with_macos_security_framework : bool; + dune : Dune.s_expr; } 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_globs_rec = []) ?(dep_files = []) - ?synopsis ?opam_with_test ?(with_macos_security_framework = false) modules = + ?synopsis ?opam_with_test ?(with_macos_security_framework = false) + ?(dune = Dune.[]) modules = if String_map.mem path !tezt_targets_by_path then invalid_arg ("cannot call Manifest.tezt twice for the same directory: " ^ path) ; @@ -1822,6 +1824,7 @@ let tezt ~opam ~path ?js_compatible ?modes ?(lib_deps = []) ?(exe_deps = []) synopsis; opam_with_test; with_macos_security_framework; + dune; } in tezt_targets_by_path := String_map.add path tezt_target !tezt_targets_by_path @@ -1843,6 +1846,7 @@ let register_tezt_targets ~make_tezt_exe = synopsis; opam_with_test; with_macos_security_framework; + dune; } = let path_with_underscores = String.map (function '-' | '/' -> '_' | c -> c) path @@ -1858,6 +1862,7 @@ let register_tezt_targets ~make_tezt_exe = ~deps:lib_deps ~modules ~linkall:true + ~dune in tezt_test_libs := lib :: !tezt_test_libs ; let declare_exe ?js_compatible exe_name modes deps main = diff --git a/manifest/manifest.mli b/manifest/manifest.mli index 74a395da8a38..2536a2f78a5c 100644 --- a/manifest/manifest.mli +++ b/manifest/manifest.mli @@ -934,6 +934,7 @@ val tezt : ?synopsis:string -> ?opam_with_test:with_test -> ?with_macos_security_framework:bool -> + ?dune:Dune.s_expr -> string list -> unit diff --git a/opam/tezos-webassembly-interpreter.opam b/opam/tezos-webassembly-interpreter.opam index 6eab9ec459f8..c1e6271a2c4b 100644 --- a/opam/tezos-webassembly-interpreter.opam +++ b/opam/tezos-webassembly-interpreter.opam @@ -16,11 +16,13 @@ depends: [ "tezos-error-monad" "zarith" { >= "1.12" & < "1.13" } "tezos-lazy-containers" - "alcotest" { with-test & >= "1.5.0" } + "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: "WebAssembly reference interpreter with tweaks for Tezos" diff --git a/src/lib_webassembly/tests/dune b/src/lib_webassembly/tests/dune index 3baa8375c135..3dc399bc0592 100644 --- a/src/lib_webassembly/tests/dune +++ b/src/lib_webassembly/tests/dune @@ -1,18 +1,36 @@ ; This file was automatically generated, do not edit. ; Edit file manifest/main.ml instead. -(executable - (name main) +(library + (name src_lib_webassembly_tests_tezt_lib) + (instrumentation (backend bisect_ppx)) (libraries + tezt.core tezos-webassembly-interpreter - alcotest) + octez-alcotezt) + (library_flags (:standard -linkall)) (flags (:standard) - -open Tezos_webassembly_interpreter)) + -open Tezt_core + -open Tezt_core.Base + -open Tezos_webassembly_interpreter + -open Octez_alcotezt) + (modules smallint)) + +(include_subdirs no) + +(executable + (name main) + (libraries + src_lib_webassembly_tests_tezt_lib + tezt) + (modules main)) (rule - (alias runtest) + (alias runtezt) (package tezos-webassembly-interpreter) (action (run %{dep:./main.exe}))) -(include_subdirs no) +(rule + (targets main.ml) + (action (with-stdout-to %{targets} (echo "let () = Tezt.Test.run ()")))) diff --git a/src/lib_webassembly/tests/main.ml b/src/lib_webassembly/tests/main.ml deleted file mode 100644 index 3e187136e3a8..000000000000 --- a/src/lib_webassembly/tests/main.ml +++ /dev/null @@ -1,3 +0,0 @@ -let tests = [("Smallint", Smallint.tests)] - -let () = Alcotest.run "WebAssembly reference interpreter tests" tests diff --git a/src/lib_webassembly/tests/smallint.ml b/src/lib_webassembly/tests/smallint.ml index 235adaeec461..e83e7a2bd5db 100644 --- a/src/lib_webassembly/tests/smallint.ml +++ b/src/lib_webassembly/tests/smallint.ml @@ -116,4 +116,6 @@ let check () = assert_equal 15l (I16.popcnt s16max) ; assert_equal 7l (I8.popcnt s8max) -let tests = [Alcotest.test_case "Check_smallint" `Quick check] +let tests = [("Smallint", [Alcotest.test_case "Check_smallint" `Quick check])] + +let () = Alcotest.run "WebAssembly reference interpreter tests" tests diff --git a/tezt/tests/dune b/tezt/tests/dune index f7da14044a1a..e6f8f79d8ec4 100644 --- a/tezt/tests/dune +++ b/tezt/tests/dune @@ -57,6 +57,7 @@ src_proto_012_Psithaca_lib_client_test_tezt_lib src_proto_011_PtHangz2_lib_client_test_tezt_lib src_lib_workers_test_tezt_lib + src_lib_webassembly_tests_tezt_lib src_lib_stdlib_unix_test__tezt_lib src_lib_stdlib_test_unix_tezt_lib src_lib_stdlib_test_tezt_lib -- GitLab