Warning, file /frameworks/oxygen-icons/autotests/dupetest.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 Copyright 2016 Harald Sitter <sitter@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Lesser General Public 0006 License as published by the Free Software Foundation; either 0007 version 2.1 of the License, or (at your option) version 3, or any 0008 later version accepted by the membership of KDE e.V. (or its 0009 successor approved by the membership of KDE e.V.), which shall 0010 act as a proxy defined in Section 6 of version 3 of the license. 0011 0012 This library is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 Lesser General Public License for more details. 0016 0017 You should have received a copy of the GNU Lesser General Public 0018 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0019 */ 0020 0021 #include <QObject> 0022 #include <QProcess> 0023 #include <QStandardPaths> 0024 #include <QTest> 0025 0026 #include "testhelpers.h" 0027 0028 class DupeTest : public QObject 0029 { 0030 Q_OBJECT 0031 0032 void readLines(QProcess &proc) 0033 { 0034 QString line; 0035 while (proc.canReadLine() || proc.waitForReadyRead()) { 0036 line = proc.readLine(); 0037 failListContent(line.simplified().split(QChar(' ')), "The following files are duplicates but not links:\n"); 0038 } 0039 } 0040 0041 void dupesForDirectory(const QString &path) 0042 { 0043 QProcess proc; 0044 const QString exec = QStandardPaths::findExecutable(QStringLiteral("fdupes")); 0045 if (exec.isEmpty()) { 0046 QFAIL("Could not find the fdupes executable in PATH."); 0047 return; 0048 } 0049 0050 proc.setProgram(exec); 0051 proc.setArguments(QStringList() << QStringLiteral("--recurse") << QStringLiteral("--sameline") << QStringLiteral("--nohidden") << path); 0052 proc.start(); 0053 proc.waitForStarted(); 0054 readLines(proc); 0055 } 0056 0057 private Q_SLOTS: 0058 void test_duplicates() 0059 { 0060 if (QStandardPaths::findExecutable(QStringLiteral("fdupes")).isEmpty()) { 0061 #ifdef Q_OS_WIN 0062 QSKIP("this test needs the fdupes binary (1.51+) to run"); 0063 #else 0064 // Fail and skip. This is a fairly relevant test, so it not running is a warning really. 0065 QFAIL("this test needs the fdupes binary (1.51+) to run"); 0066 #endif 0067 } 0068 for (auto dir : ICON_DIRS) { 0069 dupesForDirectory(PROJECT_SOURCE_DIR + QStringLiteral("/") + dir); 0070 } 0071 } 0072 }; 0073 0074 QTEST_GUILESS_MAIN(DupeTest) 0075 0076 #include "dupetest.moc"