Skip to content

Commit 23bed2e

Browse files
committed
Fix conditioning of tests.
- Use build_if instead of enabled_if to condition on build deps. - Add test dependency on OCAML_MARIADB_* environment variables. - Only run tests if OCAML_MARIADB_DB is set and restore @runtest in the opam package.
1 parent 280359a commit 23bed2e

File tree

5 files changed

+33
-8
lines changed

5 files changed

+33
-8
lines changed

mariadb.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ build: [
1313
["dune" "subst"] {dev}
1414
["dune" "build" "-p" name "-j" jobs
1515
"@install"
16-
"@default" {with-test} # but not @runtest since it would require a MariaDB server
16+
"@runtest" {with-test}
1717
"@doc" {with-doc}
1818
]
1919
]

tests/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ latter there are instances depending on the concurrency library:
99
| nonblocking-async | Tests the nonblocking API using async.
1010
| nonblocking-lwt | Tests the nonblocking API using Lwt.
1111

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:
12+
Tests require access to a MariaDB or MySQL database, which must be declared
13+
by setting the following environment variables:
1414

1515
| Environment variable | Description
1616
| -------------------- | -----------
17-
| `OCAML_MARIADB_HOST` | Host to connect to.
17+
| `OCAML_MARIADB_HOST` | Host name or IP address to connect to.
18+
| `OCAML_MARIADB_PORT` | Port number to connect to.
1819
| `OCAML_MARIADB_USER` | Authenticate as the given user.
1920
| `OCAML_MARIADB_PASS` | Authenticate with the given password.
2021
| `OCAML_MARIADB_DB` | Connect to the given database.
22+
23+
These tests will only run if `OCAML_MARIADB_DB` has been set, but the
24+
executable will still be built. The remaining variables are optional.

tests/blocking/dune

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
(test
22
(name blocking_testsuite)
3+
(enabled_if (<> %{env:OCAML_MARIADB_DB=__none__} __none__))
4+
(deps
5+
(env_var OCAML_MARIADB_HOST)
6+
(env_var OCAML_MARIADB_PORT)
7+
(env_var OCAML_MARIADB_USER)
8+
(env_var OCAML_MARIADB_PASS)
9+
(env_var OCAML_MARIADB_DB))
310
(libraries mariadb nonblocking_testsuite unix))

tests/nonblocking-async/dune

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
(test
22
(name nonblocking_testsuite_async)
3-
(libraries mariadb async nonblocking_testsuite)
4-
(enabled_if %{lib-available:lwt}))
3+
(build_if %{lib-available:lwt})
4+
(enabled_if (<> %{env:OCAML_MARIADB_DB=__none__} __none__))
5+
(deps
6+
(env_var OCAML_MARIADB_HOST)
7+
(env_var OCAML_MARIADB_PORT)
8+
(env_var OCAML_MARIADB_USER)
9+
(env_var OCAML_MARIADB_PASS)
10+
(env_var OCAML_MARIADB_DB))
11+
(libraries mariadb async nonblocking_testsuite))

tests/nonblocking-lwt/dune

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
(test
22
(name nonblocking_testsuite_lwt)
3-
(libraries mariadb lwt lwt.unix nonblocking_testsuite)
4-
(enabled_if %{lib-available:lwt}))
3+
(build_if %{lib-available:lwt})
4+
(enabled_if (<> %{env:OCAML_MARIADB_DB=__none__} __none__))
5+
(deps
6+
(env_var OCAML_MARIADB_HOST)
7+
(env_var OCAML_MARIADB_PORT)
8+
(env_var OCAML_MARIADB_USER)
9+
(env_var OCAML_MARIADB_PASS)
10+
(env_var OCAML_MARIADB_DB))
11+
(libraries mariadb lwt lwt.unix nonblocking_testsuite))

0 commit comments

Comments
 (0)