test: Fixed tests
This commit is contained in:
+1
-2
@@ -79,7 +79,7 @@ void Project::parseCode()
|
||||
|
||||
std::shared_ptr<ProjectSettings> projSettings = ProjectSettings::getInstance();
|
||||
|
||||
m_fileManager.fetchFilePaths();
|
||||
m_fileManager.fetchFilePaths(m_storage->getInfoOnAllFiles());
|
||||
std::set<FilePath> addedFilePaths = m_fileManager.getAddedFilePaths();
|
||||
std::set<FilePath> updatedFilePaths = m_fileManager.getUpdatedFilePaths();
|
||||
std::set<FilePath> removedFilePaths = m_fileManager.getRemovedFilePaths();
|
||||
@@ -178,6 +178,5 @@ Parser::Arguments Project::getParserArguments() const
|
||||
|
||||
Project::Project(StorageAccessProxy* storageAccessProxy)
|
||||
: m_storageAccessProxy(storageAccessProxy)
|
||||
, m_fileManager(storageAccessProxy)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ void SqliteStorage::clear()
|
||||
{
|
||||
m_database.execDML("PRAGMA foreign_keys=OFF;");
|
||||
clearTables();
|
||||
|
||||
setup();
|
||||
}
|
||||
|
||||
void SqliteStorage::beginTransaction()
|
||||
|
||||
@@ -6,6 +6,12 @@ FileInfo::FileInfo()
|
||||
{
|
||||
}
|
||||
|
||||
FileInfo::FileInfo(const FilePath& path)
|
||||
: path(path)
|
||||
, lastWriteTime(boost::posix_time::not_a_date_time)
|
||||
{
|
||||
}
|
||||
|
||||
FileInfo::FileInfo(const FilePath& path, boost::posix_time::ptime lastWriteTime)
|
||||
: path(path)
|
||||
, lastWriteTime(lastWriteTime)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
struct FileInfo
|
||||
{
|
||||
FileInfo();
|
||||
FileInfo(const FilePath& path);
|
||||
FileInfo(const FilePath& path, boost::posix_time::ptime lastWriteTime);
|
||||
|
||||
FilePath path;
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/utility.h"
|
||||
#include "data/access/StorageAccessProxy.h"
|
||||
|
||||
FileManager::FileManager(StorageAccessProxy* storageAccessProxy)
|
||||
: m_storageAccessProxy(storageAccessProxy)
|
||||
FileManager::FileManager()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -47,9 +45,9 @@ void FileManager::reset()
|
||||
m_removedFiles.clear();
|
||||
}
|
||||
|
||||
void FileManager::fetchFilePaths()
|
||||
void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
{
|
||||
for (FileInfo oldFileInfo: m_storageAccessProxy->getInfoOnAllFiles())
|
||||
for (FileInfo oldFileInfo: oldFileInfos)
|
||||
{
|
||||
m_files[oldFileInfo.path] = oldFileInfo;
|
||||
}
|
||||
|
||||
@@ -7,12 +7,10 @@
|
||||
|
||||
#include "utility/file/FileInfo.h"
|
||||
|
||||
class StorageAccessProxy;
|
||||
|
||||
class FileManager
|
||||
{
|
||||
public:
|
||||
FileManager(StorageAccessProxy* storageAccessProxy);
|
||||
FileManager();
|
||||
virtual ~FileManager();
|
||||
|
||||
const std::vector<FilePath>& getSourcePaths() const;
|
||||
@@ -26,7 +24,7 @@ public:
|
||||
);
|
||||
|
||||
void reset();
|
||||
void fetchFilePaths();
|
||||
void fetchFilePaths(const std::vector<FileInfo>& oldFileInfos);
|
||||
|
||||
std::set<FilePath> getAddedFilePaths() const;
|
||||
std::set<FilePath> getUpdatedFilePaths() const;
|
||||
@@ -51,8 +49,6 @@ private:
|
||||
std::set<FilePath> m_addedFiles;
|
||||
std::set<FilePath> m_updatedFiles;
|
||||
std::set<FilePath> m_removedFiles;
|
||||
|
||||
StorageAccessProxy* m_storageAccessProxy;
|
||||
};
|
||||
|
||||
#endif // FILE_MANAGER_H
|
||||
|
||||
@@ -1954,7 +1954,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->templateSpecializations.size(), 1);
|
||||
TS_ASSERT_EQUALS(client->templateSpecializations[0], "class A<int> -> A<typename T> <2:7 2:7>");
|
||||
TS_ASSERT_EQUALS(client->templateSpecializations[0], "class A<int> -> A<typename T> <7:8 7:8>");
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_class_inheritance_from_implicit_template_class_specialization()
|
||||
@@ -2706,16 +2706,16 @@ private:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual Id onFileParsed(const std::string& filePath)
|
||||
virtual Id onFileParsed(const FileInfo& fileInfo)
|
||||
{
|
||||
files.push_back(filePath);
|
||||
files.push_back(fileInfo.path.str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual Id onFileIncludeParsed(
|
||||
const ParseLocation& location, const std::string& filePath, const std::string& includedPath)
|
||||
const ParseLocation& location, const FileInfo& fileInfo, const FileInfo& includedFileInfo)
|
||||
{
|
||||
includes.push_back(filePath + " -> " + includedPath);
|
||||
includes.push_back(fileInfo.path.str() + " -> " + includedFileInfo.path.str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
|
||||
FileManager fm;
|
||||
fm.setPaths(sourcePaths, includePaths, sourceExtensions, includeExtensions);
|
||||
fm.fetchFilePaths();
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
|
||||
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 4);
|
||||
}
|
||||
@@ -49,8 +49,8 @@ public:
|
||||
|
||||
FileManager fm;
|
||||
fm.setPaths(sourcePaths, includePaths, sourceExtensions, includeExtensions);
|
||||
fm.fetchFilePaths();
|
||||
fm.fetchFilePaths();
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
|
||||
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 0);
|
||||
}
|
||||
@@ -70,14 +70,14 @@ public:
|
||||
|
||||
FileManager fm;
|
||||
fm.setPaths(sourcePaths, includePaths, sourceExtensions, includeExtensions);
|
||||
fm.fetchFilePaths();
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
|
||||
std::fstream fileStream;
|
||||
fileStream.open("./data/FileManagerTestSuite/include/c.h");
|
||||
fileStream << "update";
|
||||
fileStream.close();
|
||||
|
||||
fm.fetchFilePaths();
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
|
||||
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 0);
|
||||
TS_ASSERT_EQUALS(fm.getUpdatedFilePaths().size(), 1);
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
|
||||
FileManager fm;
|
||||
fm.setPaths(sourcePaths, includePaths, sourceExtensions, includeExtensions);
|
||||
fm.fetchFilePaths();
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
|
||||
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 2);
|
||||
TS_ASSERT_EQUALS(fm.getUpdatedFilePaths().size(), 0);
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
sourcePaths[0] = "./data/FileManagerTestSuite/src/d.c";
|
||||
|
||||
fm.setPaths(sourcePaths, includePaths, sourceExtensions, includeExtensions);
|
||||
fm.fetchFilePaths();
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
|
||||
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 1);
|
||||
TS_ASSERT_EQUALS(fm.getUpdatedFilePaths().size(), 0);
|
||||
|
||||
@@ -321,7 +321,7 @@ public:
|
||||
|
||||
storage.onMethodOverrideParsed(validLocation(4), a, b);
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_OVERRIDE) + ":A::isMethod->B::isMethod") != 0);
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_OVERRIDE) + ":B::isMethod->A::isMethod") != 0);
|
||||
}
|
||||
|
||||
void test_storage_saves_call()
|
||||
@@ -549,7 +549,7 @@ public:
|
||||
{
|
||||
TestStorage storage;
|
||||
|
||||
Id id = storage.onFileParsed("file.h");
|
||||
Id id = storage.onFileParsed(FileInfo("file.h"));
|
||||
|
||||
TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "file.h");
|
||||
TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_FILE);
|
||||
@@ -559,9 +559,9 @@ public:
|
||||
{
|
||||
TestStorage storage;
|
||||
|
||||
storage.onFileParsed("file.h");
|
||||
storage.onFileParsed("file.cpp");
|
||||
Id id = storage.onFileIncludeParsed(validLocation(7), "file.cpp", "file.h");
|
||||
storage.onFileParsed(FileInfo("file.h"));
|
||||
storage.onFileParsed(FileInfo("file.cpp"));
|
||||
Id id = storage.onFileIncludeParsed(validLocation(7), FileInfo("file.cpp"), FileInfo("file.h"));
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_INCLUDE) + ":file.cpp->file.h") != 0);
|
||||
|
||||
@@ -601,6 +601,12 @@ private:
|
||||
: public Storage
|
||||
{
|
||||
public:
|
||||
TestStorage()
|
||||
: Storage("data/test.sqlite")
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
TokenLocationCollection getLocationCollectionForTokenId(Id id) const
|
||||
{
|
||||
std::vector<Id> tokenIds;
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
#include "data/parser/cxx/CxxParser.h"
|
||||
#include "TestFileManager.h"
|
||||
|
||||
TestStorage::TestStorage()
|
||||
: Storage("data/test.sqlite")
|
||||
{
|
||||
}
|
||||
|
||||
void TestStorage::parseCxxCode(std::string code)
|
||||
{
|
||||
clear();
|
||||
|
||||
@@ -7,6 +7,7 @@ class TestStorage
|
||||
: public Storage
|
||||
{
|
||||
public:
|
||||
TestStorage();
|
||||
void parseCxxCode(std::string code);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user