diff options
Diffstat (limited to 'Tests')
21 files changed, 295 insertions, 16 deletions
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 4a5558d..b560acd 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -428,6 +428,14 @@ else() HAVE_FINAL=$<COMPILE_FEATURES:cxx_final> HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final> ) + if (CMAKE_CXX_STANDARD_DEFAULT) + target_compile_definitions(CompileFeaturesGenex PRIVATE + TEST_CXX_STD + HAVE_CXX_STD_11=$<COMPILE_FEATURES:cxx_std_11> + HAVE_CXX_STD_14=$<COMPILE_FEATURES:cxx_std_14> + HAVE_CXX_STD_17=$<COMPILE_FEATURES:cxx_std_17> + ) + endif() add_executable(CompileFeaturesGenex2 genex_test.cpp) target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_std_11) diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp index 5ae8a78..5303e73 100644 --- a/Tests/CompileFeatures/genex_test.cpp +++ b/Tests/CompileFeatures/genex_test.cpp @@ -11,6 +11,18 @@ #error EXPECT_OVERRIDE_CONTROL not defined #endif +#ifdef TEST_CXX_STD +#if !HAVE_CXX_STD_11 +#error HAVE_CXX_STD_11 is false with CXX_STANDARD == 11 +#endif +#if HAVE_CXX_STD_14 +#error HAVE_CXX_STD_14 is true with CXX_STANDARD == 11 +#endif +#if HAVE_CXX_STD_17 +#error HAVE_CXX_STD_17 is true with CXX_STANDARD == 11 +#endif +#endif + #if !HAVE_OVERRIDE_CONTROL #if EXPECT_OVERRIDE_CONTROL #error "Expect override control feature" diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index 5064d26..198bf63 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -193,5 +193,9 @@ endif() add_subdirectory(uicInclude) # -- Test +# OBJECT libraries +add_subdirectory(objectLibrary) + +# -- Test # Complex test case add_subdirectory(complex) diff --git a/Tests/QtAutogen/objectLibrary/CMakeLists.txt b/Tests/QtAutogen/objectLibrary/CMakeLists.txt new file mode 100644 index 0000000..9b29a40 --- /dev/null +++ b/Tests/QtAutogen/objectLibrary/CMakeLists.txt @@ -0,0 +1,14 @@ +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) + +# Object library a defined in a subdirectory +add_subdirectory(a) + +# Object library b defined locally +include_directories(b) +add_library(b OBJECT b/classb.cpp) +target_compile_features(b PRIVATE ${QT_COMPILE_FEATURES}) + +# Executable with OBJECT library generator expressions +add_executable(someProgram main.cpp $<TARGET_OBJECTS:a> $<TARGET_OBJECTS:b>) +target_link_libraries(someProgram ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/objectLibrary/a/CMakeLists.txt b/Tests/QtAutogen/objectLibrary/a/CMakeLists.txt new file mode 100644 index 0000000..fe76ac3 --- /dev/null +++ b/Tests/QtAutogen/objectLibrary/a/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(a OBJECT classa.cpp) +target_compile_features(a PRIVATE ${QT_COMPILE_FEATURES}) diff --git a/Tests/QtAutogen/objectLibrary/a/classa.cpp b/Tests/QtAutogen/objectLibrary/a/classa.cpp new file mode 100644 index 0000000..4f08fda --- /dev/null +++ b/Tests/QtAutogen/objectLibrary/a/classa.cpp @@ -0,0 +1,7 @@ +#include "classa.h" +#include <QDebug> + +void ClassA::slotDoSomething() +{ + qDebug() << m_member; +} diff --git a/Tests/QtAutogen/objectLibrary/a/classa.h b/Tests/QtAutogen/objectLibrary/a/classa.h new file mode 100644 index 0000000..fa5fed9 --- /dev/null +++ b/Tests/QtAutogen/objectLibrary/a/classa.h @@ -0,0 +1,23 @@ +#ifndef CLASSA_H +#define CLASSA_H + +#include <QObject> +#include <QString> + +class ClassA : public QObject +{ + Q_OBJECT +public: + ClassA() + : m_member("Hello A") + { + } + +public slots: + void slotDoSomething(); + +private: + QString m_member; +}; + +#endif diff --git a/Tests/QtAutogen/objectLibrary/b/classb.cpp b/Tests/QtAutogen/objectLibrary/b/classb.cpp new file mode 100644 index 0000000..26e0926 --- /dev/null +++ b/Tests/QtAutogen/objectLibrary/b/classb.cpp @@ -0,0 +1,7 @@ +#include "classb.h" +#include <QDebug> + +void ClassB::slotDoSomething() +{ + qDebug() << m_member; +} diff --git a/Tests/QtAutogen/objectLibrary/b/classb.h b/Tests/QtAutogen/objectLibrary/b/classb.h new file mode 100644 index 0000000..783bb48 --- /dev/null +++ b/Tests/QtAutogen/objectLibrary/b/classb.h @@ -0,0 +1,23 @@ +#ifndef CLASSB_H +#define CLASSB_H + +#include <QObject> +#include <QString> + +class ClassB : public QObject +{ + Q_OBJECT +public: + ClassB() + : m_member("Hello B") + { + } + +public slots: + void slotDoSomething(); + +private: + QString m_member; +}; + +#endif diff --git a/Tests/QtAutogen/objectLibrary/main.cpp b/Tests/QtAutogen/objectLibrary/main.cpp new file mode 100644 index 0000000..cacf0fd --- /dev/null +++ b/Tests/QtAutogen/objectLibrary/main.cpp @@ -0,0 +1,13 @@ +#include "a/classa.h" +#include "b/classb.h" + +int main(int argc, char** argv) +{ + ClassA a; + a.slotDoSomething(); + + ClassB b; + b.slotDoSomething(); + + return 0; +} diff --git a/Tests/QtAutogen/uicInclude/PageC2.ui b/Tests/QtAutogen/uicInclude/PageC2.ui new file mode 100644 index 0000000..daab868 --- /dev/null +++ b/Tests/QtAutogen/uicInclude/PageC2.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PageC2</class> + <widget class="QWidget" name="PageC2"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/uicInclude/dirB/sub/PageB.ui b/Tests/QtAutogen/uicInclude/dirB/PageB.ui index fa6dfa6..fa6dfa6 100644 --- a/Tests/QtAutogen/uicInclude/dirB/sub/PageB.ui +++ b/Tests/QtAutogen/uicInclude/dirB/PageB.ui diff --git a/Tests/QtAutogen/uicInclude/dirB/PageB2.ui b/Tests/QtAutogen/uicInclude/dirB/PageB2.ui new file mode 100644 index 0000000..2225150 --- /dev/null +++ b/Tests/QtAutogen/uicInclude/dirB/PageB2.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PageB2</class> + <widget class="QWidget" name="PageB2"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/uicInclude/dirB/subB/PageBsub.ui b/Tests/QtAutogen/uicInclude/dirB/subB/PageBsub.ui new file mode 100644 index 0000000..873016e --- /dev/null +++ b/Tests/QtAutogen/uicInclude/dirB/subB/PageBsub.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PageBsub</class> + <widget class="QWidget" name="PageBsub"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/QtAutogen/uicInclude/main.cpp b/Tests/QtAutogen/uicInclude/main.cpp index 4ca66a7..c8e7609 100644 --- a/Tests/QtAutogen/uicInclude/main.cpp +++ b/Tests/QtAutogen/uicInclude/main.cpp @@ -6,5 +6,13 @@ int main(int argv, char** args) return 0; } -#include "sub/ui_PageB.h" +// .ui files in CMAKE_AUTOUIC_SEARCH_PATHS +#include "ui_PageA.h" +// .ui files in AUTOUIC_SEARCH_PATHS +#include "sub/gen/deep/ui_PageB2.h" +#include "subB/ui_PageBsub.h" +#include "ui_PageB.h" +// .ui files in source's vicinity +#include "sub/gen/deep/ui_PageC2.h" +#include "subC/ui_PageCsub.h" #include "ui_PageC.h" diff --git a/Tests/QtAutogen/uicInclude/subC/PageCsub.ui b/Tests/QtAutogen/uicInclude/subC/PageCsub.ui new file mode 100644 index 0000000..0268326 --- /dev/null +++ b/Tests/QtAutogen/uicInclude/subC/PageCsub.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PageCsub</class> + <widget class="QWidget" name="PageCsub"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="treeView"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/Server/CMakeLists.txt b/Tests/Server/CMakeLists.txt index e7eaa8d..2ad05c3 100644 --- a/Tests/Server/CMakeLists.txt +++ b/Tests/Server/CMakeLists.txt @@ -20,6 +20,7 @@ macro(do_test bsname file) endif() endmacro() +do_test("test_cache" "tc_cache.json") do_test("test_handshake" "tc_handshake.json") do_test("test_globalSettings" "tc_globalSettings.json") do_test("test_buildsystem1" "tc_buildsystem1.json") diff --git a/Tests/Server/cmakelib.py b/Tests/Server/cmakelib.py index 78450d5..2218e02 100644 --- a/Tests/Server/cmakelib.py +++ b/Tests/Server/cmakelib.py @@ -95,6 +95,21 @@ def initProc(cmakeCommand): return cmakeCommand +def exitProc(cmakeCommand): + # Tell the server to exit. + cmakeCommand.stdin.close() + cmakeCommand.stdout.close() + + # Wait for the server to exit. + # If this version of python supports it, terminate the server after a timeout. + try: + cmakeCommand.wait(timeout=5) + except TypeError: + cmakeCommand.wait() + except: + cmakeCommand.terminate() + raise + def waitForMessage(cmakeCommand, expected): data = ordered(expected) packet = ordered(waitForRawMessage(cmakeCommand)) @@ -197,3 +212,27 @@ def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data): print("Validating", i) if (packet[i] != data[i]): sys.exit(1) + +def validateCache(cmakeCommand, data): + packet = waitForReply(cmakeCommand, 'cache', '', False) + + cache = packet['cache'] + + if (data['isEmpty']): + if (cache != []): + print('Expected empty cache, but got data.\n') + sys.exit(1) + return; + + if (cache == []): + print('Expected cache contents, but got none.\n') + sys.exit(1) + + hadHomeDir = False + for value in cache: + if (value['key'] == 'CMAKE_HOME_DIRECTORY'): + hadHomeDir = True + + if (not hadHomeDir): + print('No CMAKE_HOME_DIRECTORY found in cache.') + sys.exit(1) diff --git a/Tests/Server/server-test.py b/Tests/Server/server-test.py index 5621111..f5a3f28 100644 --- a/Tests/Server/server-test.py +++ b/Tests/Server/server-test.py @@ -84,7 +84,7 @@ for obj in testData: if 'extraGenerator' in data: extraGenerator = data['extraGenerator'] if not os.path.isabs(buildDirectory): buildDirectory = buildDir + "/" + buildDirectory - if not os.path.isabs(sourceDirectory): + if sourceDirectory != '' and not os.path.isabs(sourceDirectory): sourceDirectory = sourceDir + "/" + sourceDirectory cmakelib.handshake(proc, major, minor, sourceDirectory, buildDirectory, generator, extraGenerator) @@ -95,26 +95,20 @@ for obj in testData: if not 'generator' in data: data['generator'] = cmakeGenerator if not 'extraGenerator' in data: data['extraGenerator'] = '' cmakelib.validateGlobalSettings(proc, cmakeCommand, data) + elif 'validateCache' in obj: + data = obj['validateCache'] + if not 'isEmpty' in data: data['isEmpty'] = false + cmakelib.validateCache(proc, data) elif 'message' in obj: print("MESSAGE:", obj["message"]) + elif 'reconnect' in obj: + cmakelib.exitProc(proc) + proc = cmakelib.initProc(cmakeCommand) else: print("Unknown command:", json.dumps(obj)) sys.exit(2) print("Completed") -# Tell the server to exit. -proc.stdin.close() -proc.stdout.close() - -# Wait for the server to exit. -# If this version of python supports it, terminate the server after a timeout. -try: - proc.wait(timeout=5) -except TypeError: - proc.wait() -except: - proc.terminate() - raise - +cmakelib.exitProc(proc) sys.exit(proc.returncode) diff --git a/Tests/Server/tc_cache.json b/Tests/Server/tc_cache.json new file mode 100644 index 0000000..74af6d9 --- /dev/null +++ b/Tests/Server/tc_cache.json @@ -0,0 +1,24 @@ +[ +{ "message": "Testing cache" }, + +{ "message": "Cache after first handshake is empty:" }, +{ "handshake": {"major": 1, "sourceDirectory": "buildsystem1", "buildDirectory": "buildsystem1"} }, +{ "send": { "type": "cache" } }, +{ "validateCache": { "isEmpty": true } }, + +{ "message": "Cache after configure is populated:" }, +{ "send": { "type": "configure" } }, +{ "reply": { "type": "configure", "skipProgress":true } }, +{ "send": { "type": "cache" } }, +{ "validateCache": { "isEmpty": false } }, + +{ "message": "Handshake for existing cache requires buildDirectory only:" }, +{ "reconnect": {} }, +{ "handshake": {"major": 1, "sourceDirectory": "", "buildDirectory": "buildsystem1"} }, + +{ "message": "Cache after reconnect is again populated:" }, +{ "send": { "type": "cache" } }, +{ "validateCache": { "isEmpty": false } }, + +{ "message": "Everything ok." } +] diff --git a/Tests/Server/tc_handshake.json b/Tests/Server/tc_handshake.json index 975bb3d..4bb7fa7 100644 --- a/Tests/Server/tc_handshake.json +++ b/Tests/Server/tc_handshake.json @@ -11,6 +11,10 @@ { "send": {"test": "sometext","cookie":"monster"} }, { "recv": {"cookie":"monster","errorMessage":"No type given in request.","inReplyTo":"","type":"error"} }, +{ "message": "Testing commands before handshake" }, +{ "send": {"type": "cache","cookie":"monster"} }, +{ "recv": {"cookie":"monster","errorMessage":"Waiting for type \"handshake\".","inReplyTo":"cache","type":"error"} }, + { "message": "Testing handshake" }, { "send": {"type": "sometype","cookie":"monster2"} }, { "recv": {"cookie":"monster2","errorMessage":"Waiting for type \"handshake\".","inReplyTo":"sometype","type":"error"} }, |