From 0a0809d7f4b0e44f622dda7601d94fa9ca088aeb Mon Sep 17 00:00:00 2001 From: ispyisail Date: Sun, 18 Oct 2026 08:33:17 +1300 Subject: [PATCH] Tests: keep every app test out of the user's standard folders QetAppTest::run() moved settings, configuration and data into a temporary folder, but QStandardPaths still pointed at the user's own. Two things follow on a developer's machine: - qet-assistant.json, live-mode token included, is rewritten by every app test as its editor opens. - A .qetautosave file left in the user's data folder makes QETApp offer to restore it in a modal dialog at start. Offscreen nobody answers, so all six app tests hang until ctest times them out. Test mode is now enabled first thing in run(). tst_assistantinfopaths (#1513) did this in its own main(); it goes back to QET_APP_TEST_MAIN. Co-Authored-By: Claude Opus 5.5 --- tests/qttest/qetapptest.h | 6 ++++++ tests/qttest/tst_assistantinfopaths.cpp | 10 +--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/qttest/qetapptest.h b/tests/qttest/qetapptest.h index 6e93f8ea5..123352abb 100644 --- a/tests/qttest/qetapptest.h +++ b/tests/qttest/qetapptest.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -86,6 +87,11 @@ inline QAction *action(const QString &name) template int run(int argc, char **argv) { + //Some files are written to the standard folders whatever + //--data-dir says (qet-assistant.json, with the live-mode token, as + //the editor opens): test mode, before anything is written, keeps + //them away from the user's own + QStandardPaths::setTestModeEnabled(true); QApplication app(argc, argv); QCoreApplication::setOrganizationName("QElectroTech"); QCoreApplication::setApplicationName("QElectroTech"); diff --git a/tests/qttest/tst_assistantinfopaths.cpp b/tests/qttest/tst_assistantinfopaths.cpp index 96e99dd67..21d7a10b5 100644 --- a/tests/qttest/tst_assistantinfopaths.cpp +++ b/tests/qttest/tst_assistantinfopaths.cpp @@ -25,7 +25,6 @@ #include #include #include -#include /** qet-assistant.json names the user and company collections, and the qet @@ -88,13 +87,6 @@ private slots: } }; -int main(int argc, char **argv) -{ - //AssistantInfo writes to the standard data folder, whatever - //--data-dir says, and QETApp writes it as its editor opens: test - //mode from the very start keeps the user's own file out of reach. - QStandardPaths::setTestModeEnabled(true); - return QetAppTest::run(argc, argv); -} +QET_APP_TEST_MAIN(tst_assistantinfopaths) #include "tst_assistantinfopaths.moc"