mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-22 14:24:13 +02:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QStandardPaths>
|
||||||
#include <QTemporaryDir>
|
#include <QTemporaryDir>
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
@@ -86,6 +87,11 @@ inline QAction *action(const QString &name)
|
|||||||
template <typename Test>
|
template <typename Test>
|
||||||
int run(int argc, char **argv)
|
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);
|
QApplication app(argc, argv);
|
||||||
QCoreApplication::setOrganizationName("QElectroTech");
|
QCoreApplication::setOrganizationName("QElectroTech");
|
||||||
QCoreApplication::setApplicationName("QElectroTech");
|
QCoreApplication::setApplicationName("QElectroTech");
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QSignalBlocker>
|
#include <QSignalBlocker>
|
||||||
#include <QStandardPaths>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
qet-assistant.json names the user and company collections, and the qet
|
qet-assistant.json names the user and company collections, and the qet
|
||||||
@@ -88,13 +87,6 @@ private slots:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
QET_APP_TEST_MAIN(tst_assistantinfopaths)
|
||||||
{
|
|
||||||
//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<tst_assistantinfopaths>(argc, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "tst_assistantinfopaths.moc"
|
#include "tst_assistantinfopaths.moc"
|
||||||
|
|||||||
Reference in New Issue
Block a user