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

Olivier Goffart olivier at woboq.com
Sun Nov 4 10:42:39 CET 2012


On Sunday 04 November 2012 09:22:11 João Abecasis wrote:
> 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...

I already let Jason know at that time, and he fixed most of them 
(commit a8fd0c3654f8352773638633778cd8003680cbc7 )

But since Jason has left (AFAIK?), the history repeat again :-)

-- 
Olivier

Woboq - Qt services and support - http://woboq.com



More information about the Development mailing list