[Interest] QTest unit tests can't find .moc files
Thomas Sevaldrud
thomas at silentwings.no
Thu Mar 13 22:25:16 CET 2014
Hi,
I've a very strange problem with my QTest unit tests. I use the QTest
project wizard from Qt Creator and end up with a class that includes a moc
file at the bottom of the source just like in the QTest documentation
examples, typically something like this:
tst_foo.cpp:
class FooTests : public QObject
{
Q_OBJECT
...
private Q_SLOTS:
void testSomething();
}
void testSomething()
{
QVERIFY(true);
}
QTEST_APPLESS_MAIN(Foo)
#include "tst_foo.moc"
Now, this work nicely most of the time, but sometimes it fails to compile
with the error message "Cannot open include file 'tst_foo.moc': No such
file or directory.
I've looked at the generated Makefile and found that in the cases where
this fails, the .moc file has a dependency to itself in the Makefile, i.e
the make rule is something like this:
debug\tst_foo.moc: C:\Qt\5.2.1\msvc2010_opengl\include\QtCore\QString \
C:\Qt\5.2.1\msvc2010_opengl\include\QtCore\qstring.h \
....
<path to source tree>\tst_foo.moc \
<path to source tree>\tst_foo.cpp
C:\Qt\5.2.1\msvc2010_opengl\bin\moc.exe $(DEFINES) -D_MSC_VER=1600
-D_WIN32 $(INCPATH) <path to source tree>\tst_foo.cpp -o debug\tst_foo.moc
In the cases where it works, the .moc file is not in the dependency list
I really can't see what triggers this, it seems completely random. Some
times it happens, other times it doesn't....
Any ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140313/6f22fb7a/attachment.html>
More information about the Interest
mailing list