Commit 3ade893e authored by Peifeng Yu's avatar Peifeng Yu
Browse files

Fix lldb unit test COMPARE won't stop test if failed.

Also make all test macro report actual location in lldb unit test.
parent 89e66476
......@@ -45,6 +45,24 @@
#include <QTest>
#include <QUrl>
#define WAIT_FOR_STATE(session, state) \
do { if (!KDevMI::LLDB::waitForState((session), (state), __FILE__, __LINE__)) return; } while (0)
#define WAIT_FOR_STATE_AND_IDLE(session, state) \
do { if (!KDevMI::LLDB::waitForState((session), (state), __FILE__, __LINE__, true)) return; } while (0)
#define WAIT_FOR_A_WHILE(session, ms) \
do { if (!KDevMI::LLDB::waitForAWhile((session), (ms), __FILE__, __LINE__)) return; } while (0)
#define WAIT_FOR(session, condition) \
do { \
KDevMI::LLDB::TestWaiter w((session), #condition, __FILE__, __LINE__); \
while (w.waitUnless((condition))) /* nothing */ ; \
} while(0)
#define COMPARE_DATA(index, expected) \
do { if (!KDevMI::LLDB::compareData((index), (expected), __FILE__, __LINE__)) return; } while (0)
#define SKIP_IF_ATTACH_FORBIDDEN() \
do { \
if (isAttachForbidden(__FILE__, __LINE__)) \
......
......@@ -74,12 +74,16 @@ bool isAttachForbidden(const char *file, int line)
return false;
}
void compareData(QModelIndex index, QString expected, const char *file, int line)
bool compareData(QModelIndex index, QString expected, const char *file, int line)
{
QString s = index.model()->data(index, Qt::DisplayRole).toString();
if (s != expected) {
QFAIL(qPrintable(QString("'%0' didn't match expected '%1' in %2:%3").arg(s).arg(expected).arg(file).arg(line)));
QTest::qFail(qPrintable(QString("'%0' didn't match expected '%1' in %2:%3")
.arg(s).arg(expected).arg(file).arg(line)),
file, line);
return false;
}
return true;
}
bool waitForAWhile(MIDebugSession *session, int ms, const char *file, int line)
......
......@@ -40,7 +40,7 @@ QUrl findExecutable(const QString& name);
QString findSourceFile(const char *file, const QString& name);
bool isAttachForbidden(const char *file, int line);
void compareData(QModelIndex index, QString expected, const char *file, int line);
bool compareData(QModelIndex index, QString expected, const char *file, int line);
bool waitForState(MIDebugSession *session, KDevelop::IDebugSession::DebuggerState state,
const char *file, int line, bool waitForIdle = false);
......@@ -66,22 +66,4 @@ private:
} // end of namespace LLDB
} // end of namespace KDevMI
#define WAIT_FOR_STATE(session, state) \
do { if (!KDevMI::LLDB::waitForState((session), (state), __FILE__, __LINE__)) return; } while (0)
#define WAIT_FOR_STATE_AND_IDLE(session, state) \
do { if (!KDevMI::LLDB::waitForState((session), (state), __FILE__, __LINE__, true)) return; } while (0)
#define WAIT_FOR_A_WHILE(session, ms) \
do { if (!KDevMI::LLDB::waitForAWhile((session), (ms), __FILE__, __LINE__)) return; } while (0)
#define WAIT_FOR(session, condition) \
do { \
KDevMI::LLDB::TestWaiter w((session), #condition, __FILE__, __LINE__); \
while (w.waitUnless((condition))) /* nothing */ ; \
} while(0)
#define COMPARE_DATA(index, expected) \
KDevMI::LLDB::compareData((index), (expected), __FILE__, __LINE__)
#endif // LLDB_UNITTEST_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment