diff --git a/testhelper/CMakeLists.txt b/testhelper/CMakeLists.txt index 880d1a0..b0953f7 100644 --- a/testhelper/CMakeLists.txt +++ b/testhelper/CMakeLists.txt @@ -7,6 +7,7 @@ set(META_APP_NAME "Syncthing Tray Test Helper") set(META_APP_DESCRIPTION "Helper for testing compontents of Syncthing Tray") set(META_PUBLIC_QT_MODULES Core) set(META_NO_INSTALL_TARGETS ON) +set(META_NO_CPP_UNIT ON) # add project files set(HEADER_FILES @@ -21,6 +22,7 @@ set(SRC_FILES set(TEST_HEADER_FILES ) set(TEST_SRC_FILES + tests/manualtesting.cpp ) set(TS_FILES @@ -48,6 +50,7 @@ include(BasicConfig) include(QtConfig) include(WindowsResources) include(LibraryTarget) +include(TestTarget) include(Doxygen) include(ConfigHeader) diff --git a/testhelper/syncthingtestinstance.cpp b/testhelper/syncthingtestinstance.cpp index 5661abd..277862b 100644 --- a/testhelper/syncthingtestinstance.cpp +++ b/testhelper/syncthingtestinstance.cpp @@ -93,8 +93,14 @@ void SyncthingTestInstance::stop() } if (m_syncthingProcess.isOpen()) { cerr << "\n - Syncthing terminated with exit code " << m_syncthingProcess.exitCode() << ".\n"; - cerr << "\n - Syncthing stdout during the testrun:\n" << m_syncthingProcess.readAllStandardOutput().data(); - cerr << "\n - Syncthing stderr during the testrun:\n" << m_syncthingProcess.readAllStandardError().data(); + const auto stdOut(m_syncthingProcess.readAllStandardOutput()); + if (!stdOut.isEmpty()) { + cerr << "\n - Syncthing stdout during the testrun:\n" << stdOut.data(); + } + const auto stdErr(m_syncthingProcess.readAllStandardError()); + if (!stdErr.isEmpty()) { + cerr << "\n - Syncthing stderr during the testrun:\n" << stdErr.data(); + } } } } // namespace TestUtilities diff --git a/testhelper/syncthingtestinstance.h b/testhelper/syncthingtestinstance.h index 1a40d05..30a5c9b 100644 --- a/testhelper/syncthingtestinstance.h +++ b/testhelper/syncthingtestinstance.h @@ -24,15 +24,13 @@ public: const QString &apiKey() const; const QString &syncthingPort() const; + QCoreApplication &application(); + QProcess &syncthingProcess(); public Q_SLOTS: void start(); void stop(); -protected: - QCoreApplication &application(); - QProcess &syncthingProcess(); - private: QString m_apiKey; QString m_syncthingPort; diff --git a/testhelper/testfiles/testconfig b/testhelper/testfiles/testconfig new file mode 120000 index 0000000..fbe1030 --- /dev/null +++ b/testhelper/testfiles/testconfig @@ -0,0 +1 @@ +../../connector/testfiles/testconfig \ No newline at end of file diff --git a/testhelper/tests/manualtesting.cpp b/testhelper/tests/manualtesting.cpp new file mode 100644 index 0000000..3c1f252 --- /dev/null +++ b/testhelper/tests/manualtesting.cpp @@ -0,0 +1,29 @@ +#include "../syncthingtestinstance.h" + +#include + +#include + +using namespace std; +using namespace TestUtilities; + +/*! + * \brief Launches a Syncthing test instance for manual testing. + */ +int main(int argc, char **argv) +{ + TestApplication testApp(argc, argv); + if (!testApp) { + return -1; + } + + SyncthingTestInstance testInstance; + auto &syncthingProcess(testInstance.syncthingProcess()); + syncthingProcess.setReadChannelMode(QProcess::ForwardedChannels); + QObject::connect(&syncthingProcess, static_cast(&QProcess::finished), &QCoreApplication::exit); + testInstance.start(); + + const int res = testInstance.application().exec(); + testInstance.stop(); + return res; +}