Skip to content

Fixed module tests fail #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2019

Conversation

Kojoley
Copy link
Contributor

@Kojoley Kojoley commented Mar 30, 2019

Since recently lightweight_test introduced a sanitation to ensure that boost::report_errors() is called, and it does not in module tests.

The problem could be fixed by exporting the function and calling it from these python tests, but as it already done in other module tests I just turned those usages lightweight_test to a regular assertation.

ref #254

Since recently lightweight_test introduced a sanitation to ensure that
`boost::report_errors()` is called, and it does not in module tests.

The problem could be fixed by exporting the function and calling it from
these python tests, but as it already done in other module tests I just
turned those usages lightweight_test to a regular assertation.
@stefanseefeld
Copy link
Member

stefanseefeld commented Mar 30, 2019

I don't think BOOST_ASSERT is a device meant to be used for testing. Notably, it will empty (and the enclosed expression won't be evaluated) if NDEBUG is defined, just like the standard assert macro.

@Kojoley
Copy link
Contributor Author

Kojoley commented Mar 30, 2019

Then fix it like you think it should be.

Also grep the tests for BOOST_ASSERT. https://github.com/boostorg/python/search?q=BOOST_ASSERT&unscoped_q=BOOST_ASSERT

The cases closely related to this PR:

#include <boost/assert.hpp>
using namespace boost::python;
struct X
{
explicit X(int x) : x(x), magic(7654321) { ++counter; }
X(X const& rhs) : x(rhs.x), magic(7654321) { ++counter; }
virtual ~X() { BOOST_ASSERT(magic == 7654321); magic = 6666666; x = 9999; --counter; }
void set(int _x) { BOOST_ASSERT(magic == 7654321); this->x = _x; }
int value() const { BOOST_ASSERT(magic == 7654321); return x; }
static int count() { return counter; }
private:
void operator=(X const&);
private:
int x;
long magic;
static int counter;
};

struct X
{
explicit X(int x) : x(x), magic(7654321) { ++counter; }
X(X const& rhs) : x(rhs.x), magic(7654321) { ++counter; }
virtual ~X() { BOOST_ASSERT(magic == 7654321); magic = 6666666; x = 9999; --counter; }
void set(int _x) { BOOST_ASSERT(magic == 7654321); this->x = _x; }
int value() const { BOOST_ASSERT(magic == 7654321); return x; }
static int count() { return counter; }
private:
void operator=(X const&);
private:
int x;
long magic;
static int counter;
};

struct X
{
explicit X(int x) : x(x), magic(7654321) { ++counter; }
X(X const& rhs) : x(rhs.x), magic(7654321) { ++counter; }
~X() { BOOST_ASSERT(magic == 7654321); magic = 6666666; x = 9999; --counter; }
void set(int _x) { BOOST_ASSERT(magic == 7654321); this->x = _x; }
int value() const { BOOST_ASSERT(magic == 7654321); return x; }
static int count() { return counter; }
private:
void operator=(X const&);
private:
int x;
long magic;
static int counter;
};

@stefanseefeld
Copy link
Member

OK, fair enough. I'll merge this in an attempt to "harmonize" our testing logic. Then we can open a new request to substitute boost_assert by something more robust and suitable for use with testing.

@stefanseefeld stefanseefeld merged commit fdc9ec7 into boostorg:develop Apr 1, 2019
@Kojoley Kojoley deleted the fix-module-tests-fail branch April 1, 2019 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants