feat(Storybook): Validator app to check if all pages can be compiled

Closes: #12282
This commit is contained in:
Michał Cieślak 2023-09-28 10:11:47 +02:00 committed by Michał
parent 91de960e08
commit 0107203a46
3 changed files with 65 additions and 2 deletions

View File

@ -80,6 +80,19 @@ target_link_libraries(
add_dependencies(${PROJECT_NAME} StatusQ)
add_executable(
PagesValidator
validator_main.cpp
)
target_link_libraries(
PagesValidator PUBLIC Qt5::Core Qt5::Gui Qt5::Quick Qt5::QuickControls2)
target_compile_definitions(PagesValidator PRIVATE
QML_IMPORT_ROOT="${CMAKE_CURRENT_LIST_DIR}"
STATUSQ_MODULE_IMPORT_PATH="${STATUSQ_MODULE_IMPORT_PATH}"
)
enable_testing()
add_executable(SectionsDecoratorModelTest tests/tst_SectionsDecoratorModel.cpp)

View File

@ -36,8 +36,7 @@ int main(int argc, char *argv[])
QML_IMPORT_ROOT + QStringLiteral("/../ui/imports"),
QML_IMPORT_ROOT + QStringLiteral("/src"),
QML_IMPORT_ROOT + QStringLiteral("/pages"),
QML_IMPORT_ROOT + QStringLiteral("/stubs"),
QML_IMPORT_ROOT + QStringLiteral("/mocks"),
QML_IMPORT_ROOT + QStringLiteral("/stubs")
};
for (const auto& path : additionalImportPaths)

View File

@ -0,0 +1,51 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QDir>
#include <QQmlComponent>
#include <QQmlContext>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QStringList additionalImportPaths {
STATUSQ_MODULE_IMPORT_PATH,
QML_IMPORT_ROOT + QStringLiteral("/../ui/app"),
QML_IMPORT_ROOT + QStringLiteral("/../ui/imports"),
QML_IMPORT_ROOT + QStringLiteral("/src"),
QML_IMPORT_ROOT + QStringLiteral("/stubs")
};
for (const auto& path : additionalImportPaths)
engine.addImportPath(path);
QString pagesPath = QML_IMPORT_ROOT + QStringLiteral("/pages");
QDir pagesDir(pagesPath);
const QFileInfoList files = pagesDir.entryInfoList(
{ QStringLiteral("*Page.qml") }, QDir::Files, QDir::Name);
engine.setBaseUrl(QUrl::fromLocalFile(pagesPath + QDir::separator()));
bool errorsFound = false;
for (auto& fileInfo : files) {
auto fileName = fileInfo.fileName();
qDebug() << fileName;
QQmlComponent component(&engine, fileName);
if (component.isError()) {
qWarning() << component.errors();
errorsFound = true;
}
}
if (errorsFound)
return EXIT_FAILURE;
qDebug() << "Verification completed successfully.";
return EXIT_SUCCESS;
}