Skip to content

Commit afe5fec

Browse files
authored
Merge pull request #5885 from psafont/qcheck-core
2 parents 231bb73 + f4b9bcf commit afe5fec

File tree

5 files changed

+16
-78
lines changed

5 files changed

+16
-78
lines changed

clock.opam

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ depends: [
1313
"astring"
1414
"mtime"
1515
"ptime"
16+
"qcheck-core" {with-test}
17+
"qcheck-alcotest" {with-test}
1618
"odoc" {with-doc}
1719
]
1820
build: [

dune-project

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
astring
3030
mtime
3131
ptime
32+
(qcheck-core :with-test)
33+
(qcheck-alcotest :with-test)
3234
)
3335
)
3436

ocaml/libs/clock/dune

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,15 @@
1515
(names test_date test_timer)
1616
(package clock)
1717
(modules test_date test_timer)
18-
(libraries alcotest clock fmt mtime mtime.clock.os ptime qcheck-core qcheck-core.runner)
18+
(libraries
19+
alcotest
20+
clock
21+
fmt
22+
mtime
23+
mtime.clock.os
24+
ptime
25+
qcheck-alcotest
26+
qcheck-core
27+
qcheck-core.runner
28+
)
1929
)

ocaml/libs/clock/test_timer.ml

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,6 @@ module Timer = Clock.Timer
22
module Gen = QCheck2.Gen
33
module Test = QCheck2.Test
44

5-
module QCheck_alcotest = struct
6-
(* SPDX: BSD-2-Clause
7-
From github.com/c-cube/qcheck
8-
*)
9-
10-
module Q = QCheck2
11-
module T = QCheck2.Test
12-
module Raw = QCheck_base_runner.Raw
13-
14-
let seed_ =
15-
lazy
16-
(let s =
17-
try int_of_string @@ Sys.getenv "QCHECK_SEED"
18-
with _ -> Random.self_init () ; Random.int 1_000_000_000
19-
in
20-
Printf.printf "qcheck random seed: %d\n%!" s ;
21-
s
22-
)
23-
24-
let default_rand () =
25-
(* random seed, for repeatability of tests *)
26-
Random.State.make [|Lazy.force seed_|]
27-
28-
let verbose_ =
29-
lazy
30-
( match Sys.getenv "QCHECK_VERBOSE" with
31-
| "1" | "true" ->
32-
true
33-
| _ ->
34-
false
35-
| exception Not_found ->
36-
false
37-
)
38-
39-
let long_ =
40-
lazy
41-
( match Sys.getenv "QCHECK_LONG" with
42-
| "1" | "true" ->
43-
true
44-
| _ ->
45-
false
46-
| exception Not_found ->
47-
false
48-
)
49-
50-
let to_alcotest ?(colors = false) ?(verbose = Lazy.force verbose_)
51-
?(long = Lazy.force long_) ?(debug_shrink = None) ?debug_shrink_list
52-
?(rand = default_rand ()) (t : T.t) =
53-
let (T.Test cell) = t in
54-
let handler name cell r =
55-
match (r, debug_shrink) with
56-
| QCheck2.Test.Shrunk (step, x), Some out ->
57-
let go =
58-
match debug_shrink_list with
59-
| None ->
60-
true
61-
| Some test_list ->
62-
List.mem name test_list
63-
in
64-
if not go then
65-
()
66-
else
67-
QCheck_base_runner.debug_shrinking_choices ~colors ~out ~name cell
68-
~step x
69-
| _ ->
70-
()
71-
in
72-
let print = Raw.print_std in
73-
let name = T.get_name cell in
74-
let run () =
75-
let call = Raw.callback ~colors ~verbose ~print_res:true ~print in
76-
T.check_cell_exn ~long ~call ~handler ~rand cell
77-
in
78-
((name, `Slow, run) : unit Alcotest.test_case)
79-
end
80-
815
let spans =
826
Gen.oneofa ([|1; 100; 300|] |> Array.map (fun v -> Mtime.Span.(v * ms)))
837

quality-gate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ ocamlyacc () {
9595

9696

9797
unixgetenv () {
98-
N=1
98+
N=0
9999
UNIXGETENV=$(git grep -P -r -o --count 'getenv(?!_opt)' -- **/*.ml | wc -l)
100100
if [ "$UNIXGETENV" -eq "$N" ]; then
101101
echo "OK found $UNIXGETENV usages of exception-raising Unix.getenv in OCaml files."

0 commit comments

Comments
 (0)