From d4aebd30de52142406bde6cdc93d983123e000b6 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 20 Feb 2018 14:29:45 +0100 Subject: [PATCH 1/2] 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 --- src/common/utility.cpp | 12 +++++++----- test/testutility.cpp | 17 ++++++++++------- 2 files changed, 17 insertions(+), 12 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(fsCasePreserving()); - qputenv("OWNCLOUD_TEST_CASE_PRESERVING", "0"); - QVERIFY(! fsCasePreserving()); - qunsetenv("OWNCLOUD_TEST_CASE_PRESERVING"); QVERIFY(isMac() || isWindows() ? fsCasePreserving() : ! fsCasePreserving()); + QScopedValueRollback scope(OCC::fsCasePreserving_override); + OCC::fsCasePreserving_override = 1; + QVERIFY(fsCasePreserving()); + OCC::fsCasePreserving_override = 0; + QVERIFY(! 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 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"); } From b0f539fc1f2c978a6b71ef7adff65d930d0cf25f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 20 Feb 2018 17:06:36 +0100 Subject: [PATCH 2/2] cmake: Remove references of now unused WITH_TESTING Issue #6318 --- CMakeLists.txt | 3 --- config.h.in | 2 -- src/csync/config_csync.h.cmake | 1 - 3 files changed, 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b891db480..9b3576bbf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,9 +215,6 @@ endif() file( GLOB TRANS_FILES ${CMAKE_SOURCE_DIR}/translations/client_*.ts) set(TRANSLATIONS ${TRANS_FILES}) -# Make sure we set this before recursing into child folders. -set(WITH_TESTING ${UNIT_TESTING}) - if(BUILD_CLIENT) add_subdirectory(src) if(NOT BUILD_LIBRARIES_ONLY) diff --git a/config.h.in b/config.h.in index dfd243a09..804d5f68c 100644 --- a/config.h.in +++ b/config.h.in @@ -24,6 +24,4 @@ #cmakedefine SYSCONFDIR "@SYSCONFDIR@" #cmakedefine SHAREDIR "@SHAREDIR@" -#cmakedefine WITH_TESTING 1 - #endif diff --git a/src/csync/config_csync.h.cmake b/src/csync/config_csync.h.cmake index d1a64cb95..9a8043f1b 100644 --- a/src/csync/config_csync.h.cmake +++ b/src/csync/config_csync.h.cmake @@ -17,4 +17,3 @@ #cmakedefine HAVE___MINGW_ASPRINTF 1 #cmakedefine HAVE_ASPRINTF 1 -#cmakedefine WITH_TESTING 1