Skip to content

Commit aa41c4a

Browse files
authored
Merge pull request #60 from paurkedal/testsuite
Add testsuite
2 parents 44c923c + 88e9e01 commit aa41c4a

File tree

15 files changed

+161
-82
lines changed

15 files changed

+161
-82
lines changed

examples/async/dune

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
(tests
2-
(names
3-
nonblocking_async_example
4-
nonblocking_async_stress_test)
5-
(libraries mariadb async nonblocking_tests)
6-
(enabled_if %{lib-available:lwt}))
1+
(executable
2+
(name nonblocking_async_example)
3+
(libraries mariadb async))

examples/blocking/blocking_stress_test.ml

Lines changed: 0 additions & 45 deletions
This file was deleted.

examples/blocking/dune

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
(tests
2-
(names
3-
blocking_example
4-
blocking_stress_test)
1+
(executable
2+
(name blocking_example)
53
(libraries mariadb))

examples/lwt/dune

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
(tests
2-
(names
3-
nonblocking_lwt_example
4-
nonblocking_lwt_stress_test)
5-
(libraries mariadb lwt lwt.unix nonblocking_tests)
6-
(enabled_if %{lib-available:lwt}))
1+
(executable
2+
(name nonblocking_lwt_example)
3+
(libraries mariadb lwt lwt.unix))

examples/nonblocking/dune

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/select/dune

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
(tests
2-
(names
3-
nonblocking_select_example
4-
nonblocking_select_stress_test)
5-
(libraries mariadb unix nonblocking_tests))
1+
(executable
2+
(name nonblocking_select_example)
3+
(libraries mariadb unix))

tests/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
This directory contains the test suite. The main code split up according to
2+
whether the tests are using the blocking or non-blocking API, and for the
3+
latter there are instances depending on the concurrency library:
4+
5+
| Directory | Description
6+
| --------- | -----------
7+
| nonblocking | Abstract tests suite implementation.
8+
| blocking | Tests the blocking and nonblocking APIs without concurrency.
9+
| nonblocking-async | Tests the nonblocking API using async.
10+
| nonblocking-lwt | Tests the nonblocking API using Lwt.
11+
12+
Tests require access to a MariaDB instance to run. You will likely need to
13+
set some environment variables to point the test suite to the right place:
14+
15+
| Environment variable | Description
16+
| -------------------- | -----------
17+
| `OCAML_MARIADB_HOST` | Host to connect to.
18+
| `OCAML_MARIADB_USER` | Authenticate as the given user.
19+
| `OCAML_MARIADB_PASS` | Authenticate with the given password.
20+
| `OCAML_MARIADB_DB` | Connect to the given database.

examples/select/nonblocking_select_stress_test.ml renamed to tests/blocking/blocking_testsuite.ml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module S = Mariadb.Nonblocking.Status
22

3-
module Test = Nonblocking_stress_test.Make (struct
3+
module Wait = struct
4+
45
module IO = struct
56
type 'a future = 'a
67
let (>>=) x f = f x
@@ -28,6 +29,17 @@ module Test = Nonblocking_stress_test.Make (struct
2829
()
2930
with Unix.Unix_error (_, _, _) ->
3031
return @@ S.create ~timeout: true ()
31-
end)
3232

33-
let () = Test.main ()
33+
end
34+
35+
(* Test for the blocking API. *)
36+
module Test_blocking =
37+
Nonblocking_testsuite.Make (Wait.IO) (Mariadb.Blocking)
38+
39+
(* Test for the non-blocking API without concurrency. *)
40+
module Test_nonblocking =
41+
Nonblocking_testsuite.Make (Wait.IO) (Mariadb.Nonblocking.Make (Wait))
42+
43+
let () =
44+
Test_blocking.main ();
45+
Test_nonblocking.main ()

tests/blocking/dune

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(test
2+
(name blocking_testsuite)
3+
(libraries mariadb nonblocking_testsuite unix))

tests/nonblocking-async/dune

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(test
2+
(name nonblocking_testsuite_async)
3+
(libraries mariadb async nonblocking_testsuite)
4+
(enabled_if %{lib-available:lwt}))

0 commit comments

Comments
 (0)