mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-25 14:36:01 +03:00
Merge pull request #311 from nextcloud/upstream/pr/6371
Utility::fsCasePreserving: remove UNIT_TESTING ifdef
This commit is contained in:
commit
c6c42c3c70
5 changed files with 17 additions and 18 deletions
|
@ -215,9 +215,6 @@ endif()
|
||||||
file( GLOB TRANS_FILES ${CMAKE_SOURCE_DIR}/translations/client_*.ts)
|
file( GLOB TRANS_FILES ${CMAKE_SOURCE_DIR}/translations/client_*.ts)
|
||||||
set(TRANSLATIONS ${TRANS_FILES})
|
set(TRANSLATIONS ${TRANS_FILES})
|
||||||
|
|
||||||
# Make sure we set this before recursing into child folders.
|
|
||||||
set(WITH_TESTING ${UNIT_TESTING})
|
|
||||||
|
|
||||||
if(BUILD_CLIENT)
|
if(BUILD_CLIENT)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
if(NOT BUILD_LIBRARIES_ONLY)
|
if(NOT BUILD_LIBRARIES_ONLY)
|
||||||
|
|
|
@ -24,6 +24,4 @@
|
||||||
#cmakedefine SYSCONFDIR "@SYSCONFDIR@"
|
#cmakedefine SYSCONFDIR "@SYSCONFDIR@"
|
||||||
#cmakedefine SHAREDIR "@SHAREDIR@"
|
#cmakedefine SHAREDIR "@SHAREDIR@"
|
||||||
|
|
||||||
#cmakedefine WITH_TESTING 1
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -254,15 +254,17 @@ void Utility::usleep(int usec)
|
||||||
QThread::usleep(usec);
|
QThread::usleep(usec);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Utility::fsCasePreserving()
|
// This can be overriden from the tests
|
||||||
{
|
OCSYNC_EXPORT bool fsCasePreserving_override = []()-> bool {
|
||||||
#ifdef WITH_TESTING
|
|
||||||
QByteArray env = qgetenv("OWNCLOUD_TEST_CASE_PRESERVING");
|
QByteArray env = qgetenv("OWNCLOUD_TEST_CASE_PRESERVING");
|
||||||
if (!env.isEmpty())
|
if (!env.isEmpty())
|
||||||
return env.toInt();
|
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)
|
bool Utility::fileNamesEqual(const QString &fn1, const QString &fn2)
|
||||||
|
|
|
@ -17,4 +17,3 @@
|
||||||
#cmakedefine HAVE___MINGW_ASPRINTF 1
|
#cmakedefine HAVE___MINGW_ASPRINTF 1
|
||||||
#cmakedefine HAVE_ASPRINTF 1
|
#cmakedefine HAVE_ASPRINTF 1
|
||||||
|
|
||||||
#cmakedefine WITH_TESTING 1
|
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
|
|
||||||
using namespace OCC::Utility;
|
using namespace OCC::Utility;
|
||||||
|
|
||||||
|
namespace OCC {
|
||||||
|
OCSYNC_EXPORT extern bool fsCasePreserving_override;
|
||||||
|
}
|
||||||
|
|
||||||
class TestUtility : public QObject
|
class TestUtility : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -150,12 +154,12 @@ private slots:
|
||||||
|
|
||||||
void testFsCasePreserving()
|
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());
|
QVERIFY(isMac() || isWindows() ? fsCasePreserving() : ! fsCasePreserving());
|
||||||
|
QScopedValueRollback<bool> scope(OCC::fsCasePreserving_override);
|
||||||
|
OCC::fsCasePreserving_override = 1;
|
||||||
|
QVERIFY(fsCasePreserving());
|
||||||
|
OCC::fsCasePreserving_override = 0;
|
||||||
|
QVERIFY(! fsCasePreserving());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testFileNamesEqual()
|
void testFileNamesEqual()
|
||||||
|
@ -178,13 +182,12 @@ private slots:
|
||||||
QVERIFY(fileNamesEqual(a+"/test", b+"/test")); // both exist
|
QVERIFY(fileNamesEqual(a+"/test", b+"/test")); // both exist
|
||||||
QVERIFY(fileNamesEqual(a+"/test/TESTI", b+"/test/../test/TESTI")); // 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")); // both exist
|
||||||
|
|
||||||
QVERIFY(!fileNamesEqual(a+"/test", b+"/test/TESTI")); // both are different
|
QVERIFY(!fileNamesEqual(a+"/test", b+"/test/TESTI")); // both are different
|
||||||
|
|
||||||
dir.remove();
|
dir.remove();
|
||||||
qunsetenv("OWNCLOUD_TEST_CASE_PRESERVING");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void testSanitizeForFileName_data()
|
void testSanitizeForFileName_data()
|
||||||
|
|
Loading…
Reference in a new issue