diff options
| author | Sebastian Englbrecht <[email protected]> | 2026-05-23 15:30:30 +0200 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-05-28 08:12:53 +0000 |
| commit | 1330df1053a9ee9927dc27e1f333a67965dbf02e (patch) | |
| tree | f78bee964ddac22c7d9df707ad628121db93765b | |
| parent | 74a63f5fa93285f59aed6e47656fc2d18f4d4567 (diff) | |
tests: create smoke test for dolphin
| -rw-r--r-- | src/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/main.cpp | 13 | ||||
| -rw-r--r-- | src/tests/CMakeLists.txt | 6 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4faabe9d5..a8769454b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -668,6 +668,7 @@ install( ) if(BUILD_TESTING) + target_compile_definitions(dolphin PRIVATE BUILD_TESTING) add_subdirectory(tests) endif() diff --git a/src/main.cpp b/src/main.cpp index 1ef608193..3c89f98a9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,6 +37,7 @@ #include <QDBusConnection> #include <QDBusConnectionInterface> #include <QSessionManager> +#include <QTimer> #if HAVE_X11 #include <private/qtx11extras_p.h> @@ -142,6 +143,12 @@ int main(int argc, char **argv) i18nc("@info:shell", "Set up Dolphin for administrative tasks."))); parser.addOption( QCommandLineOption(QStringList() << QStringLiteral("daemon"), i18nc("@info:shell", "Start Dolphin Daemon (only required for DBus Interface)."))); +#ifdef BUILD_TESTING + { + QCommandLineOption selfTestOption(QStringLiteral("self-test")); + parser.addOption(selfTestOption); + } +#endif parser.addPositionalArgument(QStringLiteral("+[Url]"), i18nc("@info:shell", "Document to open")); parser.process(app); @@ -275,5 +282,11 @@ int main(int argc, char **argv) Q_UNUSED(feedbackProvider) #endif +#ifdef BUILD_TESTING + if (parser.isSet(QStringLiteral("self-test"))) { + QTimer::singleShot(std::chrono::milliseconds(500), &app, &QCoreApplication::quit); + } +#endif + return app.exec(); // krazy:exclude=crash; } diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 6a07ff8b9..a694ec8fb 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -99,6 +99,12 @@ add_test( fi" ) +# Smoke test: launch Dolphin, verify it starts without crashing, then quit. +if(NOT WIN32) + add_test(NAME dolphin_smoketest COMMAND "$<TARGET_FILE:dolphin>" --self-test) + set_tests_properties(dolphin_smoketest PROPERTIES TIMEOUT 30) +endif() + find_gem(test-unit) set_package_properties(Gem_test-unit PROPERTIES TYPE RECOMMENDED |
