Commit b578dcba authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add compare file helper

parent 6736a64c
......@@ -15,6 +15,7 @@ add_library(test_resourceconverter STATIC
testexportfile.cpp
testimportfile.cpp
logcreatingressource.cpp
comparefilehelper.cpp
)
target_link_libraries(test_resourceconverter PUBLIC KF5::ConfigCore pimdataexporterprivate KF5::Archive Qt5::Test)
......
......@@ -20,6 +20,7 @@
#include "compareexportfile.h"
#include "generatelistfilefromarchive.h"
#include "loadlistfromfile.h"
#include "comparefilehelper.h"
#include <QTest>
#include <QDebug>
#include <QProcess>
......@@ -88,25 +89,11 @@ void CompareExportFile::compareFiles()
QCOMPARE(f.write(data), data.length());
f.close();
compareFile(mListFilePath + QStringLiteral("/references/") + adaptFile, fileName);
CompareFileHelper::compareFile(mListFilePath + QStringLiteral("/references/") + adaptFile, fileName);
}
}
}
void CompareExportFile::compareFile(const QString &referenceFile, const QString &archiveFile)
{
//qDebug() << "referenceFile " << referenceFile << " archiveFile " << archiveFile;
QProcess proc;
const QStringList args = QStringList()
<< QStringLiteral("-u")
<< referenceFile
<< archiveFile;
proc.setProcessChannelMode(QProcess::ForwardedChannels);
proc.start(QStringLiteral("diff"), args);
QVERIFY(proc.waitForFinished());
QCOMPARE(proc.exitCode(), 0);
}
QString CompareExportFile::tempFilePath() const
{
return mTempFilePath;
......
......@@ -37,7 +37,6 @@ public:
void setListFilePath(const QString &listFilePath);
private:
void compareFile(const QString &referenceFile, const QString &archiveFile);
QString mTempFilePath;
QString mListFilePath;
KZip *mZip = nullptr;
......
/*
Copyright (C) 2020 Laurent Montel <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "comparefilehelper.h"
#include <QProcess>
#include <QTest>
void CompareFileHelper::compareFile(const QString &referenceFile, const QString &archiveFile)
{
//qDebug() << "referenceFile " << referenceFile << " archiveFile " << archiveFile;
QProcess proc;
const QStringList args = QStringList()
<< QStringLiteral("-u")
<< referenceFile
<< archiveFile;
proc.setProcessChannelMode(QProcess::ForwardedChannels);
proc.start(QStringLiteral("diff"), args);
QVERIFY(proc.waitForFinished());
QCOMPARE(proc.exitCode(), 0);
}
/*
Copyright (C) 2020 Laurent Montel <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef COMPAREFILEHELPER_H
#define COMPAREFILEHELPER_H
#include <QString>
namespace CompareFileHelper
{
void compareFile(const QString &referenceFile, const QString &archiveFile);
}
#endif // COMPAREFILEHELPER_H
......@@ -20,7 +20,7 @@
#include "compareimportfile.h"
#include "generatelistfilefromarchive.h"
#include "loadlistfromfile.h"
#include "comparefilehelper.h"
#include <QProcess>
#include <QTest>
......@@ -66,3 +66,4 @@ void CompareImportFile::setListFilePath(const QString &listFilePath)
{
mListFilePath = listFilePath;
}
......@@ -47,6 +47,7 @@ void TestImportFile::start()
qputenv("XDG_DATA_HOME", mExtractPath.toLatin1() + "/share");
qputenv("XDG_CONFIG_HOME", mExtractPath.toLatin1() + "/config");
qDebug() << " mExtractPath.toLatin1() " << mExtractPath.toLatin1() ;
QSignalSpy finish(mAbstractImportExportJob, &AbstractImportExportJob::jobFinished);
QSignalSpy error(mAbstractImportExportJob, &AbstractImportExportJob::error);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment