GUI: Update projectfile tests.
This commit is contained in:
parent
a3d6b697ad
commit
2123f6fafc
|
@ -9,9 +9,9 @@
|
||||||
<dir name="gui/"/>
|
<dir name="gui/"/>
|
||||||
<dir name="test/"/>
|
<dir name="test/"/>
|
||||||
</paths>
|
</paths>
|
||||||
<ignore>
|
<exclude>
|
||||||
<path name="gui/temp/"/>
|
<path name="gui/temp/"/>
|
||||||
</ignore>
|
</exclude>
|
||||||
<defines>
|
<defines>
|
||||||
<define name="FOO" />
|
<define name="FOO" />
|
||||||
</defines>
|
</defines>
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="1">
|
||||||
|
<root name="../.."/>
|
||||||
|
<includedir>
|
||||||
|
<dir name="lib/"/>
|
||||||
|
<dir name="cli/"/>
|
||||||
|
</includedir>
|
||||||
|
<paths>
|
||||||
|
<dir name="gui/"/>
|
||||||
|
<dir name="test/"/>
|
||||||
|
</paths>
|
||||||
|
<ignore>
|
||||||
|
<path name="gui/temp/"/>
|
||||||
|
</ignore>
|
||||||
|
<defines>
|
||||||
|
<define name="FOO" />
|
||||||
|
</defines>
|
||||||
|
</project>
|
|
@ -98,7 +98,7 @@ void TestFileList::filterFiles()
|
||||||
FileList list;
|
FileList list;
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters << "foo1.cpp" << "foo3.cc";
|
filters << "foo1.cpp" << "foo3.cc";
|
||||||
list.AddIngoreList(filters);
|
list.AddExcludeList(filters);
|
||||||
list.AddFile(QString(SRCDIR) + "/../data/files/foo1.cpp");
|
list.AddFile(QString(SRCDIR) + "/../data/files/foo1.cpp");
|
||||||
list.AddFile(QString(SRCDIR) + "/../data/files/foo2.cxx");
|
list.AddFile(QString(SRCDIR) + "/../data/files/foo2.cxx");
|
||||||
list.AddFile(QString(SRCDIR) + "/../data/files/foo3.cc");
|
list.AddFile(QString(SRCDIR) + "/../data/files/foo3.cc");
|
||||||
|
@ -119,7 +119,7 @@ void TestFileList::filterFiles2()
|
||||||
FileList list;
|
FileList list;
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters << "foo1.cpp" << "foo3.cc";
|
filters << "foo1.cpp" << "foo3.cc";
|
||||||
list.AddIngoreList(filters);
|
list.AddExcludeList(filters);
|
||||||
list.AddDirectory(QString(SRCDIR) + "/../data/files");
|
list.AddDirectory(QString(SRCDIR) + "/../data/files");
|
||||||
QStringList files = list.GetFileList();
|
QStringList files = list.GetFileList();
|
||||||
QCOMPARE(files.size(), 5);
|
QCOMPARE(files.size(), 5);
|
||||||
|
@ -134,7 +134,7 @@ void TestFileList::filterFiles3()
|
||||||
FileList list;
|
FileList list;
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters << "foo1.cpp" << "foo3.cc";
|
filters << "foo1.cpp" << "foo3.cc";
|
||||||
list.AddIngoreList(filters);
|
list.AddExcludeList(filters);
|
||||||
list.AddDirectory(QString(SRCDIR) + "/../data/files", true);
|
list.AddDirectory(QString(SRCDIR) + "/../data/files", true);
|
||||||
QStringList files = list.GetFileList();
|
QStringList files = list.GetFileList();
|
||||||
QCOMPARE(files.size(), 6);
|
QCOMPARE(files.size(), 6);
|
||||||
|
@ -151,7 +151,7 @@ void TestFileList::filterFiles4()
|
||||||
FileList list;
|
FileList list;
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters << "dir1/";
|
filters << "dir1/";
|
||||||
list.AddIngoreList(filters);
|
list.AddExcludeList(filters);
|
||||||
list.AddDirectory(QString(SRCDIR) + "/../data/files", true);
|
list.AddDirectory(QString(SRCDIR) + "/../data/files", true);
|
||||||
QStringList files = list.GetFileList();
|
QStringList files = list.GetFileList();
|
||||||
QCOMPARE(files.size(), 8);
|
QCOMPARE(files.size(), 8);
|
||||||
|
|
|
@ -42,7 +42,30 @@ void TestProjectFile::loadSimple()
|
||||||
QCOMPARE(paths.size(), 2);
|
QCOMPARE(paths.size(), 2);
|
||||||
QCOMPARE(paths[0], QString("gui/"));
|
QCOMPARE(paths[0], QString("gui/"));
|
||||||
QCOMPARE(paths[1], QString("test/"));
|
QCOMPARE(paths[1], QString("test/"));
|
||||||
QStringList ignores = pfile.GetIgnoredPaths();
|
QStringList excludes = pfile.GetExcludedPaths();
|
||||||
|
QCOMPARE(excludes.size(), 1);
|
||||||
|
QCOMPARE(excludes[0], QString("gui/temp/"));
|
||||||
|
QStringList defines = pfile.GetDefines();
|
||||||
|
QCOMPARE(defines.size(), 1);
|
||||||
|
QCOMPARE(defines[0], QString("FOO"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that project file with old 'ignore' element works
|
||||||
|
void TestProjectFile::loadSimpleWithIgnore()
|
||||||
|
{
|
||||||
|
const QString filepath(QString(SRCDIR) + "/../data/projectfiles/simple_ignore.cppcheck");
|
||||||
|
ProjectFile pfile(filepath);
|
||||||
|
QVERIFY(pfile.Read());
|
||||||
|
QCOMPARE(pfile.GetRootPath(), QString("../.."));
|
||||||
|
QStringList includes = pfile.GetIncludeDirs();
|
||||||
|
QCOMPARE(includes.size(), 2);
|
||||||
|
QCOMPARE(includes[0], QString("lib/"));
|
||||||
|
QCOMPARE(includes[1], QString("cli/"));
|
||||||
|
QStringList paths = pfile.GetCheckPaths();
|
||||||
|
QCOMPARE(paths.size(), 2);
|
||||||
|
QCOMPARE(paths[0], QString("gui/"));
|
||||||
|
QCOMPARE(paths[1], QString("test/"));
|
||||||
|
QStringList ignores = pfile.GetExcludedPaths();
|
||||||
QCOMPARE(ignores.size(), 1);
|
QCOMPARE(ignores.size(), 1);
|
||||||
QCOMPARE(ignores[0], QString("gui/temp/"));
|
QCOMPARE(ignores[0], QString("gui/temp/"));
|
||||||
QStringList defines = pfile.GetDefines();
|
QStringList defines = pfile.GetDefines();
|
||||||
|
@ -64,7 +87,7 @@ void TestProjectFile::loadSimpleNoroot()
|
||||||
QCOMPARE(paths.size(), 2);
|
QCOMPARE(paths.size(), 2);
|
||||||
QCOMPARE(paths[0], QString("gui/"));
|
QCOMPARE(paths[0], QString("gui/"));
|
||||||
QCOMPARE(paths[1], QString("test/"));
|
QCOMPARE(paths[1], QString("test/"));
|
||||||
QStringList ignores = pfile.GetIgnoredPaths();
|
QStringList ignores = pfile.GetExcludedPaths();
|
||||||
QCOMPARE(ignores.size(), 1);
|
QCOMPARE(ignores.size(), 1);
|
||||||
QCOMPARE(ignores[0], QString("gui/temp/"));
|
QCOMPARE(ignores[0], QString("gui/temp/"));
|
||||||
QStringList defines = pfile.GetDefines();
|
QStringList defines = pfile.GetDefines();
|
||||||
|
|
|
@ -26,5 +26,6 @@ class TestProjectFile: public QObject
|
||||||
private slots:
|
private slots:
|
||||||
void loadInexisting();
|
void loadInexisting();
|
||||||
void loadSimple();
|
void loadSimple();
|
||||||
|
void loadSimpleWithIgnore();
|
||||||
void loadSimpleNoroot();
|
void loadSimpleNoroot();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue