christophercrouzet / rexo

Neat single-file cross-platform unit testing framework for C/C++.
The Unlicense
27 stars 6 forks source link

Feature: run selected tests only #14

Open markand opened 2 years ago

markand commented 2 years ago

Most unit test frameworks have an option to only run tests specified as arguments.

Proposed syntaxes:

The -t option should be combined, that means -t suiteA -t suiteB will run all tests from suiteA and suiteB.

christophercrouzet commented 2 years ago

Hi @markand,

That definitely would be awesome to have and is actually part of the roadmap (which I still didn't get to since I didn't have a pressing need for it yet):

implement a command-line option parser (e.g.: for filtering test cases).

But since you seem to have a need for it, now would be a good time for me (us?) to find some time and finally get onto it! :sweat_smile:

default-writer commented 1 year ago

@christophercrouzet i think i can implement this functionality, in style. just parsing command line is not seems to be a rocket science, since i know the point where all tests are processing and definetely we can filter some of the tests (skipping them in place where we do a qsort cause qsort executed in just the same way. in fact, doing some complex matching of suites is out of my scopne, but just including tests individually, is ok for me. Like in pytest, -k switch

-k - "skip everything except one that we mention explicitely" with multiple -k switches of cause.

default-writer commented 1 year ago

Most unit test frameworks have an option to only run tests specified as arguments.

Proposed syntaxes:

* `-t suite`: run all tests under **suite**.

* `-t suite/test`: run the explicit **test** in **suite**.

The -t option should be combined, that means -t suiteA -t suiteB will run all tests from suiteA and suiteB.

I suppose it is too complex for just a header only test fw, which REXO actually is. we have to implement sets, sets operations, matching, etc. why dont just include individual tests by simple -k switch? if you need, you can pass several test names, or use -K to exclude individual tests (for example they are failing with memory leaks etc)

default-writer commented 1 year ago

In my opinion excluding individual tests with -T switch and forcefully including another tests/test sets with -t should be enough in most of the cases, @christophercrouzet @markand, isn't it?

For example by including test set T1 without T1/memory_leak we can run the rest suite T without temporarily not working T1/memory_leak:

-T T1 -t T1/memory_leak

If it is known that we need to pass all tests probably excluding one with memory leak, to go to the TEST stage, why not loosing some grips and belts to allow this? In cases someone will use CI/CD or TDD that will be awesome. Of cause example not awesome, but this is the case. what if some test will require network connectivity, not available for some environments (aka docker containers?) does that prevents us from using the rest of the tests online?

but we stick to the dependency of some header files if we are not be accurate, that is not a good thing cause sometimes additional headers might be missing, good to go to keep in mind that we should not add more dependencies on new features, that is why i warned about some sort of sets and operation on them. it is better to do with just and main, but of cause question will rise about c++. i can do it on C style if it is ok with the C++ devs, cause i do not know does it worth doing the templating and the rest of the mimicking boost in just one header lib...

christophercrouzet commented 1 year ago

Hi @default-writer, I'm a bit selective in how I'd like things to be implemented for my personal projects and I enjoy the process so, if this feature were to be implemented, I'd really like to do it myself, however I don't have any bandwidth at all to work on Rexo (or other side projects) at the moment, and don't have an immediate need for it, so this will have to wait (if it comes at all), apologies.

If that's something that you need, then feel free to create a fork and implement it yourself, as long as you're happy with the idea that I likely won't merge it here.

PS: another thing that I'd like to do is rewrite Rexo so that it has 0 #include and so that it can be used with the -nostdlib flag. Hopefully one day! 😅

default-writer commented 1 year ago

Thanks to head this! Ok, no worries, i am not either under immediate need for this feature as well, your repo really works well, indeed!