From c249414411951064d75f1ad2167c10cf7b44d1b9 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 14 Oct 2018 22:47:49 +0200 Subject: [PATCH] Improve SyncthingTestInstance * Show Syncthing's output interleaved with the test output by default * Show Syncthing start parameter --- testhelper/syncthingtestinstance.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/testhelper/syncthingtestinstance.cpp b/testhelper/syncthingtestinstance.cpp index 57bcf82..babb952 100644 --- a/testhelper/syncthingtestinstance.cpp +++ b/testhelper/syncthingtestinstance.cpp @@ -73,8 +73,12 @@ void SyncthingTestInstance::start() const int syncthingPortFromEnv(qEnvironmentVariableIntValue("SYNCTHING_PORT")); m_syncthingPort = !syncthingPortFromEnv ? QStringLiteral("4001") : QString::number(syncthingPortFromEnv); + // forward Syncthing's output to see what Syncthing is doing and what the test is doing at the same time + if (qEnvironmentVariableIsEmpty("SYNCTHING_TEST_NO_INTERLEAVED_OUTPUT")) { + m_syncthingProcess.setReadChannelMode(QProcess::ForwardedChannels); + } + // start st - cerr << "\n - Launching Syncthing ..." << endl; // clang-format off const QStringList args{ QStringLiteral("-gui-address=http://localhost:") + m_syncthingPort, @@ -83,6 +87,9 @@ void SyncthingTestInstance::start() QStringLiteral("-no-browser"), QStringLiteral("-verbose"), }; + cerr << "\n - Launching Syncthing: " + << syncthingPath.toStdString() + << ' ' << args.join(QChar(' ')).toStdString() << endl; m_syncthingProcess.start(syncthingPath, args); // clang-format on } @@ -107,9 +114,11 @@ void SyncthingTestInstance::stop() if (!stdErr.isEmpty()) { cerr << "\n - Syncthing stderr during the testrun:\n" << stdErr.data(); } - cerr << "\n - Syncthing (re)started: " << stdOut.count("INFO: Starting syncthing") << " times"; - cerr << "\n - Syncthing exited: " << stdOut.count("INFO: Syncthing exited: exit status") << " times"; - cerr << "\n - Syncthing panicked: " << stdOut.count("WARNING: Panic detected") << " times"; + if (!stdOut.isEmpty()) { + cerr << "\n - Syncthing (re)started: " << stdOut.count("INFO: Starting syncthing") << " times"; + cerr << "\n - Syncthing exited: " << stdOut.count("INFO: Syncthing exited: exit status") << " times"; + cerr << "\n - Syncthing panicked: " << stdOut.count("WARNING: Panic detected") << " times"; + } } } } // namespace TestUtilities