# # # add_file "tests/MonotoneTest.h" # content [73986287a1873b2e72dbc62743a7cdd9ab317fb7] # # patch "tests/test.cpp" # from [5c0d58e33ae0f5c94e1165555413fe17a9c89c35] # to [8c345925e352aea61e5f51a0b2ad01fb6475c282] # # patch "tests/test.pro" # from [a26d718f0957faf3945331cd06b5c562fc1ac210] # to [b437a3ca1b89faa23f2665324caa1a2f121184a3] # ============================================================ --- tests/MonotoneTest.h 73986287a1873b2e72dbc62743a7cdd9ab317fb7 +++ tests/MonotoneTest.h 73986287a1873b2e72dbc62743a7cdd9ab317fb7 @@ -0,0 +1,69 @@ + +#include +#include +#include +#include "Monotone.h" + +class MonotoneTest: public QObject +{ + Q_OBJECT + +private slots: + void initTestCase() + { + QVERIFY(Monotone::checkProgramVersion("mtn")); + QDir tmpDir = QDir::temp(); + QVERIFY(tmpDir.mkdir("guitone-test")); + QVERIFY(tmpDir.cd("guitone-test")); + + QString out; + QVERIFY(runmtn(QStringList() << "init", out)); + QVERIFY(runmtn(QStringList() << "setup" << "-b foo" << ".", out)); + + mtn = new Monotone(0); + QVERIFY(mtn->loadWorkspace(tmpDir.absolutePath())); + } + + void getOptionTest() + { + QVERIFY(true); + } + + void cleanupTestCase() + { + QDir tmpDir = QDir::temp(); + removePath(tmpDir.filePath("guitone-test")); + delete mtn; + } + +private: + bool runmtn(const QStringList & a, QString & output) + { + QDir tmpDir = QDir::temp(); + Q_ASSERT(tmpDir.cd("guitone-test")); + QStringList args; + args << QString("-d %1").arg(tmpDir.filePath("test.mtn")) << a; + return Monotone::runCommand("mtn", args, output); + } + + void removePath(const QString & path) + { + QFileInfo fileInfo(path); + if (fileInfo.isDir()) + { + QDir dir(path); + QStringList entries = dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot); + foreach (QString entry, entries) + { + removePath(dir.filePath(entry)); + } + dir.rmdir(path); + return; + } + QFile::remove(path); + return; + } + + Monotone * mtn; +}; + ============================================================ --- tests/test.cpp 5c0d58e33ae0f5c94e1165555413fe17a9c89c35 +++ tests/test.cpp 8c345925e352aea61e5f51a0b2ad01fb6475c282 @@ -5,6 +5,7 @@ #include "TestTest.h" #include "StdioParserTest.h" +#include "MonotoneTest.h" int main(int argc, char** argv) { @@ -12,5 +13,6 @@ int main(int argc, char** argv) TEST(TestTest, argc, argv); TEST(StdioParserTest, argc, argv); + TEST(MonotoneTest, argc, argv); } ============================================================ --- tests/test.pro a26d718f0957faf3945331cd06b5c562fc1ac210 +++ tests/test.pro b437a3ca1b89faa23f2665324caa1a2f121184a3 @@ -1,6 +1,7 @@ -TEMPLATE = app -TARGET = test -CONFIG += qt debug qtestlib +TEMPLATE = app +TARGET = test +CONFIG += qtestlib +macx:CONFIG -= app_bundle INCLUDEPATH = . \ ../src/ \ @@ -10,10 +11,15 @@ HEADERS += TestTest.h \ ../src/monotone \ ../src/util HEADERS += TestTest.h \ - StdioParserTest.h + StdioParserTest.h \ + MonotoneTest.h \ + ../src/monotone/Monotone.h \ + ../src/util/SignalWaiter.h SOURCES += test.cpp \ ../src/util/StdioParser.cpp \ - ../src/util/AbstractParser.cpp + ../src/util/AbstractParser.cpp \ + ../src/monotone/Monotone.cpp \ + ../src/util/SignalWaiter.cpp OBJECTS_DIR = tmp MOC_DIR = tmp