aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-10-22 12:05:18 +0200
committerLars Knoll <lars.knoll@qt.io>2017-10-22 12:26:28 +0200
commitaceb0d0cd2da89aebbf17729869b9e977290c826 (patch)
treeb29e815e32277710058bc32c571281937183fd43 /tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
parent6ecbe6441f825489b5fafde1a274952933254c7f (diff)
parent1bb9c7b517e7995201d2a31cd1e852c02ad8c1bc (diff)
Merge remote-tracking branch 'origin/dev' into HEAD
Conflicts: src/qml/compiler/qv4codegen.cpp src/qml/compiler/qv4compileddata.cpp src/qml/compiler/qv4compileddata_p.h src/qml/compiler/qv4isel_moth_p.h src/qml/compiler/qv4ssa.cpp src/qml/jit/qv4assembler_p.h src/qml/jit/qv4isel_masm_p.h src/qml/jit/qv4regalloc.cpp src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4qmlcontext_p.h src/qml/jsruntime/qv4regexp.cpp src/qml/jsruntime/qv4regexp_p.h src/qml/jsruntime/qv4regexpobject.cpp src/qml/jsruntime/qv4runtime.cpp src/qml/jsruntime/qv4vme_moth.cpp src/qml/qml/v8/qqmlbuiltinfunctions.cpp tests/auto/qml/qml.pro tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp tools/qmlcachegen/qmlcachegen.cpp Change-Id: I1577e195c736f3414089036b957a01cb91a3ca23
Diffstat (limited to 'tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp')
-rw-r--r--tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
index 1f80ff46d0..7e81df93b9 100644
--- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
+++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
@@ -44,6 +44,7 @@ private slots:
void loadGeneratedFile();
void translationExpressionSupport();
void signalHandlerParameters();
+ void errorOnArgumentsInSignalHandler();
};
// A wrapper around QQmlComponent to ensure the temporary reference counts
@@ -68,15 +69,20 @@ public:
}
};
-static bool generateCache(const QString &qmlFileName)
+static bool generateCache(const QString &qmlFileName, QByteArray *capturedStderr = nullptr)
{
QProcess proc;
- proc.setProcessChannelMode(QProcess::ForwardedChannels);
+ if (capturedStderr == nullptr)
+ proc.setProcessChannelMode(QProcess::ForwardedChannels);
proc.setProgram(QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator() + QLatin1String("qmlcachegen"));
proc.setArguments(QStringList() << (QLatin1String("--target-architecture=") + QSysInfo::buildCpuArchitecture()) << (QLatin1String("--target-abi=") + QSysInfo::buildAbi()) << qmlFileName);
proc.start();
if (!proc.waitForFinished())
return false;
+
+ if (capturedStderr)
+ *capturedStderr = proc.readAllStandardError();
+
if (proc.exitStatus() != QProcess::NormalExit)
return false;
return proc.exitCode() == 0;
@@ -194,6 +200,31 @@ void tst_qmlcachegen::signalHandlerParameters()
QCOMPARE(obj->property("result").toInt(), 42);
}
+void tst_qmlcachegen::errorOnArgumentsInSignalHandler()
+{
+ QTemporaryDir tempDir;
+ QVERIFY(tempDir.isValid());
+
+ const auto writeTempFile = [&tempDir](const QString &fileName, const char *contents) {
+ QFile f(tempDir.path() + '/' + fileName);
+ const bool ok = f.open(QIODevice::WriteOnly | QIODevice::Truncate);
+ Q_ASSERT(ok);
+ f.write(contents);
+ return f.fileName();
+ };
+
+ const QString testFilePath = writeTempFile("test.qml", "import QtQml 2.2\n"
+ "QtObject {\n"
+ " signal mySignal(var arguments);\n"
+ " onMySignal: console.log(arguments);\n"
+ "}");
+
+
+ QByteArray errorOutput;
+ QVERIFY(!generateCache(testFilePath, &errorOutput));
+ QVERIFY2(errorOutput.contains("error: The use of the arguments object in signal handlers is"), errorOutput);
+}
+
QTEST_GUILESS_MAIN(tst_qmlcachegen)
#include "tst_qmlcachegen.moc"