There is an increasing number of places where Catch2 wants to parse
strings into numbers, but being stuck in C++14 world, we do not
have good stdlib facilities to do this (`strtoul` and `stoul`
are both bad).
* meson: run through muon's fmt to fix formatting
* meson: switch arrays to files
Allows muon to alphabetically sort files. switch headers back to arrays
as split() can only be used on strings.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
The Meson[1] build system makes it easier incorporate third-party
libaries into a project if they also build using Meson.
Let's add a minimal Meson build that's compatible with the CMake build,
along with a GitHub workflow to check that it builds and that at least
the simplest SelfTest runs.
The handling of catch_user_config.hpp is inspired by BUILD.bazel and
doesn't attempt to support any configuratons options. Such features
could be added later.
Meson strongly discourages using wildcards to specify sources, so the
source and header lists are copied from CMakeLists.txt.
Add a new test workflow to test the Meson builds. I was unable to get
these tests to pass with Ubuntu 20.04, so they use Ubuntu 22.04.
I'm neither a CMake nor a Meson expert, but the results seem to work for
me.
[1] https://mesonbuild.com/
Co-authored-by: Mike Crowe <mcrowe@brightsign.biz>
* Suppress clang-tidy *-avoid-c-arrays for TEMPLATE_TEST_CASE
* Made globalRegistrar `const` to avoid `cppcoreguidelines-avoid-non-const-global-variables`
Fixes#2095
when a test executable is killed by a signal (e.g. when executed by
ctest with timeout), the reporter files are not flushed. this can lead
to incomplete (or empty) report files.
to avoid this we enable automatic flushing via `std::unitbuf`
compare #663
`catch_sharding.hpp` was using `std::min` without including `<algorithm>`.
This worked on most platforms, but it wasn't transitively included in
the VxWorks toolchain.
The compile time improvements from using combined TUs mostly isn't
worth the annoyance they cause with various IDE shortcuts, like
when switching between header and its impl. file.
Splitting them apart also fixes the issue of empty subdirs being
installed due to `foo/internal` folders that only contained the
combined TUs and no headers.
Closes#2457Closes#2463
* GCC5 compat: work around inherited constructor issues
Don't use inherited constructors, forward manually instead. This
basically reverts 61f803126d.
I believe that GCC5 does not implement P0136, a C++17 change that made
inherited constructors actually usable and was backported as a DR all
the way to C++11.
* GCC5 compat: bypass std::pair construction issue
Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
Reported as an issue on Discord. I thought that by GCC 9, the
C++ frontend was fixed enough to support `_Pragma`-based
suppression correctly, but apparently I was wrong.
This fixes multiple issues with random generators, with the most
important one being that multiple nested generators could return
values from the same sequence, due to internal implementation
details of `GENERATE`, and how they interact with test case
paths.
The cost of doing this is that given this simple `TEST_CASE`,
```cpp
TEST_CASE("foo") {
auto i = GENERATE(take(10, random(0, 100));
SECTION("A") {
auto j = GENERATE(take(10, random(0, 100));
}
SECTION("B") {
auto k = GENERATE(take(10, random(0, 100));
}
}
```
`k` will have different values between running the test as
a whole, e.g. with `./tests "foo"`, and running only the "B"
section with `./tests "foo" -c "B"`.
I consider this an acceptable cost, because the only alternative
would be very messy to implement, and add a lot of brittle and
complex code for relatively little benefit.
If this calculation changes, we will need to instead walk
the current tracker tree whenever a random generator is being
constructed, check for random generators on the path to root,
and take a seed from them.