-
Notifications
You must be signed in to change notification settings - Fork 543
CXX-3094 Use Catch2 SKIP()
and compact reporter
#1206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
e5791e0
7ab4ca1
7feb6e2
8edc084
e61322a
adfe32b
f39a1c6
b8c3ee1
0d6df30
1ba41f4
4831e3f
88645c0
d1f873e
d715633
9a690b6
4b7d9e3
14bf375
1417362
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,23 +206,29 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) | |
find_package(Threads REQUIRED) | ||
target_link_libraries(test_driver PRIVATE Threads::Threads) | ||
|
||
add_test(NAME driver COMMAND test_driver) | ||
add_test(NAME logging COMMAND test_logging) | ||
add_test(NAME instance COMMAND test_instance) | ||
add_test(NAME crud_specs COMMAND test_crud_specs) | ||
add_test(NAME gridfs_specs COMMAND test_gridfs_specs) | ||
add_test(NAME client_side_encryption_specs COMMAND test_client_side_encryption_specs) | ||
add_test(NAME command_monitoring_specs COMMAND test_command_monitoring_specs) | ||
add_test(NAME transactions_specs COMMAND test_transactions_specs) | ||
add_test(NAME retryable_reads_spec COMMAND test_retryable_reads_specs) | ||
add_test(NAME read_write_concern_specs COMMAND test_read_write_concern_specs) | ||
add_test(NAME unified_format_spec COMMAND test_unified_format_spec) | ||
add_test(NAME versioned_api COMMAND test_versioned_api) | ||
set(test_args "") | ||
list(APPEND test_args | ||
--reporter compact | ||
--allow-running-no-tests | ||
) | ||
|
||
add_test(NAME driver COMMAND test_driver ${test_args}) | ||
add_test(NAME logging COMMAND test_logging ${test_args}) | ||
add_test(NAME instance COMMAND test_instance ${test_args}) | ||
add_test(NAME crud_specs COMMAND test_crud_specs ${test_args}) | ||
add_test(NAME gridfs_specs COMMAND test_gridfs_specs ${test_args}) | ||
add_test(NAME client_side_encryption_specs COMMAND test_client_side_encryption_specs ${test_args}) | ||
add_test(NAME command_monitoring_specs COMMAND test_command_monitoring_specs ${test_args}) | ||
add_test(NAME transactions_specs COMMAND test_transactions_specs ${test_args}) | ||
add_test(NAME retryable_reads_spec COMMAND test_retryable_reads_specs ${test_args}) | ||
add_test(NAME read_write_concern_specs COMMAND test_read_write_concern_specs ${test_args}) | ||
add_test(NAME unified_format_spec COMMAND test_unified_format_spec ${test_args}) | ||
add_test(NAME versioned_api COMMAND test_versioned_api ${test_args}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be refactored as a loop over the test names? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea. Done. |
||
|
||
# Adding this as a test will run it as part of the RUN_TESTS command in MSVC. | ||
# Do not add, since we only test mongohouse on Linux. | ||
if(0) | ||
add_test(mongohouse_specs NAME test_mongohouse_specs COMMAND) | ||
add_test(NAME mongohouse_specs COMMAND test_mongohouse_specs ${test_args}) | ||
endif() | ||
|
||
set_property(TEST crud_specs APPEND PROPERTY ENVIRONMENT | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,9 +210,37 @@ auto size(Container c) -> decltype(std::distance(std::begin(c), std::end(c))) { | |
// | ||
// @return Whether sessions are supported by the client's topology. | ||
// | ||
bool server_has_sessions(const client& conn); | ||
|
||
bool should_run_client_side_encryption_test(void); | ||
bool server_has_sessions_impl(const client& conn); | ||
|
||
#define SERVER_HAS_SESSIONS_OR_SKIP(conn) \ | ||
if (!mongocxx::test_util::server_has_sessions_impl(conn)) { \ | ||
SKIP("server does not support session"); \ | ||
} \ | ||
((void)0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: Recommend an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually: Does this need to be a macro? Does the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, in order for source location information (filename and line number) to be unique in the skip reason message. |
||
|
||
#if defined(MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION) | ||
enum struct cseeos_result { | ||
enable, | ||
skip, | ||
fail, | ||
}; | ||
|
||
cseeos_result client_side_encryption_enabled_or_skip_impl(); | ||
|
||
#define CLIENT_SIDE_ENCRYPTION_ENABLED_OR_SKIP() \ | ||
switch (mongocxx::test_util::client_side_encryption_enabled_or_skip_impl()) { \ | ||
case mongocxx::test_util::cseeos_result::enable: \ | ||
break; \ | ||
case mongocxx::test_util::cseeos_result::skip: \ | ||
SKIP("CSE environemnt variables not set"); \ | ||
case mongocxx::test_util::cseeos_result::fail: \ | ||
FAIL("One or more CSE environment variable is missing"); \ | ||
} \ | ||
((void)0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recommend wrapping in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
#else | ||
#define CLIENT_SIDE_ENCRYPTION_ENABLED_OR_SKIP() \ | ||
SKIP("linked libmongoc does not support client side encryption") | ||
#endif // defined(MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION) | ||
|
||
std::string getenv_or_fail(const std::string env_name); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the
test_args
variable really needed? Can arguments be inlined into theadd_test
call?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is just for consistency with mongocxx tests. I suppose it can be inlined for now until more bsoncxx test executables are added (if any).