Commit 8ad116c0 authored by hjk's avatar hjk
Browse files

debugger: re-organize autotests. also adjust to recent QScopedPointer changes

parent 85cdc9b4
......@@ -43,6 +43,7 @@
#define GDBMACROS_P_H
#include <QtCore/QObject>
#include <QtCore/QPointer>
#ifndef QT_BOOTSTRAPPED
......
QT = core testlib gui
TEMPLATE = subdirs
DEBUGGERDIR = ../../../src/plugins/debugger
UTILSDIR = ../../../src/libs
MACROSDIR = ../../../share/qtcreator/gdbmacros
SOURCES += \
$$DEBUGGERDIR/gdb/gdbmi.cpp \
$$DEBUGGERDIR/tcf/json.cpp \
$$MACROSDIR/gdbmacros.cpp \
main.cpp \
DEFINES += MACROSDEBUG
INCLUDEPATH += $$DEBUGGERDIR $$UTILSDIR $$MACROSDIR
SUBDIRS = dumpers.pro plugin.pro
QT += testlib
DEBUGGERDIR = ../../../src/plugins/debugger
UTILSDIR = ../../../src/libs
MACROSDIR = ../../../share/qtcreator/gdbmacros
SOURCES += \
$$DEBUGGERDIR/gdb/gdbmi.cpp \
$$DEBUGGERDIR/tcf/json.cpp \
$$MACROSDIR/gdbmacros.cpp \
tst_dumpers.cpp \
DEFINES += MACROSDEBUG
INCLUDEPATH += $$DEBUGGERDIR $$UTILSDIR $$MACROSDIR
QT += testlib
DEBUGGERDIR = ../../../src/plugins/debugger
UTILSDIR = ../../../src/libs
MACROSDIR = ../../../share/qtcreator/gdbmacros
SOURCES += \
tst_plugin.cpp \
DEFINES += MACROSDEBUG
INCLUDEPATH += $$DEBUGGERDIR $$UTILSDIR $$MACROSDIR
#include <ctype.h>
#include <QtCore/QObject>
#include <QtCore/QProcess>
#include <QtCore/QFileInfo>
#include <QtCore/QMap>
#include <QtCore/QMetaMethod>
#include <QtCore/QModelIndex>
#if QT_VERSION >= 0x040500
#include <QtCore/QSharedPointer>
#endif
#include <QtCore/QStringList>
#include <QtCore/QTextCodec>
#include <QtGui/QApplication>
#include <QtGui/QDialog>
#include <QtGui/QImage>
#include <QtGui/QPixmap>
#include <QtGui/QStandardItemModel>
#include <QtGui/QStringListModel>
#include <QtTest/QtTest>
//#include <QtTest/qtest_gui.h>
#include <QtCore/private/qobject_p.h>
#include "gdb/gdbmi.h"
#include "tcf/json.h"
#include "gdbmacros.h"
#include "gdbmacros_p.h"
#include <QtCore/private/qobject_p.h>
#include <QtGui/QStandardItemModel>
#include <QtGui/QStringListModel>
#include <QtTest/QtTest>
//#include <QtTest/qtest_gui.h>
#undef NS
#ifdef QT_NAMESPACE
# define STRINGIFY0(s) #s
......@@ -178,16 +161,7 @@ private slots:
void dumpQWeakPointer();
void initTestCase();
public slots:
void runQtc();
public slots:
void readStandardOutput();
void readStandardError();
private:
QProcess m_proc; // the Qt Creator process
void dumpQAbstractItemHelper(QModelIndex &index);
void dumpQAbstractItemModelHelper(QAbstractItemModel &m);
void dumpQByteArrayHelper(QByteArray &ba);
......@@ -220,17 +194,6 @@ private:
void dumpQTextCodecHelper(QTextCodec *codec);
};
static QByteArray stripped(QByteArray ba)
{
for (int i = ba.size(); --i >= 0; ) {
if (ba.at(i) == '\n' || ba.at(i) == ' ')
ba.chop(1);
else
break;
}
return ba;
}
void tst_Debugger::infoBreak()
{
// This tests the regular expression used in GdbEngine::extractDataFromInfoBreak
......@@ -1765,7 +1728,12 @@ class Cheater : public QObject
public:
static const QObjectPrivate *getPrivate(const QObject &o)
{
return dynamic_cast<const QObjectPrivate *>(static_cast<const Cheater&>(o).d_ptr);
const Cheater &cheater = static_cast<const Cheater&>(o);
#if QT_VERSION >= 0x040600
return dynamic_cast<const QObjectPrivate *>(cheater.d_ptr.data());
#else
return dynamic_cast<const QObjectPrivate *>(cheater.d_ptr);
#endif
}
};
......@@ -2408,54 +2376,13 @@ void tst_Debugger::initTestCase()
#endif
}
void tst_Debugger::readStandardOutput()
{
qDebug() << "qtcreator-out: " << stripped(m_proc.readAllStandardOutput());
}
void tst_Debugger::readStandardError()
{
qDebug() << "qtcreator-err: " << stripped(m_proc.readAllStandardError());
}
void tst_Debugger::runQtc()
{
QString test = QFileInfo(qApp->arguments().at(0)).absoluteFilePath();
QString qtc = QFileInfo(test).absolutePath() + "/../../../bin/qtcreator.bin";
qtc = QFileInfo(qtc).absoluteFilePath();
QStringList env = QProcess::systemEnvironment();
env.append("QTC_DEBUGGER_TEST=" + test);
m_proc.setEnvironment(env);
connect(&m_proc, SIGNAL(readyReadStandardOutput()),
this, SLOT(readStandardOutput()));
connect(&m_proc, SIGNAL(readyReadStandardError()),
this, SLOT(readStandardError()));
m_proc.start(qtc);
m_proc.waitForStarted();
QCOMPARE(m_proc.state(), QProcess::Running);
m_proc.waitForFinished();
QCOMPARE(m_proc.state(), QProcess::NotRunning);
}
void runDebuggee()
{
qDebug() << "RUNNING DEBUGGEE";
}
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QStringList args = app.arguments();
if (args.size() == 2 && args.at(1) == "--run-debuggee") {
runDebuggee();
app.exec();
return 0;
}
QApplication app(argc, argv);
tst_Debugger test;
return QTest::qExec(&test, argc, argv);
}
#include "main.moc"
#include "tst_dumpers.moc"
#include <ctype.h>
#include <QtCore/QObject>
#include <QtCore/QProcess>
#include <QtCore/QFileInfo>
#include <QtCore/QMap>
#include <QtCore/QMetaMethod>
#include <QtCore/QModelIndex>
#if QT_VERSION >= 0x040500
#include <QtCore/QSharedPointer>
#endif
#include <QtCore/QStringList>
#include <QtCore/QTextCodec>
#include <QtGui/QApplication>
#include <QtGui/QDialog>
#include <QtGui/QImage>
#include <QtGui/QPixmap>
#include <QtGui/QStandardItemModel>
#include <QtGui/QStringListModel>
#include <QtTest/QtTest>
//#include <QtTest/qtest_gui.h>
#include <QtCore/private/qobject_p.h>
#include "gdb/gdbmi.h"
#include "tcf/json.h"
#include "gdbmacros.h"
#include "gdbmacros_p.h"
#undef NS
#ifdef QT_NAMESPACE
# define STRINGIFY0(s) #s
# define STRINGIFY1(s) STRINGIFY0(s)
# define NS STRINGIFY1(QT_NAMESPACE) "::"
#else
# define NS ""
#endif
using namespace Debugger;
using namespace Debugger::Internal;
static QByteArray stripped(QByteArray ba)
{
for (int i = ba.size(); --i >= 0; ) {
if (ba.at(i) == '\n' || ba.at(i) == ' ')
ba.chop(1);
else
break;
}
return ba;
}
class tst_Plugin : public QObject
{
Q_OBJECT
public:
tst_Plugin() {}
public slots:
void runQtc();
public slots:
void readStandardOutput();
void readStandardError();
private:
QProcess m_proc; // the Qt Creator process
};
void tst_Plugin::readStandardOutput()
{
qDebug() << "qtcreator-out: " << stripped(m_proc.readAllStandardOutput());
}
void tst_Plugin::readStandardError()
{
qDebug() << "qtcreator-err: " << stripped(m_proc.readAllStandardError());
}
void tst_Plugin::runQtc()
{
QString test = QFileInfo(qApp->arguments().at(0)).absoluteFilePath();
QString qtc = QFileInfo(test).absolutePath() + "/../../../bin/qtcreator.bin";
qtc = QFileInfo(qtc).absoluteFilePath();
QStringList env = QProcess::systemEnvironment();
env.append("QTC_DEBUGGER_TEST=" + test);
m_proc.setEnvironment(env);
connect(&m_proc, SIGNAL(readyReadStandardOutput()),
this, SLOT(readStandardOutput()));
connect(&m_proc, SIGNAL(readyReadStandardError()),
this, SLOT(readStandardError()));
m_proc.start(qtc);
m_proc.waitForStarted();
QCOMPARE(m_proc.state(), QProcess::Running);
m_proc.waitForFinished();
QCOMPARE(m_proc.state(), QProcess::NotRunning);
}
void runDebuggee()
{
qDebug() << "RUNNING DEBUGGEE";
}
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QStringList args = app.arguments();
if (args.size() == 2 && args.at(1) == "--run-debuggee") {
runDebuggee();
app.exec();
return 0;
}
tst_Plugin test;
return QTest::qExec(&test, argc, argv);
}
#include "tst_plugin.moc"
Supports Markdown
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