Meson: Fix autotests

Change-Id: I5f690efe9db19ef8ae6f86ed5556b4939bb52a05
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Christian Kandeler
2021-09-16 10:45:45 +02:00
parent d5ebefd0df
commit de8c90e9d9
5 changed files with 54 additions and 14 deletions

View File

@@ -17,9 +17,14 @@ QtcProduct {
project.buildDirectory + '/' + qtc.ide_library_path, project.buildDirectory + '/' + qtc.ide_library_path,
project.buildDirectory + '/' + qtc.ide_plugin_path project.buildDirectory + '/' + qtc.ide_plugin_path
] ]
cpp.defines: base.filter(function(d) { cpp.defines: {
return d !== "QT_RESTRICTED_CAST_FROM_ASCII"; var defines = base.filter(function(d) { return d !== "QT_RESTRICTED_CAST_FROM_ASCII"; });
}) var absLibExecPath = FileInfo.joinPaths(qbs.installRoot, qbs.installPrefix,
qtc.ide_libexec_path);
var relLibExecPath = FileInfo.relativePath(destinationDirectory, absLibExecPath);
defines.push('TEST_RELATIVE_LIBEXEC_PATH="' + relLibExecPath + '"');
return defines;
}
Group { Group {
fileTagsFilter: product.type fileTagsFilter: product.type

View File

@@ -86,6 +86,9 @@ add_qtc_plugin(MesonProjectManager
resources.qrc resources.qrc
) )
file(RELATIVE_PATH RELATIVE_TEST_PATH "${PROJECT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
file(RELATIVE_PATH TEST_RELATIVE_LIBEXEC_PATH "/${RELATIVE_TEST_PATH}" "/${IDE_LIBEXEC_PATH}")
if(WITH_TESTS) if(WITH_TESTS)
add_qtc_test(tst_mesonwrapper add_qtc_test(tst_mesonwrapper
INCLUDES INCLUDES
@@ -96,6 +99,7 @@ add_qtc_test(tst_mesonwrapper
DEFINES DEFINES
MESON_SAMPLES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/tests/resources" MESON_SAMPLES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/tests/resources"
MESON_SAMPLES_BUILD_DIR="${CMAKE_CURRENT_BINARY_DIR}" MESON_SAMPLES_BUILD_DIR="${CMAKE_CURRENT_BINARY_DIR}"
TEST_RELATIVE_LIBEXEC_PATH="${TEST_RELATIVE_LIBEXEC_PATH}"
SOURCES SOURCES
tests/testmesonwrapper.cpp tests/testmesonwrapper.cpp
exewrappers/mesonwrapper.cpp exewrappers/mesonwrapper.cpp
@@ -115,6 +119,7 @@ add_qtc_test(tst_mesoninfoparser
DEFINES DEFINES
MESON_SAMPLES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/tests/resources" MESON_SAMPLES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/tests/resources"
MESON_SAMPLES_BUILD_DIR="${CMAKE_CURRENT_BINARY_DIR}" MESON_SAMPLES_BUILD_DIR="${CMAKE_CURRENT_BINARY_DIR}"
TEST_RELATIVE_LIBEXEC_PATH="${TEST_RELATIVE_LIBEXEC_PATH}"
SOURCES SOURCES
tests/testmesoninfoparser.cpp tests/testmesoninfoparser.cpp
exewrappers/mesonwrapper.cpp exewrappers/mesonwrapper.cpp

View File

@@ -110,13 +110,13 @@ Project {
} }
QtcAutotest { QtcAutotest {
name: "tst_mesonwrapper" name: "mesonwrapper"
condition: project.withAutotests condition: project.withAutotests
Depends { name: "Core" } Depends { name: "Core" }
Depends { name: "Utils" } Depends { name: "Utils" }
cpp.defines: project.testDefines cpp.defines: base.concat(project.testDefines)
cpp.includePaths: "." cpp.includePaths: "."
files: [ files: [
@@ -131,13 +131,13 @@ Project {
} }
QtcAutotest { QtcAutotest {
name: "tst_mesoninfoparser" name: "mesoninfoparser"
condition: project.withAutotests condition: project.withAutotests
Depends { name: "Core" } Depends { name: "Core" }
Depends { name: "Utils" } Depends { name: "Utils" }
cpp.defines: project.testDefines cpp.defines: base.concat(project.testDefines)
cpp.includePaths: "." cpp.includePaths: "."
files: [ files: [
@@ -153,7 +153,7 @@ Project {
} }
QtcAutotest { QtcAutotest {
name: "tst_ninjaparser" name: "ninjaparser"
condition: project.withAutotests condition: project.withAutotests
Depends { name: "Core" } Depends { name: "Core" }
@@ -171,14 +171,14 @@ Project {
} }
QtcAutotest { QtcAutotest {
name: "tst_mesonparser" name: "mesonparser"
condition: project.withAutotests condition: project.withAutotests
Depends { name: "Core" } Depends { name: "Core" }
Depends { name: "ProjectExplorer" } Depends { name: "ProjectExplorer" }
Depends { name: "Utils" } Depends { name: "Utils" }
cpp.defines: "MESONPARSER_DISABLE_TASKS_FOR_TESTS" cpp.defines: base.concat("MESONPARSER_DISABLE_TASKS_FOR_TESTS")
cpp.includePaths: "." cpp.includePaths: "."
files: [ files: [

View File

@@ -26,6 +26,10 @@
#include "exewrappers/mesonwrapper.h" #include "exewrappers/mesonwrapper.h"
#include "mesoninfoparser/mesoninfoparser.h" #include "mesoninfoparser/mesoninfoparser.h"
#include <utils/launcherinterface.h>
#include <utils/processreaper.h>
#include <QCoreApplication>
#include <QDir> #include <QDir>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
@@ -73,7 +77,12 @@ class AMesonInfoParser : public QObject
Q_OBJECT Q_OBJECT
private slots: private slots:
void initTestCase() {} void initTestCase()
{
Utils::LauncherInterface::startLauncher(
QCoreApplication::instance()->applicationDirPath() + '/'
+ QLatin1String(TEST_RELATIVE_LIBEXEC_PATH));
}
void shouldListTargets_data() void shouldListTargets_data()
{ {
@@ -110,7 +119,13 @@ private slots:
}) })
} }
void cleanupTestCase() {} void cleanupTestCase()
{
Utils::LauncherInterface::stopLauncher();
}
private:
Utils::ProcessReaper processReaper;
}; };
QTEST_MAIN(AMesonInfoParser) QTEST_MAIN(AMesonInfoParser)

View File

@@ -25,6 +25,10 @@
#include "exewrappers/mesonwrapper.h" #include "exewrappers/mesonwrapper.h"
#include <utils/launcherinterface.h>
#include <utils/processreaper.h>
#include <QCoreApplication>
#include <QDir> #include <QDir>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
@@ -44,7 +48,12 @@ class AMesonWrapper : public QObject
Q_OBJECT Q_OBJECT
private slots: private slots:
void initTestCase() {} void initTestCase()
{
Utils::LauncherInterface::startLauncher(
QCoreApplication::instance()->applicationDirPath() + '/'
+ QLatin1String(TEST_RELATIVE_LIBEXEC_PATH));
}
void shouldFindMesonFromPATH() void shouldFindMesonFromPATH()
{ {
@@ -104,7 +113,13 @@ private slots:
Utils::FilePath::fromString(build_dir.path())))); Utils::FilePath::fromString(build_dir.path()))));
} }
void cleanupTestCase() {} void cleanupTestCase()
{
Utils::LauncherInterface::stopLauncher();
}
private:
Utils::ProcessReaper processReaper;
}; };
QTEST_MAIN(AMesonWrapper) QTEST_MAIN(AMesonWrapper)