summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/auto.pro2
-rw-r--r--tests/auto/qscxmlc/data/empty.scxml1
-rw-r--r--tests/auto/qscxmlc/qscxmlc.pro24
-rw-r--r--tests/auto/qscxmlc/tst_qscxmlc.cpp65
-rw-r--r--tests/auto/qscxmlc/tst_qscxmlc.qrc5
-rw-r--r--tools/qscxmlc/qscxmlc.cpp30
6 files changed, 111 insertions, 16 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index b4876f0..2c2bcce 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,2 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS = cmake parser scion statemachine
+SUBDIRS = cmake parser scion statemachine qscxmlc
diff --git a/tests/auto/qscxmlc/data/empty.scxml b/tests/auto/qscxmlc/data/empty.scxml
new file mode 100644
index 0000000..10c563b
--- /dev/null
+++ b/tests/auto/qscxmlc/data/empty.scxml
@@ -0,0 +1 @@
+<scxml></scxml>
diff --git a/tests/auto/qscxmlc/qscxmlc.pro b/tests/auto/qscxmlc/qscxmlc.pro
new file mode 100644
index 0000000..285ed87
--- /dev/null
+++ b/tests/auto/qscxmlc/qscxmlc.pro
@@ -0,0 +1,24 @@
+QT = core testlib scxml-private
+CONFIG += testcase console c++11
+CONFIG -= app_bundle
+
+TARGET = tst_qscxmlc
+TEMPLATE = app
+
+RESOURCES += tst_qscxmlc.qrc
+
+SOURCES += \
+ $$PWD/tst_qscxmlc.cpp \
+ $$PWD/../../../tools/qscxmlc/generator.cpp \
+ $$PWD/../../../tools/qscxmlc/scxmlcppdumper.cpp
+
+HEADERS += \
+ $$PWD/../../../tools/qscxmlc/qscxmlc.cpp \ # yes, that's a header. We want to #define scxmlcmain main
+ $$PWD/../../../tools/qscxmlc/moc.h \
+ $$PWD/../../../tools/qscxmlc/generator.h \
+ $$PWD/../../../tools/qscxmlc/outputrevision.h \
+ $$PWD/../../../tools/qscxmlc/utils.h \
+ $$PWD/../../../tools/qscxmlc/scxmlcppdumper.h
+
+INCLUDEPATH += ../../../tools/qscxmlc/
+
diff --git a/tests/auto/qscxmlc/tst_qscxmlc.cpp b/tests/auto/qscxmlc/tst_qscxmlc.cpp
new file mode 100644
index 0000000..a529144
--- /dev/null
+++ b/tests/auto/qscxmlc/tst_qscxmlc.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtScxml module of the Qt Toolkit.
+**
+** $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 <QtTest>
+#include <QObject>
+#include <QCoreApplication>
+
+#define main qscxmlcmain
+#include "qscxmlc.cpp"
+#undef main
+
+class tst_Qscxmlc: public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void parsing_data();
+ void parsing();
+};
+
+void tst_Qscxmlc::parsing_data()
+{
+ QTest::addColumn<QString>("scxmlFileName");
+ QDir dir(QLatin1String(":/tst_qscxmlc/data/"));
+ foreach (const QString &entry, dir.entryList()) {
+ QTest::newRow(entry.toLatin1().constData()) << dir.filePath(entry);
+ }
+}
+
+void tst_Qscxmlc::parsing()
+{
+ QFETCH(QString, scxmlFileName);
+ QVERIFY(run(QStringList() << QLatin1String("qcsxmlc") << scxmlFileName));
+}
+
+QTEST_MAIN(tst_Qscxmlc)
+
+#include "tst_qscxmlc.moc"
+
+
diff --git a/tests/auto/qscxmlc/tst_qscxmlc.qrc b/tests/auto/qscxmlc/tst_qscxmlc.qrc
new file mode 100644
index 0000000..df21b44
--- /dev/null
+++ b/tests/auto/qscxmlc/tst_qscxmlc.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/tst_qscxmlc">
+ <file>data/empty.scxml</file>
+ </qresource>
+</RCC>
diff --git a/tools/qscxmlc/qscxmlc.cpp b/tools/qscxmlc/qscxmlc.cpp
index 82eb8df..1bee7cf 100644
--- a/tools/qscxmlc/qscxmlc.cpp
+++ b/tools/qscxmlc/qscxmlc.cpp
@@ -53,13 +53,13 @@ int write(TranslationUnit *tu)
QFile outH(tu->outHFileName);
if (!outH.open(QFile::WriteOnly)) {
errs << QStringLiteral("Error: cannot open '%1': %2").arg(outH.fileName(), outH.errorString()) << endl;
- exit(CannotOpenOutputHeaderFileError);
+ return CannotOpenOutputHeaderFileError;
}
QFile outCpp(tu->outCppFileName);
if (!outCpp.open(QFile::WriteOnly)) {
errs << QStringLiteral("Error: cannot open '%1': %2").arg(outCpp.fileName(), outCpp.errorString()) << endl;
- exit(CannotOpenOutputCppFileError);
+ return CannotOpenOutputCppFileError;
}
QTextStream h(&outH);
@@ -79,17 +79,10 @@ static void collectAllDocuments(DocumentModel::ScxmlDocument *doc, QMap<Document
}
}
-
-int main(int argc, char *argv[])
+int run(QStringList arguments)
{
- QCoreApplication a(argc, argv);
- a.setApplicationVersion(QString::fromLatin1("%1 (Qt %2)").arg(
- QString::number(Q_QSCXMLC_OUTPUT_REVISION),
- QString::fromLatin1(QT_VERSION_STR)));
-
- QTextStream errs(stderr, QIODevice::WriteOnly);
-
QCommandLineParser cmdParser;
+ QTextStream errs(stderr, QIODevice::WriteOnly);
cmdParser.addHelpOption();
cmdParser.addVersionOption();
@@ -131,7 +124,7 @@ int main(int argc, char *argv[])
cmdParser.addOption(optionClassName);
cmdParser.addOption(optionQtMode);
- cmdParser.process(a);
+ cmdParser.process(arguments);
const QStringList inputFiles = cmdParser.positionalArguments();
@@ -182,7 +175,7 @@ int main(int argc, char *argv[])
QFile file(scxmlFileName);
if (!file.open(QFile::ReadOnly)) {
errs << QStringLiteral("Error: cannot open input file %1").arg(scxmlFileName);
- exit(CannotOpenInputFileError);
+ return CannotOpenInputFileError;
}
QXmlStreamReader reader(&file);
@@ -231,7 +224,14 @@ int main(int argc, char *argv[])
tu.classnameForDocument.insert(i.key(), name);
}
- int err = write(&tu);
+ return write(&tu);
+}
- return err;
+int main(int argc, char *argv[])
+{
+ QCoreApplication a(argc, argv);
+ a.setApplicationVersion(QString::fromLatin1("%1 (Qt %2)").arg(
+ QString::number(Q_QSCXMLC_OUTPUT_REVISION),
+ QString::fromLatin1(QT_VERSION_STR)));
+ return run(QCoreApplication::arguments());
}