Add app to automatically setup basic env for manual testing

This commit is contained in:
Martchus 2018-01-27 16:04:17 +01:00
parent b9c87a9bba
commit 2f26543acf
5 changed files with 43 additions and 6 deletions

View File

@ -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)

View File

@ -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

View File

@ -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;

View File

@ -0,0 +1 @@
../../connector/testfiles/testconfig

View File

@ -0,0 +1,29 @@
#include "../syncthingtestinstance.h"
#include <c++utilities/tests/testutils.h>
#include <iostream>
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<void (QProcess::*)(int)>(&QProcess::finished), &QCoreApplication::exit);
testInstance.start();
const int res = testInstance.application().exec();
testInstance.stop();
return res;
}