finish removing qtest

This commit is contained in:
Simon Cruanes 2022-07-02 22:12:40 -04:00
parent 1e4a22fbf2
commit 3b2cd786e2
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
8 changed files with 7 additions and 150 deletions

View file

@ -266,10 +266,10 @@ You need dune (formerly jbuilder).
$ make $ 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 $ make test
``` ```
@ -302,7 +302,7 @@ to list authors based on the git commits.
Assuming your are in a clone of the repository: Assuming your are in a clone of the repository:
1. Some dependencies are required, you'll need 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). 2. run `make all` to enable everything (including tests).
3. make your changes, commit, push, and open a PR. 3. make your changes, commit, push, and open a PR.
4. use `make test` without moderation! It must pass before 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); - no dependencies between basic modules (even just for signatures);
- add `@since` tags for new functions; - 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, There are numerous inline tests already,
to see what it looks like search for comments starting with `(*$` to see what it looks like search for comments starting with `(*$`
in source files. in source files.

View file

@ -14,8 +14,7 @@ depends: [
"dune" { >= "2.0" } "dune" { >= "2.0" }
"containers" { = version } "containers" { = version }
"seq" "seq"
"qtest" { with-test } "qcheck-core" { with-test }
"qcheck" { with-test }
"ounit" { with-test } "ounit" { with-test }
"iter" { with-test } "iter" { with-test }
"gen" { with-test } "gen" { with-test }

View file

@ -16,8 +16,7 @@ depends: [
"dune-configurator" "dune-configurator"
"containers" { = version } "containers" { = version }
"iter" { with-test } "iter" { with-test }
"qtest" { with-test } "qcheck-core" { with-test }
"qcheck" { with-test }
"ounit" { with-test } "ounit" { with-test }
"uutf" { with-test } "uutf" { with-test }
"odoc" { with-doc } "odoc" { with-doc }

View file

@ -16,9 +16,7 @@ depends: [
"dune-configurator" "dune-configurator"
"seq" # compat "seq" # compat
"either" # compat "either" # compat
"qtest" { with-test } "qcheck-core" { >= "0.14" & with-test }
"qcheck" { >= "0.14" & with-test }
"ounit2" { with-test }
"yojson" { with-test } "yojson" { with-test }
"iter" { with-test } "iter" { with-test }
"gen" { with-test } "gen" { with-test }

View file

@ -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)))

View file

@ -1,74 +0,0 @@
let str_sub ?(offset=0) ~sub:s' s =
let open String in
let rec aux i =
i<length s && (aux_sub i 0 || aux (i+1))
and aux_sub i j =
if j = length s' then true
else if i+j >= 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
)

View file

@ -4,7 +4,6 @@ module Test = (val Containers_testlib.make ~__FILE__())
open Test open Test
module Mixmap = struct module Mixmap = struct
open CCMixmap;;
t @@ fun () -> t @@ fun () ->
let module M = CCMixmap.Make(CCInt) in let module M = CCMixmap.Make(CCInt) in
@ -138,7 +137,6 @@ module Mixtbl = struct
end end
module Multiset = struct module Multiset = struct
open CCMultiSet;;
t @@ fun () -> let module S = CCMultiSet.Make(String) in t @@ fun () -> let module S = CCMultiSet.Make(String) in
S.count (S.add_mult S.empty "a" 5) "a" = 5;; S.count (S.add_mult S.empty "a" 5) "a" = 5;;

View file

@ -2,7 +2,6 @@
module Test = (val Containers_testlib.make ~__FILE__()) module Test = (val Containers_testlib.make ~__FILE__())
open Test open Test
open CCMutHeap;;
type elt = { type elt = {
x: string; x: string;