-
Notifications
You must be signed in to change notification settings - Fork 546
CXX-3294 Relocate all remaining Manual Doc Page examples into the examples directory #1407
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
Conversation
@@ -457,20 +457,17 @@ TEST_CASE("Documentation Examples", "[change_stream]") { | |||
}}; | |||
|
|||
SECTION("Example 1") { |
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.
the code itself remains to preserve code coverage as part of the test suite.
Suggest removing the doc examples from tests to avoid going out-of-sync. I expect the main purpose is documentation rather than testing. And the examples are run on most Evergreen configurations.
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.
LGTM with minor suggestions.
mongocxx::client const conn{mongocxx::uri{}}; | ||
|
||
auto const db = conn["documentation_examples"]; |
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.
mongocxx::client const conn{mongocxx::uri{}}; | |
auto const db = conn["documentation_examples"]; |
Unused.
for (auto const& example : examples) { | ||
mongocxx::pool pool{mongocxx::uri{}}; |
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.
for (auto const& example : examples) { | |
mongocxx::pool pool{mongocxx::uri{}}; | |
mongocxx::pool pool{mongocxx::uri{}}; | |
for (auto const& example : examples) { |
Suggest creating pool outside of loop. Pool destruction signals and waits for monitoring threads to shut down. Timing cmake --build cmake-build --target run-examples-mongocxx-mongodb.com-change_streams_examples
locally showed a decrease of 2.207s => 1.156s.
Resolves CXX-3294. Followup to #1403, which broke downstream Manual Doc pages due to several example code blocks that still remained under the
test
directory (these are identified by// (Start|Begin|End) <name>
comments). All such remaining code blocks are copied into equivalent files under theexamples/mongocxx/mongodb.com
directory for consistency and to inform future maintainers about their stability requirement by downstream Manual Doc pages. Although the comments under thetest
directory are removed, the code itself remains to preserve code coverage as part of the test suite.Catch2 assertions such as
CHECK(cond)
are converted intoif (!cond) { throw std::logic_error{...}; }
for consistency with other example code. The rest of the code block contents and structure is otherwise preserved as much as possible with their prior form asSECTION()
blocks.As a drive-by fix/improvement, the requirement that the replica set against which the examples are run is named
repl0
(withreplicaSet=repl0
) is removed. AFAIK no such expectation or requirement is necessary for example code.