[Development] Danger when excluding auto tests with pre-processor macro.

João Abecasis joao at abecasis.name
Sun Nov 4 09:22:11 CET 2012


Olivier Goffart wrote:
> In the paragraph "Use appropriate mechanisms to exclude inapplicable tests" of
> https://qt-project.org/wiki/Writing_Unit_Tests
> the policy to exclude tests depending on platforms or compiler features is to
> use pre-processor #ifdef.
>
> I just eddited that page to add a Warning there.
> the MOC does not know all the built-ins defined by the compiler. And as a
> result, disabling a test based on one of those define actually disable the
> test all the time, since the moc will not generate the slot for it so the test
> system don't call that function.
>
> I write that now because I just saw many changes recently that effectively
> just remove tests on all platform.
>
> For example, I don't think QT_OS_WIN is visible to moc,
> and i'm pretty sure QT_COMPILER_* is not visible
>
> So in effect, all those recent commit just disabled some tests that should
> probably not be disabled.

For a while now, the general recommendation has been to have tests
compile and run on all platforms and to use QSKIP on those
configurations where the test doesn't apply. So, #ifdefs should go
inside the function definition, and stay out of MOC's way.

At some point Jason McDonald was going over all the tests and fixing
this, but maybe someone needs to take a second round now...

Cheers,


João



More information about the Development mailing list