From 3b2cd786e2ca45b2d3e941f2206964f830fda775 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sat, 2 Jul 2022 22:12:40 -0400 Subject: [PATCH] finish removing qtest --- README.md | 8 ++--- containers-data.opam | 3 +- containers-thread.opam | 3 +- containers.opam | 4 +-- qtest/dune | 62 ---------------------------------- qtest/make.ml | 74 ----------------------------------------- tests/data/t_misc.ml | 2 -- tests/data/t_mutheap.ml | 1 - 8 files changed, 7 insertions(+), 150 deletions(-) delete mode 100644 qtest/dune delete mode 100644 qtest/make.ml diff --git a/README.md b/README.md index 1191d178..4d362a0e 100644 --- a/README.md +++ b/README.md @@ -266,10 +266,10 @@ You need dune (formerly jbuilder). $ make ``` -To build and run tests (requires `oUnit`, [qtest](https://github.com/vincent-hugot/qtest), `gen`, `iter`): +To build and run tests (requires `qcheck-core`, `gen`, `iter`): ``` -$ opam install oUnit qtest +$ opam install qcheck-core $ make test ``` @@ -302,7 +302,7 @@ to list authors based on the git commits. Assuming your are in a clone of the repository: 1. Some dependencies are required, you'll need - `opam install benchmark qcheck qtest iter gen mdx uutf`. + `opam install benchmark qcheck-core iter gen mdx uutf`. 2. run `make all` to enable everything (including tests). 3. make your changes, commit, push, and open a PR. 4. use `make test` without moderation! It must pass before a PR @@ -318,7 +318,7 @@ A few guidelines to follow the philosophy of containers: - no dependencies between basic modules (even just for signatures); - add `@since` tags for new functions; -- add tests if possible (using [qtest](https://github.com/vincent-hugot/qtest/)). +- add tests if possible (see `tests/` dir) There are numerous inline tests already, to see what it looks like search for comments starting with `(*$` in source files. diff --git a/containers-data.opam b/containers-data.opam index bf17602f..a66b0802 100644 --- a/containers-data.opam +++ b/containers-data.opam @@ -14,8 +14,7 @@ depends: [ "dune" { >= "2.0" } "containers" { = version } "seq" - "qtest" { with-test } - "qcheck" { with-test } + "qcheck-core" { with-test } "ounit" { with-test } "iter" { with-test } "gen" { with-test } diff --git a/containers-thread.opam b/containers-thread.opam index eb9adaab..2fdb8034 100644 --- a/containers-thread.opam +++ b/containers-thread.opam @@ -16,8 +16,7 @@ depends: [ "dune-configurator" "containers" { = version } "iter" { with-test } - "qtest" { with-test } - "qcheck" { with-test } + "qcheck-core" { with-test } "ounit" { with-test } "uutf" { with-test } "odoc" { with-doc } diff --git a/containers.opam b/containers.opam index 7f5fe570..e37930de 100644 --- a/containers.opam +++ b/containers.opam @@ -16,9 +16,7 @@ depends: [ "dune-configurator" "seq" # compat "either" # compat - "qtest" { with-test } - "qcheck" { >= "0.14" & with-test } - "ounit2" { with-test } + "qcheck-core" { >= "0.14" & with-test } "yojson" { with-test } "iter" { with-test } "gen" { with-test } diff --git a/qtest/dune b/qtest/dune deleted file mode 100644 index b74244da..00000000 --- a/qtest/dune +++ /dev/null @@ -1,62 +0,0 @@ - -(executable - (name make) - (flags :standard -warn-error -a) - (modules make)) - -(rule - (targets run_qtest.ml) - (deps ./make.exe (source_tree ../src)) - (action (run ./make.exe -target %{targets} ../src/core ../src/bencode ../src/unix/))) - -(executable - (name run_qtest) - (modes native) - (modules run_qtest) - ; disable some warnings in qtests - (flags :standard -warn-error -a -w -3-33-35-27-39-50) - (libraries iter gen qcheck containers containers.unix containers.bencode unix uutf threads)) - -(rule - (alias runtest) - (locks /ctest) - (package containers) - (action (run ./run_qtest.exe))) - -(rule - (targets run_qtest_data.ml) - (deps make.exe (source_tree ../src/data)) - (action (run ./make.exe -target %{targets} ../src/data))) - -(executable - (name run_qtest_data) - (modes native) - (modules run_qtest_data) - ; disable some warnings in qtests - (flags :standard -warn-error -a -w -3-33-35-27-39-50) - (libraries iter gen qcheck containers containers-data)) - -(rule - (alias runtest) - (package containers-data) - (locks /ctest) - (action (run ./run_qtest_data.exe))) - -(rule - (targets run_qtest_thread.ml) - (deps make.exe (source_tree ../src/threads)) - (action (run ./make.exe -target %{targets} ../src/threads))) - -(executable - (name run_qtest_thread) - (modes native) - (modules run_qtest_thread) - ; disable some warnings in qtests - (flags :standard -warn-error -a -w -3-33-35-27-39-50) - (libraries qcheck containers containers-thread iter threads)) - -(rule - (alias runtest) - (locks /ctest) - (package containers-thread) - (action (run ./run_qtest_thread.exe))) diff --git a/qtest/make.ml b/qtest/make.ml deleted file mode 100644 index 390400e5..00000000 --- a/qtest/make.ml +++ /dev/null @@ -1,74 +0,0 @@ -let str_sub ?(offset=0) ~sub:s' s = - let open String in - let rec aux i = - i= length s then false - else get s (i+j) = get s' j && aux_sub i (j+1) - in - aux offset - -let is_suffix ~sub s = - String.length s >= String.length sub && - str_sub ~offset:(String.length s - String.length sub) ~sub s - -let is_code file = is_suffix ~sub:".ml" file || is_suffix ~sub:".mli" file - -let do_not_test file = - assert (not (is_suffix ~sub:"make.ml" file)); - str_sub ~sub:"Labels.ml" file || - is_suffix ~sub:".pp.ml" file || - (if Sys.ocaml_version < "4.08" then Filename.basename file = "CCFormat.ml" else false) || - is_suffix ~sub:".pp.mli" file || - is_suffix ~sub:"containers.ml" file || - is_suffix ~sub:"_top.ml" file || - is_suffix ~sub:"cpp.ml" file || - is_suffix ~sub:"check_labelled_mods.ml" file || - is_suffix ~sub:"test_random.ml" file || - is_suffix ~sub:"test_hash.ml" file || - is_suffix ~sub:"test_csexp.ml" file || - is_suffix ~sub:"utop.ml" file - -let prefix = "src" -let dirs = List.map (fun s-> Filename.concat prefix s) - -let list_files dir : string list = - let rec f ~prefix acc file = - let file = Filename.concat prefix file in - if Sys.is_directory file then ( - Array.fold_left (f ~prefix:file) acc (Sys.readdir file) - ) else ( - if is_code file && not (do_not_test file) then file :: acc else acc - ) - in - f ~prefix:"" [] dir - -let run_qtest target dirs = - let files = - dirs - |> List.map list_files - |> List.flatten - |> List.map (Printf.sprintf "'%s'") - |> String.concat " " - in - let cmd = - Printf.sprintf "qtest extract --preamble 'open CCShims_;; open CCFun;;' -o %S %s 2>/dev/null" - target files - in - exit (Sys.command cmd) - -let () = - let target = ref "" in - let dirs = ref [] in - Arg.parse ["-target", Arg.Set_string target, " set target"] - (fun d -> dirs := d :: !dirs) "make.ml -target file dir+"; - if !target="" then failwith "please specify a target"; - if Sys.command "command -v qtest > /dev/null" <> 0 then ( - (* create empty file *) - let out = open_out !target in - output_string out ""; - close_out out; - ) else ( - run_qtest !target !dirs - ) diff --git a/tests/data/t_misc.ml b/tests/data/t_misc.ml index c4d4e89b..8b0de83d 100644 --- a/tests/data/t_misc.ml +++ b/tests/data/t_misc.ml @@ -4,7 +4,6 @@ module Test = (val Containers_testlib.make ~__FILE__()) open Test module Mixmap = struct - open CCMixmap;; t @@ fun () -> let module M = CCMixmap.Make(CCInt) in @@ -138,7 +137,6 @@ module Mixtbl = struct end module Multiset = struct - open CCMultiSet;; t @@ fun () -> let module S = CCMultiSet.Make(String) in S.count (S.add_mult S.empty "a" 5) "a" = 5;; diff --git a/tests/data/t_mutheap.ml b/tests/data/t_mutheap.ml index 7cd4e0e1..3212c267 100644 --- a/tests/data/t_mutheap.ml +++ b/tests/data/t_mutheap.ml @@ -2,7 +2,6 @@ module Test = (val Containers_testlib.make ~__FILE__()) open Test -open CCMutHeap;; type elt = { x: string;