From 9317fbffeab4a8c258acb1116eb12fbded7053d8 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 8 Jul 2016 11:01:48 +0200 Subject: Control debugoutput during tests with sinksh. --- common/test.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'common/test.cpp') diff --git a/common/test.cpp b/common/test.cpp index 99e51c8..5b4c899 100644 --- a/common/test.cpp +++ b/common/test.cpp @@ -27,6 +27,7 @@ #include "facadefactory.h" #include "query.h" #include "resourceconfig.h" +#include "definitions.h" SINK_DEBUG_AREA("test") @@ -34,6 +35,9 @@ using namespace Sink; void Sink::Test::initTest() { + auto logIniFile = Sink::configLocation() + "/log.ini"; + auto areaAutocompletionFile = Sink::dataLocation() + "/debugAreas.ini"; + setTestModeEnabled(true); // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).removeRecursively(); @@ -48,6 +52,30 @@ void Sink::Test::initTest() // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation); QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).removeRecursively(); Log::setPrimaryComponent("test"); + + //We copy those files so we can control debug output from outside the test with sinksh + { + QFile file(logIniFile); + if (!file.open(QIODevice::ReadOnly)) { + qWarning() << "Failed to open the file: " << logIniFile; + } + QDir dir; + dir.mkpath(Sink::configLocation()); + if (!file.copy(Sink::configLocation() + "/log.ini")) { + qWarning() << "Failed to move the file: " << Sink::configLocation() + "/log.ini"; + } + } + { + QFile file(areaAutocompletionFile); + if (!file.open(QIODevice::ReadOnly)) { + qWarning() << "Failed to open the file: " << logIniFile; + } + QDir dir; + dir.mkpath(Sink::dataLocation()); + if (!file.copy(Sink::dataLocation() + "/debugAreas.ini")) { + qWarning() << "Failed to move the file: " << Sink::configLocation() + "/log.ini"; + } + } } void Sink::Test::setTestModeEnabled(bool enabled) -- cgit v1.2.3