mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 04:55:48 +03:00
Simplify the build of auto tests
Remove all configure_files: - Move all tests to cpp files - Use the QTEST_MAIN macro instead of a generated main.cpp - Include test*.moc in the cpp to let CMAKE_AUTOMOC call moc - Pass info through add_definitions instead of generating oc_bin.h with them This makes sure that build errors points to the original test source file instead of the generated one in the build directory to be able to jump and fix errors directly from the IDE's error pane.
This commit is contained in:
parent
dd8b0c3e4a
commit
f427955512
21 changed files with 40 additions and 97 deletions
|
@ -26,8 +26,6 @@ if( UNIX AND NOT APPLE )
|
|||
owncloud_add_test(InotifyWatcher "${FolderWatcher_SRC}")
|
||||
endif(UNIX AND NOT APPLE)
|
||||
|
||||
configure_file(oc_bin.h.in oc_bin.h)
|
||||
|
||||
owncloud_add_test(CSyncSqlite "")
|
||||
owncloud_add_test(NetrcParser ../src/cmd/netrcparser.cpp)
|
||||
owncloud_add_test(OwnSql "")
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
This software is in the public domain, furnished "as is", without technical
|
||||
support, and with no warranty, express or implied, as to its usefulness for
|
||||
any purpose.
|
||||
*/
|
||||
#include <QtCore>
|
||||
#include <QtTest>
|
||||
|
||||
#include "test@OWNCLOUD_TEST_CLASS_LOWERCASE@.h"
|
||||
// #include "moc_test@OWNCLOUD_TEST_CLASS_LOWERCASE@.cpp"
|
||||
|
||||
int main( int argc, char** argv)
|
||||
{
|
||||
QCoreApplication app( argc, argv );
|
||||
|
||||
#define TEST( Type ) { \
|
||||
Type o; \
|
||||
if (int r = QTest::qExec( &o, argc, argv ) != 0) return r; }
|
||||
|
||||
TEST( Test@OWNCLOUD_TEST_CLASS@ );
|
||||
return 0;
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
|
||||
#define OWNCLOUD_BIN "@CMAKE_BINARY_DIR@/bin/owncloud"
|
||||
|
|
@ -6,12 +6,9 @@ macro(owncloud_add_test test_class additional_cpp)
|
|||
"${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
|
||||
set(OWNCLOUD_TEST_CLASS ${test_class})
|
||||
set(CMAKE_AUTOMOC TRUE)
|
||||
set(OWNCLOUD_TEST_CLASS ${test_class})
|
||||
string(TOLOWER "${OWNCLOUD_TEST_CLASS}" OWNCLOUD_TEST_CLASS_LOWERCASE)
|
||||
configure_file(main.cpp.in test${OWNCLOUD_TEST_CLASS_LOWERCASE}.cpp)
|
||||
configure_file(test${OWNCLOUD_TEST_CLASS_LOWERCASE}.h test${OWNCLOUD_TEST_CLASS_LOWERCASE}.h)
|
||||
qt_wrap_cpp(test${OWNCLOUD_TEST_CLASS_LOWERCASE}.h)
|
||||
|
||||
add_executable(${OWNCLOUD_TEST_CLASS}Test test${OWNCLOUD_TEST_CLASS_LOWERCASE}.cpp ${additional_cpp})
|
||||
qt5_use_modules(${OWNCLOUD_TEST_CLASS}Test Test Sql Xml Network Gui Widgets)
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtTest>
|
||||
#include <QDir>
|
||||
#include <QString>
|
||||
|
@ -151,3 +149,6 @@ using namespace OCC;
|
|||
void cleanupTestCase() {
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_MAIN(TestChecksumValidator)
|
||||
#include "testchecksumvalidator.moc"
|
|
@ -5,9 +5,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef MIRALL_TESTCONCATURL_H
|
||||
#define MIRALL_TESTCONCATURL_H
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include <QUrl>
|
||||
|
@ -103,4 +100,5 @@ private slots:
|
|||
|
||||
};
|
||||
|
||||
#endif
|
||||
QTEST_MAIN(TestConcatUrl)
|
||||
#include "testconcaturl.moc"
|
|
@ -4,9 +4,6 @@
|
|||
any purpose.
|
||||
*/
|
||||
|
||||
#ifndef MIRALL_TESTCSYNCSQLITE_H
|
||||
#define MIRALL_TESTCSYNCSQLITE_H
|
||||
|
||||
#include "csync_statedb.h"
|
||||
#include "csync_private.h"
|
||||
#include <QtTest>
|
||||
|
@ -88,4 +85,5 @@ private slots:
|
|||
|
||||
};
|
||||
|
||||
#endif
|
||||
QTEST_MAIN(TestCSyncSqlite)
|
||||
#include "testcsyncsqlite.moc"
|
|
@ -5,8 +5,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "excludedfiles.h"
|
||||
|
@ -47,4 +45,5 @@ private slots:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
QTEST_MAIN(TestExcludedFiles)
|
||||
#include "testexcludedfiles.moc"
|
|
@ -4,9 +4,6 @@
|
|||
any purpose.
|
||||
*/
|
||||
|
||||
#ifndef MIRALL_TESTFILESYSTEM_H
|
||||
#define MIRALL_TESTFILESYSTEM_H
|
||||
|
||||
#include <QtTest>
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -90,4 +87,5 @@ private slots:
|
|||
|
||||
};
|
||||
|
||||
#endif
|
||||
QTEST_MAIN(TestFileSystem)
|
||||
#include "testfilesystem.moc"
|
|
@ -5,9 +5,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef MIRALL_TESTFOLDER_H
|
||||
#define MIRALL_TESTFOLDER_H
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "utility.h"
|
||||
|
@ -44,4 +41,5 @@ private slots:
|
|||
|
||||
};
|
||||
|
||||
#endif
|
||||
QTEST_MAIN(TestFolder)
|
||||
#include "testfolder.moc"
|
|
@ -5,8 +5,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <qglobal.h>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
#include <QTemporaryDir>
|
||||
|
@ -120,4 +118,5 @@ private slots:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
QTEST_MAIN(TestFolderMan)
|
||||
#include "testfolderman.moc"
|
|
@ -5,9 +5,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef MIRALL_TESTFOLDERWATCHER_H
|
||||
#define MIRALL_TESTFOLDERWATCHER_H
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "folderwatcher.h"
|
||||
|
@ -173,4 +170,5 @@ private slots:
|
|||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
QTEST_MAIN(TestFolderWatcher)
|
||||
#include "testfolderwatcher.moc"
|
|
@ -4,9 +4,6 @@
|
|||
* any purpose.
|
||||
* */
|
||||
|
||||
#ifndef MIRALL_INOTIFYWATCHER_H
|
||||
#define MIRALL_INOTIFYWATCHER_H
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "folderwatcher_linux.h"
|
||||
|
@ -72,4 +69,5 @@ private slots:
|
|||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
QTEST_MAIN(TestInotifyWatcher)
|
||||
#include "testinotifywatcher.moc"
|
|
@ -4,9 +4,6 @@
|
|||
* any purpose.
|
||||
* */
|
||||
|
||||
#ifndef MIRALL_INOTIFYWATCHER_H
|
||||
#define MIRALL_INOTIFYWATCHER_H
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "cmd/netrcparser.h"
|
||||
|
@ -73,4 +70,5 @@ private slots:
|
|||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
QTEST_MAIN(TestNetrcParser)
|
||||
#include "testnetrcparser.moc"
|
|
@ -4,9 +4,6 @@
|
|||
any purpose.
|
||||
*/
|
||||
|
||||
#ifndef MIRALL_TESTOWNCLOUDPROPAGATOR_H
|
||||
#define MIRALL_TESTOWNCLOUDPROPAGATOR_H
|
||||
|
||||
#include <QtTest>
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -81,4 +78,5 @@ private slots:
|
|||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
QTEST_MAIN(TestOwncloudPropagator)
|
||||
#include "testowncloudpropagator.moc"
|
|
@ -4,9 +4,6 @@
|
|||
* any purpose.
|
||||
* */
|
||||
|
||||
#ifndef MIRALL_TESTOWNSQL_H
|
||||
#define MIRALL_TESTOWNSQL_H
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
@ -152,4 +149,5 @@ private:
|
|||
SqlDatabase _db;
|
||||
};
|
||||
|
||||
#endif
|
||||
QTEST_MAIN(TestOwnSql)
|
||||
#include "testownsql.moc"
|
|
@ -4,9 +4,6 @@
|
|||
* any purpose.
|
||||
* */
|
||||
|
||||
#ifndef MIRALL_TESTSYNCFILEITEM_H
|
||||
#define MIRALL_TESTSYNCFILEITEM_H
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "syncfileitem.h"
|
||||
|
@ -68,4 +65,5 @@ private slots:
|
|||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
QTEST_MAIN(TestSyncFileItem)
|
||||
#include "testsyncfileitem.moc"
|
|
@ -4,9 +4,6 @@
|
|||
* any purpose.
|
||||
* */
|
||||
|
||||
#ifndef MIRALL_TESTSYNCJOURNALDB_H
|
||||
#define MIRALL_TESTSYNCJOURNALDB_H
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
@ -174,4 +171,5 @@ private:
|
|||
SyncJournalDb _db;
|
||||
};
|
||||
|
||||
#endif
|
||||
QTEST_MAIN(TestSyncJournalDB)
|
||||
#include "testsyncjournaldb.moc"
|
|
@ -4,9 +4,6 @@
|
|||
any purpose.
|
||||
*/
|
||||
|
||||
#ifndef MIRALL_TESTUTILITY_H
|
||||
#define MIRALL_TESTUTILITY_H
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "updater/updater.h"
|
||||
|
@ -33,4 +30,5 @@ private slots:
|
|||
|
||||
};
|
||||
|
||||
#endif
|
||||
QTEST_MAIN(TestUpdater)
|
||||
#include "testupdater.moc"
|
|
@ -4,14 +4,13 @@
|
|||
any purpose.
|
||||
*/
|
||||
|
||||
#ifndef MIRALL_TESTUTILITY_H
|
||||
#define MIRALL_TESTUTILITY_H
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "utility.h"
|
||||
|
||||
#include "oc_bin.h"
|
||||
#define STR_(X) #X
|
||||
#define STR(X) STR_(X)
|
||||
#define BIN_PATH STR(OWNCLOUD_BIN_PATH)
|
||||
|
||||
using namespace OCC::Utility;
|
||||
|
||||
|
@ -122,7 +121,7 @@ private slots:
|
|||
// Current requires an X-Server
|
||||
return;
|
||||
}
|
||||
QString ver = versionOfInstalledBinary(OWNCLOUD_BIN);
|
||||
QString ver = versionOfInstalledBinary(BIN_PATH);
|
||||
qDebug() << "Version of installed ownCloud Binary: " << ver;
|
||||
QVERIFY( !ver.isEmpty());
|
||||
|
||||
|
@ -166,4 +165,5 @@ private slots:
|
|||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
QTEST_MAIN(TestUtility)
|
||||
#include "testutility.moc"
|
|
@ -4,9 +4,6 @@
|
|||
* any purpose.
|
||||
* */
|
||||
|
||||
#ifndef MIRALL_TESTXMLPARSE_H
|
||||
#define MIRALL_TESTXMLPARSE_H
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "networkjobs.h"
|
||||
|
@ -444,4 +441,5 @@ private slots:
|
|||
|
||||
};
|
||||
|
||||
#endif
|
||||
QTEST_MAIN(TestXmlParse)
|
||||
#include "testxmlparse.moc"
|
Loading…
Reference in a new issue