Commit 576756cb authored by Michael Reeves's avatar Michael Reeves

Revert dfd04d09 add more testing

parent edc27113
Pipeline #12839 passed with stage
in 6 minutes and 49 seconds
......@@ -18,11 +18,15 @@
*/
#include <QTest>
#include <qglobal.h>
#include "../cvsignorelist.h"
class CvsIgnoreListTest : public QObject
{
const QString defaultPatterns = QString::fromLatin1(". .. core RCSLOG tags TAGS RCS SCCS .make.state "
".nse_depinfo #* .#* cvslog.* ,* CVS CVS.adm .del-* *.a *.olb *.o *.obj "
"*.so *.Z *~ *.old *.elc *.ln *.bak *.BAK *.orig *.rej *.exe _$* *$");
Q_OBJECT
private Q_SLOTS:
void init()
......@@ -35,16 +39,44 @@ class CvsIgnoreListTest : public QObject
QVERIFY(test.m_startPatterns.isEmpty());
}
void addEntriesFromString()
{
CvsIgnoreList test;
QStringList expected;
CvsIgnoreList expected;
test.addEntriesFromString(". .. core RCSLOG tags TAGS RCS SCCS .make.state");
expected = QStringList{".", "..", "core", "RCSLOG", "tags", "TAGS", "RCS", "SCCS", ".make.state"};
QString testString = ". .. core RCSLOG tags TAGS RCS SCCS .make.state";
test.addEntriesFromString(testString);
QVERIFY(!test.m_exactPatterns.isEmpty());
QVERIFY(test.m_exactPatterns == expected);
QVERIFY(test.m_exactPatterns == testString.split(' '));
expected = test = CvsIgnoreList();
}
void testDefaults()
{
CvsIgnoreList test;
CvsIgnoreList expected;
MocIgnoreFile file;
t_DirectoryList dirList;
/*
Verify default init. For this to work we must:
1. Unset CVSIGNORE
2. Insure no patterns are read from a .cvsignore file.
MocCvsIgnore emulates a blank cvs file by default insuring the second condition.
*/
test = CvsIgnoreList();
//
qunsetenv("CVSIGNORE");
expected.addEntriesFromString(defaultPatterns);
test.init(file, &dirList);
QVERIFY(test.m_endPatterns == expected.m_endPatterns);
QVERIFY(test.m_exactPatterns == expected.m_exactPatterns);
QVERIFY(test.m_startPatterns == expected.m_startPatterns);
QVERIFY(test.m_generalPatterns == expected.m_generalPatterns);
}
};
......
......@@ -19,12 +19,13 @@
void CvsIgnoreList::init(FileAccess& dir, const t_DirectoryList* pDirList)
{
static const QStringList ignorestr = QStringList{".", ".. core", "RCSLOG", "tags", "TAGS", "RCS", "SCCS", ".make.state",
".nse_depinfo", "#* .#* cvslog.*", ",* CVS", "CVS.adm", ".del-*", "*.a", "*.olb", "*.o", "*.obj",
"*.so", "*.Z", "*~ *.old", "*.elc *.ln", "*.bak", "*.BAK", "*.orig", "*.rej", "*.exe", "_$*", "*$"};
static const QString ignorestr = QString::fromLatin1(". .. core RCSLOG tags TAGS RCS SCCS .make.state "
".nse_depinfo #* .#* cvslog.* ,* CVS CVS.adm .del-* *.a *.olb *.o *.obj "
"*.so *.Z *~ *.old *.elc *.ln *.bak *.BAK *.orig *.rej *.exe _$* *$");
constexpr char varname[] = "CVSIGNORE";
addEntriesFromList(ignorestr);
addEntriesFromString(ignorestr);
addEntriesFromFile(QDir::homePath() + "/.cvsignore");
if(qEnvironmentVariableIsSet(varname) && !qEnvironmentVariableIsEmpty(varname))
{
......@@ -46,14 +47,6 @@ void CvsIgnoreList::init(FileAccess& dir, const t_DirectoryList* pDirList)
}
}
void CvsIgnoreList::addEntriesFromList(const QStringList& patternList)
{
for(const QString& pattern : patternList)
{
addEntry(pattern);
}
}
void CvsIgnoreList::addEntriesFromString(const QString& str)
{
QStringList patternList = str.split(' ');
......@@ -160,6 +153,7 @@ bool CvsIgnoreList::matches(const QString& text, bool bCaseSensitive) const
{
if(text.mid(text.length() - endPattern.length()) == endPattern) //(text.endsWith(*it))
{
Q_ASSERT(text.endsWith(endPattern));
return true;
}
}
......
......@@ -20,8 +20,8 @@
#include "MocIgnoreFile.h"
#endif
#include <QStringList>
#include <QString>
#include <QStringList>
class CvsIgnoreList
{
......@@ -34,7 +34,6 @@ class CvsIgnoreList
friend class CvsIgnoreListTest;
bool cvsIgnoreExists(const t_DirectoryList* pDirList);
void addEntriesFromList(const QStringList& patternList);
void addEntriesFromString(const QString& str);
void addEntriesFromFile(const QString& name);
void addEntry(const QString& pattern);
......
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