tst_QXmlStream::tokenErrorHandling() - register test directory in CMake

Register the directory tokenError in the build system to expose it to
embedded devices / for cross compiling.
Do not fail the test function, when a test file isn't found. The tested
functionality is platform independent and will be tested on other
platforms.

Task-number: QTBUG-92113
Task-number: QTBUG-95188
Change-Id: I885d8fdfbbf8ec60e6326bfd871fa85a4390247d
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
(cherry picked from commit b476570932dcfc1b32e8405bcdd219c2dcc421f7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Axel Spoerl 2023-07-11 13:51:44 +02:00 committed by Qt Cherry-pick Bot
parent 477ecafaee
commit 4f89eb5a7a
2 changed files with 10 additions and 3 deletions

View File

@ -10,11 +10,17 @@ file(GLOB_RECURSE test_data
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
data/* XML-Test-Suite/*)
file(GLOB_RECURSE tokenError
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
tokenError/* XML-token-error/*)
qt_internal_add_test(tst_qxmlstream
SOURCES
tst_qxmlstream.cpp
LIBRARIES
Qt::Network
Qt::CorePrivate
TESTDATA ${test_data}
TESTDATA
${test_data}
${tokenError}
)

View File

@ -1892,9 +1892,10 @@ void tst_QXmlStream::tokenErrorHandling() const
const QDir dir(QFINDTESTDATA("tokenError"));
QFile file(dir.absoluteFilePath(fileName));
// Cross-compiling: File will be on host only
// Cross-compiling: Files may not be found when running test standalone
// QSKIP in that case, because the tested functionality is platform independent.
if (!file.exists())
QSKIP("Testfile not found.");
QSKIP(QObject::tr("Testfile %1 not found.").arg(fileName).toUtf8().constData());
file.open(QIODevice::ReadOnly);
QXmlStreamReader reader(&file);