Enable verbose logging for tests and dump Syncthing config at the end

This is not very verbose but hopefully it'll help debugging test failures
more easily.
This commit is contained in:
Martchus 2023-01-30 15:19:08 +01:00
parent edceb2fddb
commit e67f40ca18
3 changed files with 17 additions and 0 deletions

View File

@ -958,6 +958,9 @@ void SyncthingConnection::setStatus(SyncthingStatus status)
*/
void SyncthingConnection::emitError(const QString &message, const QJsonParseError &jsonError, QNetworkReply *reply, const QByteArray &response)
{
if (loggingFlags() & SyncthingConnectionLoggingFlags::ApiReplies) {
cerr << Phrases::Error << "JSON parsing error: " << message.toLocal8Bit().data() << jsonError.errorString().toLocal8Bit().data() << " (at offset " << jsonError.offset << ')' << endl;
}
emit error(message % jsonError.errorString() % QChar(' ') % QChar('(') % tr("at offset %1").arg(jsonError.offset) % QChar(')'),
SyncthingErrorCategory::Parsing, QNetworkReply::NoError, reply->request(), response);
}
@ -967,6 +970,9 @@ void SyncthingConnection::emitError(const QString &message, const QJsonParseErro
*/
void SyncthingConnection::emitError(const QString &message, SyncthingErrorCategory category, QNetworkReply *reply)
{
if (loggingFlags() & SyncthingConnectionLoggingFlags::ApiReplies) {
cerr << Phrases::Error << "Syncthing connection error: " << message.toLocal8Bit().data() << reply->errorString().toLocal8Bit().data() << endl;
}
emit error(message + reply->errorString(), category, reply->error(), reply->request(), reply->bytesAvailable() ? reply->readAll() : QByteArray());
}

View File

@ -157,5 +157,6 @@ foreach (TEST ${QT_TESTS})
# avoid running wizard tests in parallel with other tests spawning a Syncthing test instance
if ("${TEST}" STREQUAL "wizard")
set_tests_properties("${FULL_TEST_NAME_${TEST}}" PROPERTIES RESOURCE_LOCK "syncthingtestinstance")
set_tests_properties("${FULL_TEST_NAME_${TEST}}" PROPERTIES ENVIRONMENT "LIB_SYNCTHING_CONNECTOR_LOG_ALL=1")
endif ()
endforeach ()

View File

@ -95,6 +95,10 @@ void WizardTests::initTestCase()
void WizardTests::cleanupTestCase()
{
auto syncthingConfig = QFile(m_homeDir.path() + QStringLiteral("/config.xml"));
qDebug() << "Syncthing config: ";
!syncthingConfig.open(QFile::ReadOnly) ? (qDebug() << "unable to open") : (qDebug().noquote() << syncthingConfig.readAll());
if (m_launcher.isRunning()) {
qDebug() << "terminating Syncthing";
m_launcher.terminate();
@ -348,6 +352,12 @@ void WizardTests::testConfiguringCurrentlyRunningSyncthing()
m_eventLoop.exec();
// configure external launcher
const auto &url = setupDetection.connection.syncthingUrl();
const auto &apiKey = setupDetection.connection.apiKey();
qDebug() << "configured URL: " << url;
qDebug() << "configured API key: " << apiKey;
QVERIFY(!url.isEmpty());
QVERIFY(!apiKey.isEmpty());
auto *const mainConfigPage = qobject_cast<MainConfigWizardPage *>(wizardDlg.currentPage());
QVERIFY(mainConfigPage != nullptr);
QVERIFY(setupDetection.hasConfig());