[utilities/kongress] /: Add smoke test

Volker Krause <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit c76a81316ecf58670dfe9f95b74e8fc78a65dc9b by Volker Krause.
Committed on 01/08/2026 at 08:57.
Pushed by vkrause into branch 'master'.

Add smoke test

Ensures the app (and its Flatpak) actually start.

M  +3    -0    .gitlab-ci.yml
M  +5    -0    .kde-ci.yml
M  +3    -1    CMakeLists.txt
A  +4    -0    autotests/CMakeLists.txt
M  +11   -2    src/main.cpp

https://invent.kde.org/utilities/kongress/-/commit/c76a81316ecf58670dfe9f95b74e8fc78a65dc9b

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c82af6f..039f8f3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,6 +1,9 @@
 # SPDX-FileCopyrightText: 2020 Volker Krause <[email protected]>
 # SPDX-License-Identifier: CC0-1.0
 
+variables:
+  KDE_FLATPAK_TEST_COMMAND: "flatpak run org.kde.kongress --self-test"
+
 include:
   - project: sysadmin/ci-utilities
     file:
diff --git a/.kde-ci.yml b/.kde-ci.yml
index b2dbf2b..eca7cde 100644
--- a/.kde-ci.yml
+++ b/.kde-ci.yml
@@ -20,5 +20,10 @@ Dependencies:
     'frameworks/kdbusaddons': '@latest-kf6'
     'frameworks/kcrash': '@latest-kf6'
 
+RuntimeDependencies:
+ - 'on': ['Linux', 'FreeBSD']
+   'require':
+    'frameworks/qqc2-desktop-style': '@latest-kf6'
+
 Options:
  require-passing-tests-on: ['@all']
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7b66a98..66d2f34 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,10 +67,12 @@ if(NOT ANDROID AND REMINDERS_ENABLED)
 endif()
 
 add_subdirectory(src)
-
 if(NOT ANDROID AND REMINDERS_ENABLED)
     add_subdirectory(kongressac)
 endif()
+if (BUILD_TESTING)
+    add_subdirectory(autotests)
+endif()
 
 if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po")
     ki18n_install(po)
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
new file mode 100644
index 0000000..8f3fed2
--- /dev/null
+++ b/autotests/CMakeLists.txt
@@ -0,0 +1,4 @@
+# SPDX-FileCopyrightText: Volker Krause <[email protected]>
+# SPDX-License-Identifier: BSD-2-Clause
+
+add_test(NAME kongress-self-test COMMAND kongress --self-test)
diff --git a/src/main.cpp b/src/main.cpp
index 6b7de0f..2ab7306 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -40,8 +40,11 @@
 #include <QQmlContext>
 #include <QQuickStyle>
 #include <QStandardPaths>
+#include <QTimer>
 #include <QUrl>
 
+using namespace Qt::Literals;
+
 Q_DECL_EXPORT int main(int argc, char *argv[])
 {
 #ifdef Q_OS_ANDROID
@@ -80,6 +83,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
 
     QCommandLineParser parser;
     about.setupCommandLine(&parser);
+    QCommandLineOption selfTestOpt(u"self-test"_s, u"internal, for automated testing"_s);
+    selfTestOpt.setFlags(QCommandLineOption::HiddenFromHelp);
+    parser.addOption(selfTestOpt);
     parser.process(app);
     about.processCommandLine(&parser);
 
@@ -121,6 +127,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
         return -1;
     }
 
-    int ret = app.exec();
-    return ret;
+    if (parser.isSet(selfTestOpt)) {
+        QTimer::singleShot(std::chrono::milliseconds(250), &app, &QCoreApplication::quit);
+    }
+
+    return app.exec();
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.