Fix issues with Meson tests

- set temporary directory for launcher
- check for finding meson tool instead of crashing
- use GUILESS_MAIN since it doesn't use gui

Change-Id: I3f8de658d9ccbec3efb260cf2d58e27720e78d47
Reviewed-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Eike Ziller
2022-01-12 10:40:16 +01:00
parent d4b2f18c5e
commit 9091761996
4 changed files with 16 additions and 6 deletions

View File

@@ -28,6 +28,7 @@
#include <utils/launcherinterface.h>
#include <utils/singleton.h>
#include <utils/temporarydirectory.h>
#include <QCoreApplication>
#include <QDir>
@@ -56,7 +57,9 @@ static const QList<projectData> projectList{
#define WITH_CONFIGURED_PROJECT(_source_dir, _build_dir, ...) \
{ \
QTemporaryDir _build_dir{"test-meson"}; \
const auto _meson = MesonWrapper("name", *MesonWrapper::find()); \
const auto tool = MesonWrapper::find(); \
QVERIFY(tool.has_value()); \
const auto _meson = MesonWrapper("name", *tool); \
run_meson(_meson.setup(Utils::FilePath::fromString(_source_dir), \
Utils::FilePath::fromString(_build_dir.path()))); \
QVERIFY(isSetup(Utils::FilePath::fromString(_build_dir.path()))); \
@@ -67,7 +70,9 @@ static const QList<projectData> projectList{
{ \
QTemporaryFile _intro_file; \
_intro_file.open(); \
const auto _meson = MesonWrapper("name", *MesonWrapper::find()); \
const auto tool = MesonWrapper::find(); \
QVERIFY(tool.has_value()); \
const auto _meson = MesonWrapper("name", *tool); \
run_meson(_meson.introspect(Utils::FilePath::fromString(_source_dir)), &_intro_file); \
__VA_ARGS__ \
}
@@ -79,6 +84,8 @@ class AMesonInfoParser : public QObject
private slots:
void initTestCase()
{
Utils::TemporaryDirectory::setMasterTemporaryDirectory(QDir::tempPath()
+ "/mesontest-XXXXXX");
Utils::LauncherInterface::setPathToLauncher(qApp->applicationDirPath() + '/'
+ QLatin1String(TEST_RELATIVE_LIBEXEC_PATH));
}
@@ -126,5 +133,5 @@ private slots:
private:
};
QTEST_MAIN(AMesonInfoParser)
QTEST_GUILESS_MAIN(AMesonInfoParser)
#include "testmesoninfoparser.moc"

View File

@@ -296,6 +296,6 @@ private slots:
void cleanupTestCase() {}
};
QTEST_MAIN(AMesonOutputParser)
QTEST_GUILESS_MAIN(AMesonOutputParser)
#include "testmesonparser.moc"

View File

@@ -27,6 +27,7 @@
#include <utils/launcherinterface.h>
#include <utils/singleton.h>
#include <utils/temporarydirectory.h>
#include <QCoreApplication>
#include <QDir>
@@ -50,6 +51,8 @@ class AMesonWrapper : public QObject
private slots:
void initTestCase()
{
Utils::TemporaryDirectory::setMasterTemporaryDirectory(QDir::tempPath()
+ "/mesontest-XXXXXX");
Utils::LauncherInterface::setPathToLauncher(qApp->applicationDirPath() + '/'
+ QLatin1String(TEST_RELATIVE_LIBEXEC_PATH));
}
@@ -120,5 +123,5 @@ private slots:
private:
};
QTEST_MAIN(AMesonWrapper)
QTEST_GUILESS_MAIN(AMesonWrapper)
#include "testmesonwrapper.moc"

View File

@@ -108,5 +108,5 @@ private slots:
void cleanupTestCase() {}
};
QTEST_MAIN(ANinjaParser)
QTEST_GUILESS_MAIN(ANinjaParser)
#include "testninjaparser.moc"