summaryrefslogtreecommitdiffstats
path: root/common/test.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-08 11:01:48 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-08 11:01:48 +0200
commit9317fbffeab4a8c258acb1116eb12fbded7053d8 (patch)
treeb1f00b8ee96e222c16d25d02b49ade1ef3aee8ae /common/test.cpp
parent1b6439215fa0bb6ac1e191c2ffc992e815a53199 (diff)
downloadsink-9317fbffeab4a8c258acb1116eb12fbded7053d8.tar.gz
sink-9317fbffeab4a8c258acb1116eb12fbded7053d8.zip
Control debugoutput during tests with sinksh.
Diffstat (limited to 'common/test.cpp')
-rw-r--r--common/test.cpp28
1 files changed, 28 insertions, 0 deletions
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 @@
27#include "facadefactory.h" 27#include "facadefactory.h"
28#include "query.h" 28#include "query.h"
29#include "resourceconfig.h" 29#include "resourceconfig.h"
30#include "definitions.h"
30 31
31SINK_DEBUG_AREA("test") 32SINK_DEBUG_AREA("test")
32 33
@@ -34,6 +35,9 @@ using namespace Sink;
34 35
35void Sink::Test::initTest() 36void Sink::Test::initTest()
36{ 37{
38 auto logIniFile = Sink::configLocation() + "/log.ini";
39 auto areaAutocompletionFile = Sink::dataLocation() + "/debugAreas.ini";
40
37 setTestModeEnabled(true); 41 setTestModeEnabled(true);
38 // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); 42 // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
39 QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).removeRecursively(); 43 QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).removeRecursively();
@@ -48,6 +52,30 @@ void Sink::Test::initTest()
48 // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation); 52 // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
49 QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).removeRecursively(); 53 QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).removeRecursively();
50 Log::setPrimaryComponent("test"); 54 Log::setPrimaryComponent("test");
55
56 //We copy those files so we can control debug output from outside the test with sinksh
57 {
58 QFile file(logIniFile);
59 if (!file.open(QIODevice::ReadOnly)) {
60 qWarning() << "Failed to open the file: " << logIniFile;
61 }
62 QDir dir;
63 dir.mkpath(Sink::configLocation());
64 if (!file.copy(Sink::configLocation() + "/log.ini")) {
65 qWarning() << "Failed to move the file: " << Sink::configLocation() + "/log.ini";
66 }
67 }
68 {
69 QFile file(areaAutocompletionFile);
70 if (!file.open(QIODevice::ReadOnly)) {
71 qWarning() << "Failed to open the file: " << logIniFile;
72 }
73 QDir dir;
74 dir.mkpath(Sink::dataLocation());
75 if (!file.copy(Sink::dataLocation() + "/debugAreas.ini")) {
76 qWarning() << "Failed to move the file: " << Sink::configLocation() + "/log.ini";
77 }
78 }
51} 79}
52 80
53void Sink::Test::setTestModeEnabled(bool enabled) 81void Sink::Test::setTestModeEnabled(bool enabled)