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

View File

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

View File

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

View File

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