aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmljsscope
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2024-03-23 20:41:57 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2024-04-04 09:43:49 +0100
commit082634268a4bd23ff08b9a58d4537eaf800b7b84 (patch)
treea135b81a516b0b5f71f1fa87a45548cc1e196cca /tests/auto/qml/qqmljsscope
parentcd5d2ec701be8de32e83ee778d161de17f1400b4 (diff)
Tests: check that QFile::open succeeds
Wrap it in QVERIFY if possible. If not possible (e.g. a function that returns non-void, or not an autotest function) use qFatal to abort the test. Change-Id: Ie255024d29507e928a94e67d9af1cd436df4f1df Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmljsscope')
-rw-r--r--tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp b/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp
index 4acf27b173..60c0da78de 100644
--- a/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp
+++ b/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp
@@ -35,9 +35,9 @@ class tst_qqmljsscope : public QQmlDataTest
{
const QFileInfo fi(url);
QFile f(fi.absoluteFilePath());
- f.open(QIODevice::ReadOnly);
- QByteArray data(fi.size(), Qt::Uninitialized);
- f.read(data.data(), data.size());
+ if (!f.open(QIODevice::ReadOnly))
+ qFatal("Could not open file %s", qPrintable(url));
+ QByteArray data = f.readAll();
return QString::fromUtf8(data);
}