Skip to content

Commit bb0d612

Browse files
committed
Merge pull request #314 from remicollet/issue-online
allow to skip online tests
2 parents a21a957 + 077c046 commit bb0d612

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ provided to MongoDB, so an additional variable must be set to enable these tests
192192

193193
Set this environment variable to `on` if MongoDB has enabled majority read concern.
194194

195+
Some tests require Internet access, e.g. to check the error message when failing
196+
to open a MongoDB connection to example.com. Skip them with:
197+
198+
* `MONGOC_TEST_OFFLINE`
199+
195200
All tests should pass before submitting a patch.
196201

197202
## Configuring the test runner

tests/test-libmongoc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,12 @@ int test_framework_skip_if_max_version_version_less_than_4 (void)
12091209
}
12101210

12111211

1212+
int test_framework_skip_if_offline (void)
1213+
{
1214+
return test_framework_getenv_bool ("MONGOC_TEST_OFFLINE") ? 0 : 1;
1215+
}
1216+
1217+
12121218
int
12131219
main (int argc,
12141220
char *argv[])

tests/test-libmongoc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ int test_framework_skip_if_windows (void);
6161
int test_framework_skip_if_not_mongos (void);
6262
int test_framework_skip_if_not_replset (void);
6363
int test_framework_skip_if_not_single (void);
64+
int test_framework_skip_if_offline (void);
6465

6566
typedef struct _debug_stream_stats_t {
6667
mongoc_client_t *client;

tests/test-mongoc-topology.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ test_connect_timeout_try_once_false(void)
750750

751751

752752
static void
753-
test_multiple_selection_errors (void)
753+
test_multiple_selection_errors (void *context)
754754
{
755755
const char *uri = "mongodb://doesntexist,example.com:2/?replicaSet=rs"
756756
"&connectTimeoutMS=100";
@@ -811,6 +811,6 @@ test_topology_install (TestSuite *suite)
811811
TestSuite_Add (suite, "/Topology/connect_timeout/pooled", test_connect_timeout_pooled);
812812
TestSuite_Add (suite, "/Topology/connect_timeout/single/try_once", test_connect_timeout_single);
813813
TestSuite_Add (suite, "/Topology/connect_timeout/single/try_once_false", test_connect_timeout_try_once_false);
814-
TestSuite_Add (suite, "/Topology/multiple_selection_errors", test_multiple_selection_errors);
814+
TestSuite_AddFull (suite, "/Topology/multiple_selection_errors", test_multiple_selection_errors, NULL, NULL, test_framework_skip_if_offline);
815815
TestSuite_Add (suite, "/Topology/invalid_server_id", test_invalid_server_id);
816816
}

0 commit comments

Comments
 (0)