Comments (2)
Some design notes for this
- There should be a new listener event for generators.
- To simplify the work to create a custom reporter, we should be sending paired
start
...end
events. This enables reporters to keep track of active generators without having to do the bookkeeping of tracking each generator's parent section.- The name
generatorStarting
is symmetric with the existing events, and also terrible, because it does not match the actual semantics ofGENERATE
.generatorEnded
is even worse. - Current consideration:
generatorActivated
...generatorDeactivated
.
- The name
- The starting event should be sent whenever we visit an expression with
GENERATE
in it.- The ending event can only be sent when the parent section's tracker is closing. We have to ensure that the generator trackers emit the ending events in the proper LIFO order.
- The starting event should pass either the generator interface, or something similar, that allows both getting the index of the current element in the generator, and getting the string representation of that element.
- The ending event should not send these, as the generator might no longer be valid when the event is fired. Or we have to codify the semantics that the event is always sent before the generator can be deallocated, and make it clear that the generator-interface-pointer should never ever be stored.
- We should also consider sending in the "index" of the generator that is (de)activated. It is not important, but it might simplify some things... but users will have to maintain their own stack anyway, maybe it is not worth it?
- Unlike sections, generators do not have user-facing names, so we cannot use those.
- We want to keep backwards compatibility with the existing
-c
,--section
path filtering. To avoid overcomplicating the CLI option, we will support two exclusive path specification modes, so the users can either use-c ...
as they do now, or they can use-p
,--path
in the future, but not both at the same time.- The
--path
specifier will accept compound arguments, such as--path g:2
or--path c:"foo bar"
for generator index or section name respectively.- Should we use 'c' or 's' (or both) for the section filter? 'c' is consistent with
-c
argument,-s
makes more sense. We can also use both, but that risks user confusion. - Should we also allow long names, so that
g:2
andgenerator:2
are equivalent? Also should the long names be fully explicit, e.g.generator-index:2
,section-name:"foo bar"
?
- Should we use 'c' or 's' (or both) for the section filter? 'c' is consistent with
- The
Example event semantics
This sample test case
TEST_CASE() {
SECTION("A") { ... }
auto _ = GENERATE(...);
SECTION("B") { ... }
}
should emit
testCaseStarting
testCasePartialStarting -> #0
sectionStarting -> "test"
sectionStarting -> "A"
sectionEnded -> "A"
generatorActivated
generatorDeactivated
sectionEnded -> "test"
testCasePartialEnded -> #0
testCasePartialStarting -> #1
sectionStarting -> "test"
generatorActivated
sectionStarting -> "B"
sectionEnded -> "B"
generatorDeactivated
sectionEnded -> "test"
testCasePartialEnded -> #1
... repeated for each generator element ...
testCaseEnded
from catch2.
Also, we may want something like
auto foo = NAMED_GENERATE("foo", ...);
for avoiding common patterns
auto foo = GENERATE(...);
CAPTURE(foo);
This will also present the generator name to reporters, so that in cases when we are generating something that we care to be named, we will see a reasonable name there.
from catch2.
Related Issues (20)
- tsan reports data race on multithread std::cout HOT 3
- XML Reporter doesn't output stderr / stdin when there is a segfault HOT 3
- unnecessary double promotion generate warning.
- Support multiple reporters for `catch_discover_tests` HOT 1
- Extend support for randomness generation in tests
- Finish JSON reporter & use it for more reliable CMake/CTest integration
- Update documentation for v3 HOT 2
- Provide Catch2's StringMaker specialization behind extra level of indirection
- Handle ANSI escape sequences during text wrapping
- Bring back Single-Header capability HOT 2
- AddressSanitizer reports container overflow during benchmarking HOT 3
- Latest macOS system header causes compilation failures on GCC HOT 4
- Compilation fails with `error: arithmetic on a pointer to an incomplete type` HOT 1
- Combine test filters with filenames HOT 2
- Section filter command line option only works for sections without whitespace in name HOT 1
- Separate headers for "extra" std types
- Catch2 does not appear to work with C++23
- version 3.5.4 does not compile
- JUnit and console reporter discrepency.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from catch2.