Fix unit tests

side-tag: c9s-build-side-453

Resolves: bz#2061370
This commit is contained in:
Jan Grulich 2022-04-20 11:45:57 +02:00
parent 93c5f6b838
commit ee1f5ea227
2 changed files with 235 additions and 11 deletions

View File

@ -12,7 +12,7 @@
Summary: Qt5 - QtTool components
Name: qt5-qttools
Version: 5.15.3
Release: 1%{?dist}
Release: 2%{?dist}
License: LGPLv3 or LGPLv2
Url: http://www.qt.io
@ -30,6 +30,10 @@ Patch4: qttools-opensource-src-5.7-add-libatomic.patch
# https://fedoraproject.org/wiki/Changes/Stop-Shipping-Individual-Component-Libraries-In-clang-lib-Package
Patch5: 0001-Link-against-libclang-cpp.so-instead-of-the-clang-co.patch
%if 0%{?build_tests}
Patch100: qttools-fix-data-files-path-for-tests.patch
%endif
## upstream patches
Source20: assistant.desktop
@ -188,6 +192,9 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
%endif
%patch5 -p1 -b .libclang-cpp
%if 0%{?build_tests}
%patch100 -p1 -b .fix-data-files-path-for-tests
%endif
%build
%{qmake_qt5} \
@ -196,9 +203,16 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
%make_build
%if 0%{?build_tests}
# FIXME: qttools is special case and we cannot use qt5_build_tests macro as this
# skips many files used by qttools unit tests
#qt5_build_tests
%qt5_build_tests
%endif
%install
make install INSTALL_ROOT=%{buildroot}
%if 0%{?build_tests}
# FIXME: qttools is special case and we cannot use qt5_install_tests macro as
# it skips many data files used by qttools unit tests
#qt5_install_tests
mkdir -p %{buildroot}%{_qt5_libdir}/qt5
find ./tests -not -path '*/\.*' -type d | while read LINE
do
@ -210,13 +224,6 @@ do
done
%endif
%install
make install INSTALL_ROOT=%{buildroot}
%if 0%{?build_tests}
%qt5_install_tests
%endif
# Add desktop files, --vendor=... helps avoid possible conflicts with qt3/qt4
desktop-file-install \
--dir=%{buildroot}%{_datadir}/applications \
@ -512,6 +519,10 @@ fi
%endif
%changelog
* Wed Apr 20 2022 Jan Grulich <jgrulich@redhat.com> - 5.15.3-2
- Fix unit tests used by gating
Resolves: bz#2061370
* Mon Mar 28 2022 Jan Grulich <jgrulich@redhat.com> - 5.15.3-1
- 5.15.3
Resolves: bz#2061370

View File

@ -0,0 +1,213 @@
diff --git a/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.cpp b/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.cpp
index 039ea2f..514578a 100644
--- a/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.cpp
+++ b/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.cpp
@@ -84,12 +84,12 @@ private:
void tst_QHelpContentModel::init()
{
// defined in profile
- QString path = QLatin1String(SRCDIR);
+ QString path = QFINDTESTDATA("data/");
- m_colFile = path + QLatin1String("/data/col.qhc");
+ m_colFile = path + QLatin1String("col.qhc");
if (QFile::exists(m_colFile))
QDir::current().remove(m_colFile);
- if (!QFile::copy(path + "/data/collection.qhc", m_colFile))
+ if (!QFile::copy(path + "collection.qhc", m_colFile))
QFAIL("Cannot copy file!");
QFile f(m_colFile);
f.setPermissions(QFile::WriteUser|QFile::ReadUser);
diff --git a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp
index ba2b153..7f42a8e 100644
--- a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp
+++ b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp
@@ -81,14 +81,14 @@ private:
void tst_QHelpEngineCore::init()
{
// defined in profile
- m_path = QLatin1String(SRCDIR);
+ m_path = QFINDTESTDATA("data/");
m_path = QFileInfo(m_path).absoluteFilePath();
- m_colFile = m_path + QLatin1String("/data/col.qhc");
+ m_colFile = m_path + QLatin1String("col.qhc");
if (QFile::exists(m_colFile))
QDir::current().remove(m_colFile);
- if (!QFile::copy(m_path + "/data/collection.qhc", m_colFile))
+ if (!QFile::copy(m_path + "collection.qhc", m_colFile))
QFAIL("Cannot copy file!");
QFile f(m_colFile);
f.setPermissions(QFile::WriteUser|QFile::ReadUser);
@@ -111,7 +111,7 @@ void tst_QHelpEngineCore::setCollectionFile()
QHelpEngineCore help(m_colFile, 0);
QCOMPARE(help.collectionFile(), QFileInfo(m_colFile).absoluteFilePath());
- QString col1File = m_path + QLatin1String("/data/collection1.qhc");
+ QString col1File = m_path + QLatin1String("collection1.qhc");
help.setCollectionFile(col1File);
QCOMPARE(help.collectionFile(), QFileInfo(col1File).absoluteFilePath());
@@ -125,7 +125,7 @@ void tst_QHelpEngineCore::copyCollectionFile()
QHelpEngineCore help(m_colFile, 0);
QCOMPARE(help.collectionFile(), QFileInfo(m_colFile).absoluteFilePath());
- QString copiedFile = m_path + QLatin1String("/collectionCopy.qhc");
+ QString copiedFile = m_path + QLatin1String("collectionCopy.qhc");
if (QFile::exists(copiedFile))
QDir::current().remove(copiedFile);
@@ -165,7 +165,7 @@ void tst_QHelpEngineCore::copyCollectionFile()
while (m_query->next()) {
if (i == 0) {
QCOMPARE(m_query->value(0).toString(), QString("trolltech.com.3-3-8.qmake"));
- QCOMPARE(m_query->value(1).toString(), QString("data/qmake-3.3.8.qch"));
+ QCOMPARE(m_query->value(1).toString(), QString("qmake-3.3.8.qch"));
}
++i;
}
@@ -179,9 +179,9 @@ void tst_QHelpEngineCore::copyCollectionFile()
void tst_QHelpEngineCore::namespaceName()
{
- QCOMPARE(QHelpEngineCore::namespaceName(m_path + "/data/qmake-3.3.8.qch"),
+ QCOMPARE(QHelpEngineCore::namespaceName(m_path + "qmake-3.3.8.qch"),
QString("trolltech.com.3-3-8.qmake"));
- QCOMPARE(QHelpEngineCore::namespaceName(m_path + "/data/linguist-3.3.8.qch"),
+ QCOMPARE(QHelpEngineCore::namespaceName(m_path + "linguist-3.3.8.qch"),
QString("trolltech.com.3-3-8.linguist"));
}
@@ -206,11 +206,11 @@ void tst_QHelpEngineCore::registerDocumentation()
{
QHelpEngineCore c(m_colFile);
QCOMPARE(c.setupData(), true);
- c.registerDocumentation(m_path + "/data/qmake-3.3.8.qch");
+ c.registerDocumentation(m_path + "qmake-3.3.8.qch");
QCOMPARE(c.registeredDocumentations().count(), 1);
- c.registerDocumentation(m_path + "/data/qmake-3.3.8.qch");
+ c.registerDocumentation(m_path + "qmake-3.3.8.qch");
QCOMPARE(c.registeredDocumentations().count(), 1);
- c.registerDocumentation(m_path + "/data/linguist-3.3.8.qch");
+ c.registerDocumentation(m_path + "linguist-3.3.8.qch");
QCOMPARE(c.registeredDocumentations().count(), 2);
}
@@ -248,9 +248,9 @@ void tst_QHelpEngineCore::documentationFileName()
QHelpEngineCore c(m_colFile);
QCOMPARE(c.setupData(), true);
QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.3-3-8.qmake")),
- QString(m_path + "/data/qmake-3.3.8.qch"));
+ QString(m_path + "qmake-3.3.8.qch"));
QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.1.0.0.test")),
- QString(m_path + "/data/test.qch"));
+ QString(m_path + "test.qch"));
QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.empty")),
QString());
}
@@ -367,7 +367,7 @@ void tst_QHelpEngineCore::fileData()
QCOMPARE(ba.size(), 0);
ba = help.fileData(QUrl("qthelp://trolltech.com.1.0.0.test/testFolder/test.html"));
QTextStream s(ba, QIODevice::ReadOnly|QIODevice::Text);
- QFile f(m_path + "/data/test.html");
+ QFile f(m_path + "test.html");
if (!f.open(QIODevice::ReadOnly|QIODevice::Text))
QFAIL("Cannot open original file!");
QTextStream ts(&f);
@@ -433,9 +433,9 @@ void tst_QHelpEngineCore::setAutoSaveFilter()
void tst_QHelpEngineCore::metaData()
{
- QCOMPARE(QHelpEngineCore::metaData(m_path + "/data/test.qch", "author").toString(),
+ QCOMPARE(QHelpEngineCore::metaData(m_path + "test.qch", "author").toString(),
QString("Digia Plc and/or its subsidiary(-ies)"));
- QCOMPARE(QHelpEngineCore::metaData(m_path + "/data/test.qch", "notExisting").isValid(),
+ QCOMPARE(QHelpEngineCore::metaData(m_path + "test.qch", "notExisting").isValid(),
false);
}
diff --git a/tests/auto/qhelpgenerator/tst_qhelpgenerator.cpp b/tests/auto/qhelpgenerator/tst_qhelpgenerator.cpp
index 47a879d..99f4615 100644
--- a/tests/auto/qhelpgenerator/tst_qhelpgenerator.cpp
+++ b/tests/auto/qhelpgenerator/tst_qhelpgenerator.cpp
@@ -57,8 +57,8 @@ private:
void tst_QHelpGenerator::initTestCase()
{
- QString path = QLatin1String(SRCDIR);
- m_outputFile = path + QLatin1String("/data/test.qch");
+ QString path = QFINDTESTDATA("data/");
+ m_outputFile = path + QLatin1String("test.qch");
if (QFile::exists(m_outputFile)) {
QDir d;
if (!d.remove(m_outputFile))
@@ -69,9 +69,9 @@ void tst_QHelpGenerator::initTestCase()
void tst_QHelpGenerator::generateHelp()
{
// defined in profile
- QString path = QLatin1String(SRCDIR);
+ QString path = QFINDTESTDATA("data/");
- QString inputFile(path + "/data/test.qhp");
+ QString inputFile(path + "test.qhp");
QHelpProjectData data;
if (!data.readData(inputFile))
QFAIL("Cannot read qthp file!");
@@ -194,17 +194,17 @@ void tst_QHelpGenerator::checkMetaData()
void tst_QHelpGenerator::generateTwice()
{
// defined in profile
- QString path = QLatin1String(SRCDIR);
+ QString path = QFINDTESTDATA("data/");
- QString inputFile(path + "/data/test.qhp");
+ QString inputFile(path + "test.qhp");
QHelpProjectData data;
if (!data.readData(inputFile))
QFAIL("Cannot read qhp file!");
HelpGenerator generator1;
HelpGenerator generator2;
- QString outputFile1 = path + QLatin1String("/data/test1.qch");
- QString outputFile2 = path + QLatin1String("/data/test2.qch");
+ QString outputFile1 = path + QLatin1String("test1.qch");
+ QString outputFile2 = path + QLatin1String("test2.qch");
QCOMPARE(generator1.generate(&data, outputFile1), true);
QCOMPARE(generator2.generate(&data, outputFile2), true);
diff --git a/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp b/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp
index 713c229..65ee62f 100644
--- a/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp
+++ b/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp
@@ -84,12 +84,12 @@ private:
void tst_QHelpIndexModel::init()
{
- QString path = QLatin1String(SRCDIR);
+ QString path = QFINDTESTDATA("data/");
- m_colFile = path + QLatin1String("/data/col.qhc");
+ m_colFile = path + QLatin1String("col.qhc");
if (QFile::exists(m_colFile))
QDir::current().remove(m_colFile);
- if (!QFile::copy(path + "/data/collection.qhc", m_colFile))
+ if (!QFile::copy(path + "collection.qhc", m_colFile))
QFAIL("Cannot copy file!");
QFile f(m_colFile);
f.setPermissions(QFile::WriteUser|QFile::ReadUser);
diff --git a/tests/auto/qhelpprojectdata/tst_qhelpprojectdata.cpp b/tests/auto/qhelpprojectdata/tst_qhelpprojectdata.cpp
index a09135d..d59a3fc 100644
--- a/tests/auto/qhelpprojectdata/tst_qhelpprojectdata.cpp
+++ b/tests/auto/qhelpprojectdata/tst_qhelpprojectdata.cpp
@@ -52,8 +52,8 @@ private:
void tst_QHelpProjectData::initTestCase()
{
- const QString path = QLatin1String(SRCDIR);
- m_inputFile = path + QLatin1String("/data/test.qhp");
+ const QString path = QFINDTESTDATA("data/");
+ m_inputFile = path + QLatin1String("test.qhp");
}
void tst_QHelpProjectData::readData()