Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2018-02-20 16:29:45 +0300
committerCamila San <hello@camila.codes>2018-05-16 13:57:20 +0300
commitd4aebd30de52142406bde6cdc93d983123e000b6 (patch)
tree9c613cd4f6984a49d8b22655588ccbe5f700b031
parent5e2270bd570c06905c5be953f7d1eaa055d503ac (diff)
Utility::fsCasePreserving: remove UNIT_TESTING ifdef
Since the release package will be build with unit test, we don't want to query the env variable at every call to fsCasePreserving. So only test the env variable at startup. And the testutility can still change the value. (The env variable is still used from t8.pl and maybe smashbox) Issue #6318
-rw-r--r--src/common/utility.cpp12
-rw-r--r--test/testutility.cpp15
2 files changed, 16 insertions, 11 deletions
diff --git a/src/common/utility.cpp b/src/common/utility.cpp
index e8a3546f0..36de6a11f 100644
--- a/src/common/utility.cpp
+++ b/src/common/utility.cpp
@@ -254,15 +254,17 @@ void Utility::usleep(int usec)
QThread::usleep(usec);
}
-bool Utility::fsCasePreserving()
-{
-#ifdef WITH_TESTING
+// This can be overriden from the tests
+OCSYNC_EXPORT bool fsCasePreserving_override = []()-> bool {
QByteArray env = qgetenv("OWNCLOUD_TEST_CASE_PRESERVING");
if (!env.isEmpty())
return env.toInt();
-#endif
+ return Utility::isWindows() || Utility::isMac();
+}();
- return isWindows() || isMac();
+bool Utility::fsCasePreserving()
+{
+ return fsCasePreserving_override;
}
bool Utility::fileNamesEqual(const QString &fn1, const QString &fn2)
diff --git a/test/testutility.cpp b/test/testutility.cpp
index c83b14199..1c538c58f 100644
--- a/test/testutility.cpp
+++ b/test/testutility.cpp
@@ -11,6 +11,10 @@
using namespace OCC::Utility;
+namespace OCC {
+OCSYNC_EXPORT extern bool fsCasePreserving_override;
+}
+
class TestUtility : public QObject
{
Q_OBJECT
@@ -150,12 +154,12 @@ private slots:
void testFsCasePreserving()
{
- qputenv("OWNCLOUD_TEST_CASE_PRESERVING", "1");
+ QVERIFY(isMac() || isWindows() ? fsCasePreserving() : ! fsCasePreserving());
+ QScopedValueRollback<bool> scope(OCC::fsCasePreserving_override);
+ OCC::fsCasePreserving_override = 1;
QVERIFY(fsCasePreserving());
- qputenv("OWNCLOUD_TEST_CASE_PRESERVING", "0");
+ OCC::fsCasePreserving_override = 0;
QVERIFY(! fsCasePreserving());
- qunsetenv("OWNCLOUD_TEST_CASE_PRESERVING");
- QVERIFY(isMac() || isWindows() ? fsCasePreserving() : ! fsCasePreserving());
}
void testFileNamesEqual()
@@ -178,13 +182,12 @@ private slots:
QVERIFY(fileNamesEqual(a+"/test", b+"/test")); // both exist
QVERIFY(fileNamesEqual(a+"/test/TESTI", b+"/test/../test/TESTI")); // both exist
- qputenv("OWNCLOUD_TEST_CASE_PRESERVING", "1");
+ QScopedValueRollback<bool> scope(OCC::fsCasePreserving_override, true);
QVERIFY(fileNamesEqual(a+"/test", b+"/TEST")); // both exist
QVERIFY(!fileNamesEqual(a+"/test", b+"/test/TESTI")); // both are different
dir.remove();
- qunsetenv("OWNCLOUD_TEST_CASE_PRESERVING");
}