Fix a collection of random failures encountered when testing with Bazel.

This commit is contained in:
Antonio Sánchez
2025-06-26 16:58:24 +00:00
committed by Rasmus Munk Larsen
parent 0bce653efc
commit a395ee162d
12 changed files with 52 additions and 23 deletions

View File

@@ -8,7 +8,7 @@
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Various sanity tests with exceptions and non trivially copyable scalar type.
// - no memory leak when a custom scalar type trow an exceptions
// - no memory leak when a custom scalar type throw an exceptions
// - todo: complete the list of tests!
#define EIGEN_STACK_ALLOCATION_LIMIT 100000000
@@ -21,9 +21,8 @@
AnnoyingScalar::countdown = 100; \
int before = AnnoyingScalar::instances; \
bool exception_thrown = false; \
try { \
OP; \
} catch (my_exception) { \
EIGEN_TRY { OP; } \
EIGEN_CATCH(my_exception) { \
exception_thrown = true; \
VERIFY(AnnoyingScalar::instances == before && "memory leak detected in " && EIGEN_MAKESTRING(OP)); \
} \
@@ -35,7 +34,11 @@ EIGEN_DECLARE_TEST(exceptions) {
typedef Eigen::Matrix<AnnoyingScalar, Dynamic, Dynamic> MatrixType;
{
#if defined(EIGEN_EXCEPTIONS) && !defined(EIGEN_TEST_ANNOYING_SCALAR_DONT_THROW)
AnnoyingScalar::dont_throw = false;
#else
AnnoyingScalar::dont_throw = true;
#endif
int n = 50;
VectorType v0(n), v1(n);
MatrixType m0(n, n), m1(n, n), m2(n, n);