[Pkg-owncloud-commits] [owncloud-client] 252/470: Simplify the build of auto tests

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu May 12 16:25:10 UTC 2016


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit f42795551235568ecf4c82514c2175164d24c64a
Author: Jocelyn Turcotte <jturcotte at woboq.com>
Date:   Wed Mar 30 17:58:15 2016 +0200

    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.
---
 test/CMakeLists.txt                                |  2 --
 test/main.cpp.in                                   | 22 ----------------------
 test/oc_bin.h.in                                   |  3 ---
 test/owncloud_add_test.cmake                       |  5 +----
 ...ecksumvalidator.h => testchecksumvalidator.cpp} |  5 +++--
 test/{testconcaturl.h => testconcaturl.cpp}        |  6 ++----
 test/{testcsyncsqlite.h => testcsyncsqlite.cpp}    |  6 ++----
 .../{testexcludedfiles.h => testexcludedfiles.cpp} |  5 ++---
 test/{testfilesystem.h => testfilesystem.cpp}      |  6 ++----
 test/{testfolder.h => testfolder.cpp}              |  6 ++----
 test/{testfolderman.h => testfolderman.cpp}        |  5 ++---
 .../{testfolderwatcher.h => testfolderwatcher.cpp} |  6 ++----
 ...testinotifywatcher.h => testinotifywatcher.cpp} |  6 ++----
 test/{testnetrcparser.h => testnetrcparser.cpp}    |  6 ++----
 ...loudpropagator.h => testowncloudpropagator.cpp} |  6 ++----
 test/{testownsql.h => testownsql.cpp}              |  6 ++----
 test/{testsyncfileitem.h => testsyncfileitem.cpp}  |  6 ++----
 .../{testsyncjournaldb.h => testsyncjournaldb.cpp} |  6 ++----
 test/{testupdater.h => testupdater.cpp}            |  6 ++----
 test/{testutility.h => testutility.cpp}            | 12 ++++++------
 test/{testxmlparse.h => testxmlparse.cpp}          |  6 ++----
 21 files changed, 40 insertions(+), 97 deletions(-)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index c001c5e..b218aa9 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -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 "")
diff --git a/test/main.cpp.in b/test/main.cpp.in
deleted file mode 100644
index 7d39807..0000000
--- a/test/main.cpp.in
+++ /dev/null
@@ -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 at OWNCLOUD_TEST_CLASS_LOWERCASE@.h"
-// #include "moc_test at 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 at OWNCLOUD_TEST_CLASS@ );
-    return 0;
-}
diff --git a/test/oc_bin.h.in b/test/oc_bin.h.in
deleted file mode 100644
index 4af6176..0000000
--- a/test/oc_bin.h.in
+++ /dev/null
@@ -1,3 +0,0 @@
-
-#define OWNCLOUD_BIN "@CMAKE_BINARY_DIR@/bin/owncloud"
-
diff --git a/test/owncloud_add_test.cmake b/test/owncloud_add_test.cmake
index 3129f4b..f9e5986 100644
--- a/test/owncloud_add_test.cmake
+++ b/test/owncloud_add_test.cmake
@@ -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)
diff --git a/test/testchecksumvalidator.h b/test/testchecksumvalidator.cpp
similarity index 98%
rename from test/testchecksumvalidator.h
rename to test/testchecksumvalidator.cpp
index 2813da1..8338c00 100644
--- a/test/testchecksumvalidator.h
+++ b/test/testchecksumvalidator.cpp
@@ -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"
diff --git a/test/testconcaturl.h b/test/testconcaturl.cpp
similarity index 97%
rename from test/testconcaturl.h
rename to test/testconcaturl.cpp
index dd75fb1..b38d526 100644
--- a/test/testconcaturl.h
+++ b/test/testconcaturl.cpp
@@ -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"
diff --git a/test/testcsyncsqlite.h b/test/testcsyncsqlite.cpp
similarity index 97%
rename from test/testcsyncsqlite.h
rename to test/testcsyncsqlite.cpp
index be7b556..490f286 100644
--- a/test/testcsyncsqlite.h
+++ b/test/testcsyncsqlite.cpp
@@ -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"
diff --git a/test/testexcludedfiles.h b/test/testexcludedfiles.cpp
similarity index 95%
rename from test/testexcludedfiles.h
rename to test/testexcludedfiles.cpp
index 659c659..446a9cb 100644
--- a/test/testexcludedfiles.h
+++ b/test/testexcludedfiles.cpp
@@ -5,8 +5,6 @@
  *
  */
 
-#pragma once
-
 #include <QtTest>
 
 #include "excludedfiles.h"
@@ -47,4 +45,5 @@ private slots:
     }
 };
 
-
+QTEST_MAIN(TestExcludedFiles)
+#include "testexcludedfiles.moc"
diff --git a/test/testfilesystem.h b/test/testfilesystem.cpp
similarity index 96%
rename from test/testfilesystem.h
rename to test/testfilesystem.cpp
index 300e044..85983bc 100644
--- a/test/testfilesystem.h
+++ b/test/testfilesystem.cpp
@@ -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"
diff --git a/test/testfolder.h b/test/testfolder.cpp
similarity index 94%
rename from test/testfolder.h
rename to test/testfolder.cpp
index 786f798..2ed4870 100644
--- a/test/testfolder.h
+++ b/test/testfolder.cpp
@@ -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"
diff --git a/test/testfolderman.h b/test/testfolderman.cpp
similarity index 98%
rename from test/testfolderman.h
rename to test/testfolderman.cpp
index 35ba8ba..47e115d 100644
--- a/test/testfolderman.h
+++ b/test/testfolderman.cpp
@@ -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"
diff --git a/test/testfolderwatcher.h b/test/testfolderwatcher.cpp
similarity index 98%
rename from test/testfolderwatcher.h
rename to test/testfolderwatcher.cpp
index 14b1ff3..9ce4eb7 100644
--- a/test/testfolderwatcher.h
+++ b/test/testfolderwatcher.cpp
@@ -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"
diff --git a/test/testinotifywatcher.h b/test/testinotifywatcher.cpp
similarity index 96%
rename from test/testinotifywatcher.h
rename to test/testinotifywatcher.cpp
index 454c57a..c1100aa 100644
--- a/test/testinotifywatcher.h
+++ b/test/testinotifywatcher.cpp
@@ -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"
diff --git a/test/testnetrcparser.h b/test/testnetrcparser.cpp
similarity index 97%
rename from test/testnetrcparser.h
rename to test/testnetrcparser.cpp
index b77f2f7..2bb6683 100644
--- a/test/testnetrcparser.h
+++ b/test/testnetrcparser.cpp
@@ -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"
diff --git a/test/testowncloudpropagator.h b/test/testowncloudpropagator.cpp
similarity index 96%
rename from test/testowncloudpropagator.h
rename to test/testowncloudpropagator.cpp
index ab3504a..55c0c5b 100644
--- a/test/testowncloudpropagator.h
+++ b/test/testowncloudpropagator.cpp
@@ -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"
diff --git a/test/testownsql.h b/test/testownsql.cpp
similarity index 98%
rename from test/testownsql.h
rename to test/testownsql.cpp
index 872c11d..a45f099 100644
--- a/test/testownsql.h
+++ b/test/testownsql.cpp
@@ -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"
diff --git a/test/testsyncfileitem.h b/test/testsyncfileitem.cpp
similarity index 96%
rename from test/testsyncfileitem.h
rename to test/testsyncfileitem.cpp
index 5fa062f..e2cc12b 100644
--- a/test/testsyncfileitem.h
+++ b/test/testsyncfileitem.cpp
@@ -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"
diff --git a/test/testsyncjournaldb.h b/test/testsyncjournaldb.cpp
similarity index 98%
rename from test/testsyncjournaldb.h
rename to test/testsyncjournaldb.cpp
index 1ca8470..9bfce3b 100644
--- a/test/testsyncjournaldb.h
+++ b/test/testsyncjournaldb.cpp
@@ -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"
diff --git a/test/testupdater.h b/test/testupdater.cpp
similarity index 92%
rename from test/testupdater.h
rename to test/testupdater.cpp
index b90c51d..deb3821 100644
--- a/test/testupdater.h
+++ b/test/testupdater.cpp
@@ -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"
diff --git a/test/testutility.h b/test/testutility.cpp
similarity index 97%
rename from test/testutility.h
rename to test/testutility.cpp
index a4b9572..ba6b9fb 100644
--- a/test/testutility.h
+++ b/test/testutility.cpp
@@ -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"
diff --git a/test/testxmlparse.h b/test/testxmlparse.cpp
similarity index 99%
rename from test/testxmlparse.h
rename to test/testxmlparse.cpp
index 39d3f75..a5b66aa 100644
--- a/test/testxmlparse.h
+++ b/test/testxmlparse.cpp
@@ -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"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list