Commit 507d99f0 authored by Marco Bubke's avatar Marco Bubke Committed by Tim Jenssen

UnitTests: Use memory database

Tests get more reliable if the database is not shared between different
tests and the testing is speed up by not accessing the file system.

Change-Id: Ieb3c5495df4f0fae2293111949792774b01bf913
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 7a8d1aca
......@@ -56,7 +56,7 @@ protected:
void SetUp() override;
protected:
Sqlite::Database database{QDir::tempPath() + "/symbol.db"};
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
RefactoringDatabaseInitializer<Sqlite::Database> initializer{database};
FilePathCaching filePathCache{database};
::ClangQuery simpleFunctionQuery{filePathCache};
......
......@@ -81,7 +81,7 @@ protected:
void SetUp() override;
protected:
Sqlite::Database database{QDir::tempPath() + "/symbol.db"};
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database};
Utils::SmallString sourceContent{"#include \"query_simplefunction.h\"\nvoid f() {}"};
......
......@@ -50,7 +50,7 @@ protected:
FilePathId id(const Utils::SmallString &path);
protected:
Sqlite::Database database{QDir::tempPath() + "/symbol.db"};
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database};
ClangBackEnd::IncludeCollector collector{filePathCache};
......
......@@ -85,7 +85,7 @@ protected:
protected:
NiceMock<MockRefactoringClient> mockRefactoringClient;
NiceMock<MockSymbolIndexing> mockSymbolIndexing;
Sqlite::Database database{QDir::tempPath() + "/symbol.db"};
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database};
ClangBackEnd::RefactoringServer refactoringServer{mockSymbolIndexing, filePathCache};
......
......@@ -60,7 +60,7 @@ protected:
TestClangTool clangTool{TESTDATA_DIR, "sourcerangeextractor_location.cpp", "", {"cc", "sourcerangeextractor_location.cpp"}};
ClangBackEnd::SourceRangesContainer sourceRangesContainer;
const clang::SourceManager &sourceManager{clangTool.sourceManager()};
Sqlite::Database database{QDir::tempPath() + "/symbol.db"};
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database};
ClangBackEnd::SourceRangeExtractor extractor{sourceManager, clangTool.languageOptions(), filePathCache, sourceRangesContainer};
......
......@@ -71,7 +71,7 @@ protected:
void TearDown() override;
protected:
Database database;
Database database{":memory:", Sqlite::JournalMode::Memory};
};
struct Output
......@@ -619,8 +619,6 @@ TEST_F(SqliteStatement, GetValuesWithTupleArgumentsCallsResetIfExceptionIsThrown
void SqliteStatement::SetUp()
{
database.setJournalMode(JournalMode::Memory);
database.open(":memory:");
database.execute("CREATE TABLE test(name TEXT UNIQUE, number NUMERIC, value NUMERIC)");
database.execute("INSERT INTO test VALUES ('bar', 'blah', 1)");
database.execute("INSERT INTO test VALUES ('foo', 23.3, 2)");
......
......@@ -75,7 +75,7 @@ protected:
FilePathId filePathId(Utils::SmallString filePath);
protected:
Sqlite::Database database{QDir::tempPath() + "/symbol.db"};
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
RefactoringDatabaseInitializer<Sqlite::Database> initializer{database};
FilePathCaching filePathCache{database};
ClangBackEnd::SymbolIndexing indexing{database, filePathCache};
......
......@@ -30,6 +30,7 @@
#include <symbolscollector.h>
#include <filepathcaching.h>
#include <refactoringdatabaseinitializer.h>
#include <QDir>
......@@ -66,7 +67,8 @@ protected:
SymbolIndex symbolIdForSymbolName(const Utils::SmallString &symbolName);
protected:
Sqlite::Database database{QDir::tempPath() + "/symbol.db"};
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> initializer{database};
FilePathCaching filePathCache{database};
ClangBackEnd::SymbolsCollector collector{filePathCache};
};
......
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