Skip to content

Commit

Permalink
test/cli/runtests.sh: added support for Qt6 package config
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Dec 17, 2024
1 parent 514ea89 commit 075f156
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
12 changes: 10 additions & 2 deletions test/cfg/qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <QStack>
#include <QByteArray>
#include <QList>
#include <QLinkedList>
#include <QMap>
#include <QMultiMap>
#include <QQueue>
Expand All @@ -34,6 +33,11 @@
#include <QRegion>
#include <QTransform>

// TODO: this is actually avilable via Core5Compat but I could not get it to work with pkg-config
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QLinkedList>
#endif

#include <cstdio>

int ignoredReturnValue_QSize_height(const QSize &s)
Expand Down Expand Up @@ -323,6 +327,7 @@ QList<int>::iterator QList3()
return it;
}

#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void QLinkedList1()
{
// cppcheck-suppress unreadVariable
Expand Down Expand Up @@ -359,6 +364,7 @@ QLinkedList<int>::iterator QLinkedList3()
// cppcheck-suppress returnDanglingLifetime
return it;
}
#endif

void QStringList1(QStringList stringlistArg)
{
Expand Down Expand Up @@ -569,11 +575,13 @@ void MacroTest2_test()
QByteArray ba = str.toLatin1();
printf(ba.data());

#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#ifndef QT_NO_DEPRECATED
str = MacroTest2::trUtf8("test2");
ba = str.toLatin1();
printf(ba.data());
#endif
#endif
}

void MacroTest3()
Expand Down Expand Up @@ -617,7 +625,7 @@ void validCode(int * pIntPtr, QString & qstrArg, double d)
if (qstr1.length() == 1) {}
}
if (qstr1.length() == 1) {} else {
qstr1.remove(1);
qstr1.remove(1, 0);
if (qstr1.length() == 1) {}
}
}
Expand Down
13 changes: 10 additions & 3 deletions test/cfg/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,17 @@ function gnu_fn {
# qt.cpp
function qt_fn {
if [ $HAS_PKG_CONFIG -eq 1 ]; then
QTCONFIG=$(get_pkg_config_cflags Qt5Core Qt5Test Qt5Gui)
# TODO: check syntax with Qt5 and Qt6?
QTCONFIG=$(get_pkg_config_cflags Qt6Core Qt6Test Qt6Gui)
if [ -z "$QTCONFIG" ]; then
QTCONFIG=$(get_pkg_config_cflags Qt5Core Qt5Test Qt5Gui)
QTBUILDCONFIG=$(pkg-config --variable=qt_config Qt5Core Qt5Test Qt5Gui)
[[ $QTBUILDCONFIG =~ (^|[[:space:]])reduce_relocations($|[[:space:]]) ]] && QTCONFIG="${QTCONFIG} -fPIC"
else
QTBUILDCONFIG=$(pkg-config --variable=qt_config Qt6Core Qt6Test Qt6Gui)
QTCONFIG="${QTCONFIG} -fPIC"
fi
if [ -n "$QTCONFIG" ]; then
QTBUILDCONFIG=$(pkg-config --variable=qt_config Qt5Core Qt5Test Qt5Gui)
[[ $QTBUILDCONFIG =~ (^|[[:space:]])reduce_relocations($|[[:space:]]) ]] && QTCONFIG="${QTCONFIG} -fPIC"
# TODO: get rid of the error enabling/disabling?
set +e
echo -e "#include <QString>" | ${CXX} "${CXX_OPT[@]}" ${QTCONFIG} -x c++ -
Expand Down

0 comments on commit 075f156

Please sign in to comment.