diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-23 14:43:26 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-23 14:43:26 +0200 |
commit | c9f26c4cbca654417d304c9214aa3a7709631159 (patch) | |
tree | fd19cab23dbea2364f6c381d67d68fdd943f63a2 /common/test.cpp | |
parent | 422950c63f830e4d01315afc37d0144f79bf10db (diff) | |
download | sink-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.cpp | 16 |
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 | ||
33 | void Sink::Test::initTest() | 33 | void 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 | ||
50 | void 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 | |||
60 | bool Sink::Test::testModeEnabled() | ||
61 | { | ||
62 | return !qEnvironmentVariableIsEmpty("SINK_TESTMODE"); | ||
63 | } | ||
50 | 64 | ||
51 | template <typename T> | 65 | template <typename T> |
52 | class TestFacade : public Sink::StoreFacade<T> | 66 | class TestFacade : public Sink::StoreFacade<T> |