diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 41a86609..0a0a0adf 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -1,25 +1,26 @@ remove_definitions(-DQT_NO_CAST_FROM_ASCII) include(ECMAddTests) if(BUILD_TESTING) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Test) + find_package(KF5CoreAddons ${KF5_VERSION} REQUIRED) configure_file(testdata.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/testdata.h) ecm_add_test(symlinktest.cpp TEST_NAME "symlink" LINK_LIBRARIES Qt5::Test ) ecm_add_test(newlinetest.cpp TEST_NAME "newline" LINK_LIBRARIES Qt5::Test ) ecm_add_test(dupetest.cpp TEST_NAME "dupe" - LINK_LIBRARIES Qt5::Test + LINK_LIBRARIES Qt5::Test KF5::CoreAddons ) ecm_add_test(scalabletest.cpp TEST_NAME "scalable" LINK_LIBRARIES Qt5::Test ) endif() diff --git a/autotests/dupetest.cpp b/autotests/dupetest.cpp index 8b170ddd..a142b76a 100644 --- a/autotests/dupetest.cpp +++ b/autotests/dupetest.cpp @@ -1,69 +1,71 @@ /* - Copyright 2016 Harald Sitter + Copyright 2016-2018 Harald Sitter This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include #include +#include #include "testhelpers.h" class DupeTest : public QObject { Q_OBJECT void readLines(QProcess &proc) { QString line; while (proc.canReadLine() || proc.waitForReadyRead()) { line = proc.readLine(); - failListContent(line.simplified().split(QChar(' ')), + // Split through KShell so we don't trip over paths with spaces. + failListContent(KShell::splitArgs(line.simplified()), "The following files are duplicates but not links:\n"); } } void dupesForDirectory(const QString &path) { QProcess proc; proc.setProgram(QStringLiteral("fdupes")); proc.setArguments(QStringList() << QStringLiteral("--recurse") << QStringLiteral("--sameline") << QStringLiteral("--nohidden") << path); proc.start(); proc.waitForStarted(); readLines(proc); } private Q_SLOTS: void test_duplicates() { if (QStandardPaths::findExecutable(QStringLiteral("fdupes")).isEmpty()) { // Fail and skip. This is a fairly relevant test, so it not running is a warning really. QFAIL("this test needs the fdupes binary (1.51+) to run"); } for (auto dir : ICON_DIRS) { dupesForDirectory(PROJECT_SOURCE_DIR + QStringLiteral("/") + dir); } } }; QTEST_GUILESS_MAIN(DupeTest) #include "dupetest.moc"