diff options
Diffstat (limited to 'sources/shiboken2/tests/test_generator')
11 files changed, 0 insertions, 464 deletions
diff --git a/sources/shiboken2/tests/test_generator/CMakeLists.txt b/sources/shiboken2/tests/test_generator/CMakeLists.txt deleted file mode 100644 index 07611e32c..000000000 --- a/sources/shiboken2/tests/test_generator/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(test_generator) - -set(dummy_generator_SRC dummygenerator.cpp) -add_library(dummy_generator SHARED ${dummy_generator_SRC}) -target_link_libraries(dummy_generator ${APIEXTRACTOR_LIBRARY} ${QT_QTCORE_LIBRARY} genrunner) -set_property(TARGET dummy_generator PROPERTY PREFIX "") - -add_executable(dummygenerator main.cpp) -set(DUMMYGENERATOR_EXECUTABLE dummygenerator${generator_SUFFIX}) -set_target_properties(dummygenerator PROPERTIES OUTPUT_NAME ${DUMMYGENERATOR_EXECUTABLE}) -target_link_libraries(dummygenerator ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES}) - -configure_file(dummygentestconfig.h.in "${CMAKE_CURRENT_BINARY_DIR}/dummygentestconfig.h" @ONLY) - -get_filename_component(APIEXTRACTOR_LIBRARY_DIRS ${APIEXTRACTOR_LIBRARY} PATH) -if(WIN32) - set(PATH_SEP ";") - find_program(APIEXTRACTOR_BINARY apiextractor.dll HINTS ${APIEXTRACTOR_LIBRARY_DIRS}) - get_filename_component(APIEXTRACTOR_BINARY_DIR ${APIEXTRACTOR_BINARY} PATH) - set(APIEXTRACTOR_LIBRARY_DIRS "${APIEXTRACTOR_LIBRARY_DIRS}${PATH_SEP}${APIEXTRACTOR_BINARY_DIR}") -else() - set(PATH_SEP ":") -endif() - -set(ENV_PATH "${generatorrunner_BINARY_DIR}${PATH_SEP}${CMAKE_CURRENT_BINARY_DIR}${PATH_SEP}$ENV{PATH}${PATH_SEP}${APIEXTRACTOR_LIBRARY_DIRS}") -set(ENV_QT_PLUGIN_PATH "${CMAKE_CURRENT_BINARY_DIR}${PATH_SEP}$ENV{QT_PLUGIN_PATH}") -if(WIN32) - string(REPLACE "\\;" ";" ENV_PATH "${ENV_PATH}") - string(REPLACE ";" "\\;" ENV_PATH "${ENV_PATH}") - string(REPLACE "\\;" ";" ENV_QT_PLUGIN_PATH "${ENV_QT_PLUGIN_PATH}") - string(REPLACE ";" "\\;" ENV_QT_PLUGIN_PATH "${ENV_QT_PLUGIN_PATH}") -endif() - -macro(m_add_test testname) - add_test(${testname} ${testname}) - set_property(TEST ${testname} PROPERTY ENVIRONMENT "PATH=${ENV_PATH}" "QT_PLUGIN_PATH=${ENV_QT_PLUGIN_PATH}") -endmacro() - -macro(declare_test testname) - qt4_automoc("${testname}.cpp") - add_executable(${testname} "${testname}.cpp") - include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(${testname} - ${QT_QTTEST_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${Qt${QT_MAJOR_VERSION}Test_LIBRARIES} - ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES} - ) - m_add_test(${testname}) -endmacro(declare_test testname) - -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/test_global.h" - "${CMAKE_CURRENT_BINARY_DIR}/test_global.h" COPYONLY) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/test_typesystem.xml" - "${CMAKE_CURRENT_BINARY_DIR}/test_typesystem.xml" COPYONLY) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/dummygentest-project.txt.in" - "${CMAKE_CURRENT_BINARY_DIR}/dummygentest-project.txt" @ONLY) -declare_test(dummygentest) - -add_dependencies(dummygenerator generatorrunner) - diff --git a/sources/shiboken2/tests/test_generator/dummygenerator.cpp b/sources/shiboken2/tests/test_generator/dummygenerator.cpp deleted file mode 100644 index ef82c11c9..000000000 --- a/sources/shiboken2/tests/test_generator/dummygenerator.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of Qt for Python. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <iostream> -#include "dummygenerator.h" - -EXPORT_GENERATOR_PLUGIN(new DummyGenerator) - -using namespace std; - -QString -DummyGenerator::fileNameForClass(const AbstractMetaClass* metaClass) const -{ - return QString("%1_generated.txt").arg(metaClass->name().toLower()); -} - -void -DummyGenerator::generateClass(QTextStream& s, const AbstractMetaClass* metaClass) -{ - s << "// Generated code for class: " << qPrintable(metaClass->name()) << endl; -} - -bool -DummyGenerator::doSetup(const QMap<QString, QString>& args) -{ - if (args.contains("dump-arguments") && !args["dump-arguments"].isEmpty()) { - QFile logFile(args["dump-arguments"]); - logFile.open(QIODevice::WriteOnly | QIODevice::Text); - QTextStream out(&logFile); - for (QMap<QString, QString>::const_iterator it = args.cbegin(), end = args.cend(); it != end; ++it) { - const QString& key = it.key(); - if (key == "arg-1") - out << "header-file"; - else if (key == "arg-2") - out << "typesystem-file"; - else - out << key; - if (!args[key].isEmpty()) - out << " = " << args[key]; - out << endl; - } - } - return true; -} - diff --git a/sources/shiboken2/tests/test_generator/dummygenerator.h b/sources/shiboken2/tests/test_generator/dummygenerator.h deleted file mode 100644 index e768e7643..000000000 --- a/sources/shiboken2/tests/test_generator/dummygenerator.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of Qt for Python. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef DUMMYGENERATOR_H -#define DUMMYGENERATOR_H - -#include "generator.h" - -class GENRUNNER_API DummyGenerator : public Generator -{ -public: - DummyGenerator() {} - ~DummyGenerator() {} - bool doSetup(const QMap<QString, QString>& args); - const char* name() const { return "DummyGenerator"; } - -protected: - void writeFunctionArguments(QTextStream&, const AbstractMetaFunction*, Options) const {} - void writeArgumentNames(QTextStream&, const AbstractMetaFunction*, Options) const {} - QString fileNameForClass(const AbstractMetaClass* metaClass) const; - void generateClass(QTextStream& s, const AbstractMetaClass* metaClass); - void finishGeneration() {} -}; - -#endif // DUMMYGENERATOR_H diff --git a/sources/shiboken2/tests/test_generator/dummygentest-project.txt.in b/sources/shiboken2/tests/test_generator/dummygentest-project.txt.in deleted file mode 100644 index 0a076d8bd..000000000 --- a/sources/shiboken2/tests/test_generator/dummygentest-project.txt.in +++ /dev/null @@ -1,20 +0,0 @@ -[generator-project] - -generator-set = dummy -header-file = @CMAKE_CURRENT_BINARY_DIR@/test_global.h -typesystem-file = @CMAKE_CURRENT_BINARY_DIR@/test_typesystem.xml -output-directory = /tmp/output - -dump-arguments = @CMAKE_CURRENT_BINARY_DIR@/dummygen-args.log - -include-path = /include/path/location1 -include-path = /include/path/location2 - -typesystem-path = /typesystem/path/location1 -typesystem-path = /typesystem/path/location2 - -api-version = 1.2.3 -debug = sparse - -no-suppress-warnings - diff --git a/sources/shiboken2/tests/test_generator/dummygentest.cpp b/sources/shiboken2/tests/test_generator/dummygentest.cpp deleted file mode 100644 index c09cdfb82..000000000 --- a/sources/shiboken2/tests/test_generator/dummygentest.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of Qt for Python. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "dummygentest.h" -#include "dummygenerator.h" -#include "dummygentestconfig.h" -#include <QTemporaryFile> -#include <QtTest/QTest> -#include <QProcess> - -#define GENERATED_CONTENTS "// Generated code for class: Dummy" - -void DummyGenTest::initTestCase() -{ - int argc = 0; - char* argv[] = {NULL}; - QCoreApplication app(argc, argv); - workDir = QDir::currentPath(); - - headerFilePath = workDir + "/test_global.h"; - typesystemFilePath = workDir + "/test_typesystem.xml"; - projectFilePath = workDir + "/dummygentest-project.txt"; - generatedFilePath = QString("%1/dummy/dummy_generated.txt").arg(QDir::tempPath()); -} - -void DummyGenTest::testCallGenRunnerWithFullPathToDummyGenModule() -{ - QStringList args; - args.append("--generator-set=" DUMMYGENERATOR_BINARY_DIR "/dummy_generator" MODULE_EXTENSION); - args.append(QString("--output-directory=%1").arg(QDir::tempPath())); - args.append(headerFilePath); - args.append(typesystemFilePath); - int result = QProcess::execute("generatorrunner", args); - QCOMPARE(result, 0); - - QFile generatedFile(generatedFilePath); - generatedFile.open(QIODevice::ReadOnly); - QCOMPARE(generatedFile.readAll().trimmed(), QByteArray(GENERATED_CONTENTS).trimmed()); - generatedFile.close(); - - QVERIFY(generatedFile.remove()); -} - -void DummyGenTest::testCallGenRunnerWithNameOfDummyGenModule() -{ - QStringList args; - args.append("--generator-set=dummy"); - args.append(QString("--output-directory=%1").arg(QDir::tempPath())); - args.append(headerFilePath); - args.append(typesystemFilePath); - int result = QProcess::execute("generatorrunner", args); - QCOMPARE(result, 0); - - QFile generatedFile(generatedFilePath); - generatedFile.open(QIODevice::ReadOnly); - QCOMPARE(generatedFile.readAll().trimmed(), QByteArray(GENERATED_CONTENTS).trimmed()); - generatedFile.close(); - - QVERIFY(generatedFile.remove()); -} - -void DummyGenTest::testCallDummyGeneratorExecutable() -{ - QStringList args; - args.append(QString("--output-directory=%1").arg(QDir::tempPath())); - args.append(headerFilePath); - args.append(typesystemFilePath); - int result = QProcess::execute(DUMMYGENERATOR_BINARY, args); - QCOMPARE(result, 0); - - QFile generatedFile(generatedFilePath); - generatedFile.open(QIODevice::ReadOnly); - QCOMPARE(generatedFile.readAll().trimmed(), QByteArray(GENERATED_CONTENTS).trimmed()); - generatedFile.close(); - - QVERIFY(generatedFile.remove()); -} - -void DummyGenTest::testProjectFileArgumentsReading() -{ - QStringList args(QString("--project-file=%1/dummygentest-project.txt").arg(workDir)); - int result = QProcess::execute("generatorrunner", args); - QCOMPARE(result, 0); - - QFile logFile(workDir + "/dummygen-args.log"); - logFile.open(QIODevice::ReadOnly); - QStringList logContents; - while (!logFile.atEnd()) - logContents << logFile.readLine().trimmed(); - logContents.sort(); - QCOMPARE(logContents[0], QString("api-version = 1.2.3")); - QCOMPARE(logContents[1], QString("debug = sparse")); - QVERIFY(logContents[2].startsWith("dump-arguments = ")); - QVERIFY(logContents[2].endsWith("dummygen-args.log")); - QCOMPARE(logContents[3], QString("generator-set = dummy")); - QVERIFY(logContents[4].startsWith("header-file = ")); - QVERIFY(logContents[4].endsWith("test_global.h")); - QCOMPARE(logContents[5], - QDir::toNativeSeparators(QString("include-paths = /include/path/location1%1/include/path/location2").arg(PATH_SPLITTER))); - QCOMPARE(logContents[6], QString("no-suppress-warnings")); - QCOMPARE(logContents[7], QString("output-directory = /tmp/output")); - QVERIFY(logContents[8].startsWith("project-file = ")); - QVERIFY(logContents[8].endsWith("dummygentest-project.txt")); - QVERIFY(logContents[9].startsWith("typesystem-file = ")); - QVERIFY(logContents[9].endsWith("test_typesystem.xml")); - QCOMPARE(logContents[10], - QDir::toNativeSeparators(QString("typesystem-paths = /typesystem/path/location1%1/typesystem/path/location2").arg(PATH_SPLITTER))); -} - -QTEST_APPLESS_MAIN(DummyGenTest) - -#include "dummygentest.moc" - diff --git a/sources/shiboken2/tests/test_generator/dummygentest.h b/sources/shiboken2/tests/test_generator/dummygentest.h deleted file mode 100644 index 78bae1d52..000000000 --- a/sources/shiboken2/tests/test_generator/dummygentest.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of Qt for Python. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DUMMYGENTABLETEST_H -#define DUMMYGENTABLETEST_H - -#include <QObject> - -class DummyGenerator; - -class DummyGenTest : public QObject -{ - Q_OBJECT - -private: - QString workDir; - QString headerFilePath; - QString typesystemFilePath; - QString generatedFilePath; - QString projectFilePath; - -private slots: - void initTestCase(); - void testCallGenRunnerWithFullPathToDummyGenModule(); - void testCallGenRunnerWithNameOfDummyGenModule(); - void testCallDummyGeneratorExecutable(); - void testProjectFileArgumentsReading(); -}; - -#endif - diff --git a/sources/shiboken2/tests/test_generator/dummygentestconfig.h.in b/sources/shiboken2/tests/test_generator/dummygentestconfig.h.in deleted file mode 100644 index 9da17dcd3..000000000 --- a/sources/shiboken2/tests/test_generator/dummygentestconfig.h.in +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef DUMMYGENTESTCONFIG_H -#define DUMMYGENTESTCONFIG_H - -#define MODULE_EXTENSION "@CMAKE_SHARED_LIBRARY_SUFFIX@" -#define DUMMYGENERATOR_BINARY "@DUMMYGENERATOR_EXECUTABLE@" -#define DUMMYGENERATOR_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@" - -#ifdef _WINDOWS - #define PATH_SPLITTER ";" -#else - #define PATH_SPLITTER ":" -#endif - -#endif // DUMMYGENTESTCONFIG_H - diff --git a/sources/shiboken2/tests/test_generator/main.cpp b/sources/shiboken2/tests/test_generator/main.cpp deleted file mode 100644 index f928b4d2c..000000000 --- a/sources/shiboken2/tests/test_generator/main.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of Qt for Python. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtCore> - -int main(int argc, char *argv[]) -{ - QStringList args; - args.append("--generator-set=dummy"); - for (int i = 1; i < argc; i++) - args.append(argv[i]); - return QProcess::execute("generatorrunner", args); -} - diff --git a/sources/shiboken2/tests/test_generator/run_test.cmake b/sources/shiboken2/tests/test_generator/run_test.cmake deleted file mode 100644 index 34a821d80..000000000 --- a/sources/shiboken2/tests/test_generator/run_test.cmake +++ /dev/null @@ -1,11 +0,0 @@ -# The tests are run through this script due to a limitation -# on versions of CMake lesser than 2.8, that prevent setting -# environment variables for tests from working. - -set(ENV{PATH} "${ENV_PATH}") -set(ENV{QT_PLUGIN_PATH} "${ENV_QT_PLUGIN_PATH}") -execute_process(COMMAND ${TEST} WORKING_DIRECTORY "${WORKDIR}" RESULT_VARIABLE OK) - -if(NOT OK EQUAL 0) - message(SEND_ERROR "${TEST} failed!") -endif() diff --git a/sources/shiboken2/tests/test_generator/test_global.h b/sources/shiboken2/tests/test_generator/test_global.h deleted file mode 100644 index 6a95200cf..000000000 --- a/sources/shiboken2/tests/test_generator/test_global.h +++ /dev/null @@ -1 +0,0 @@ -struct Dummy {}; diff --git a/sources/shiboken2/tests/test_generator/test_typesystem.xml b/sources/shiboken2/tests/test_generator/test_typesystem.xml deleted file mode 100644 index c19a4e95e..000000000 --- a/sources/shiboken2/tests/test_generator/test_typesystem.xml +++ /dev/null @@ -1,3 +0,0 @@ -<typesystem package='dummy'> - <value-type name='Dummy'/> -</typesystem> |