aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2019-07-10 14:48:30 +0200
committerMarco Bubke <marco.bubke@qt.io>2019-07-11 09:02:43 +0000
commit56277de27f0753e52482a302d9a43b230268f59d (patch)
tree82d31a231a64f14951b27dab265b1ba1fc81fa48 /tests
parentd7e5935396d07de26f799e7e39987d8330916db2 (diff)
ClangPchManager: Protect fetchPchSources
It was not protected by a transaction so it was not thread save. Change-Id: Ib4529d0e94942d3cbafb46705a0256812908c8c6 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/unittest/builddependenciesstorage-test.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unit/unittest/builddependenciesstorage-test.cpp b/tests/unit/unittest/builddependenciesstorage-test.cpp
index 56f8b42ac5..b542fd3082 100644
--- a/tests/unit/unittest/builddependenciesstorage-test.cpp
+++ b/tests/unit/unittest/builddependenciesstorage-test.cpp
@@ -251,6 +251,32 @@ TEST_F(BuildDependenciesStorage, FetchPchSources)
ASSERT_THAT(sources, result);
}
+TEST_F(BuildDependenciesStorage, FetchPchSourcesCalls)
+{
+ InSequence s;
+
+ EXPECT_CALL(mockDatabase, deferredBegin());
+ EXPECT_CALL(fetchPchSourcesStatement, valuesReturnFilePathIds(_, 22));
+ EXPECT_CALL(mockDatabase, commit());
+
+ auto sources = storage.fetchPchSources(22);
+}
+
+TEST_F(BuildDependenciesStorage, FetchPchSourcesCallsIsBusy)
+{
+ InSequence s;
+
+ EXPECT_CALL(mockDatabase, deferredBegin());
+ EXPECT_CALL(fetchPchSourcesStatement, valuesReturnFilePathIds(_, 22))
+ .WillOnce(Throw(Sqlite::StatementIsBusy{""}));
+ EXPECT_CALL(mockDatabase, rollback());
+ EXPECT_CALL(mockDatabase, deferredBegin());
+ EXPECT_CALL(fetchPchSourcesStatement, valuesReturnFilePathIds(_, 22));
+ EXPECT_CALL(mockDatabase, commit());
+
+ auto sources = storage.fetchPchSources(22);
+}
+
TEST_F(BuildDependenciesStorage, FetchSources)
{
ClangBackEnd::FilePathIds result{3, 5, 7};