Add hook to cancel running the tests
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 32/100
Research direction
Start with include/boost/test/impl/unit_test_main.ipp around the linked line and trace how unit_test_main, unit_test_init(), --list_content, and --list_labels are handled. Compare the proposed overload and cancellation point with existing entry points and compatibility expectations. Done means a user-definable cancellation hook can stop the suite while preserving the documented command-line behavior.
Written by the indexing model from the issue text.
Description
I am working with a boost test suite, which needs to run under some conditions.
There is currently no way of checking these conditions and exiting early, while keeping the boost test command line flags working.
- If I use a custom main and exit before calling boost test, then obviously no flags will be checked by boost test.
- If I use a custom
unit_test_init(), then flags like--helpwill work.
The flags--list_contentand--list_labelsare handled afterunit_test_init(), so they won't work.
Currently, I either have to either sacrifice the very useful --list_content and --list_labels flags, or I have to exit in the first test.
I propose to add another user-definable hook, which allows the user to cancel the testsuite:
https://github.com/boostorg/test/blob/9d863d07e864ef663e3e8573b55905099b938d3e/include/boost/test/impl/unit_test_main.ipp#L250
This could be a simple predicate:
typedef bool (*cancel_unit_test_func)();
// For backwards compatibility
int BOOST_TEST_DECL
unit_test_main( init_unit_test_func init_func, int argc, char* argv[] ) {
return unit_test_main(init_func, nullptr, argc, argv);
}
// New main with additional cancel_unit_test_func
int BOOST_TEST_DECL
unit_test_main( init_unit_test_func init_func, cancel_unit_test_func cancel_func, int argc, char* argv[] ) {
// ...
if(cancel_func && cancel_func()) {
return boost::exit_cancelled;
}
framework::run()
// ...
}
- Dominant language
- C++
- Stars
- 213
- Forks
- 149
- Avg merge
- 18h 17m
- Merged PRs (30d)
- 2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/test
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
-
Conversion Warning with GCC15 when using operator<< within custom failure message and -WConversion Open
Difficulty 4/5 3-5 days Newbie friendliness 42/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100