summaryrefslogtreecommitdiffstats
path: root/common/test.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-05-23 14:43:26 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-05-23 14:43:26 +0200
commitc9f26c4cbca654417d304c9214aa3a7709631159 (patch)
treefd19cab23dbea2364f6c381d67d68fdd943f63a2 /common/test.cpp
parent422950c63f830e4d01315afc37d0144f79bf10db (diff)
downloadsink-c9f26c4cbca654417d304c9214aa3a7709631159.tar.gz
sink-c9f26c4cbca654417d304c9214aa3a7709631159.zip
Propagate test-mode to resources.
This way we can run tests in completely separate data-directories.
Diffstat (limited to 'common/test.cpp')
-rw-r--r--common/test.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/common/test.cpp b/common/test.cpp
index 1062e21..59ad9ec 100644
--- a/common/test.cpp
+++ b/common/test.cpp
@@ -32,7 +32,7 @@ using namespace Sink;
32 32
33void Sink::Test::initTest() 33void Sink::Test::initTest()
34{ 34{
35 QStandardPaths::setTestModeEnabled(true); 35 setTestModeEnabled(true);
36 // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); 36 // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
37 QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).removeRecursively(); 37 QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).removeRecursively();
38 // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::DataLocation); 38 // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::DataLocation);
@@ -47,6 +47,20 @@ void Sink::Test::initTest()
47 QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).removeRecursively(); 47 QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).removeRecursively();
48} 48}
49 49
50void Sink::Test::setTestModeEnabled(bool enabled)
51{
52 QStandardPaths::setTestModeEnabled(enabled);
53 if (enabled) {
54 qputenv("SINK_TESTMODE", "TRUE");
55 } else {
56 qunsetenv("SINK_TESTMODE");
57 }
58}
59
60bool Sink::Test::testModeEnabled()
61{
62 return !qEnvironmentVariableIsEmpty("SINK_TESTMODE");
63}
50 64
51template <typename T> 65template <typename T>
52class TestFacade : public Sink::StoreFacade<T> 66class TestFacade : public Sink::StoreFacade<T>