Skip to content

Commit b9343a7

Browse files
authoredSep 28, 2018
Fix temporary path crash in TestAuthDatabase (#7753)
The constructor of TestAuthDatabase was called immediately, at a time when the settings weren't initialized properly yet.
1 parent ce2d33e commit b9343a7

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed
 

‎src/unittest/test_authdatabase.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,7 @@ class SQLite3Provider : public AuthDatabaseProvider
9090
class TestAuthDatabase : public TestBase
9191
{
9292
public:
93-
TestAuthDatabase()
94-
{
95-
TestManager::registerTestModule(this);
96-
// fixed directory, for persistence
97-
test_dir = getTestTempDirectory();
98-
}
93+
TestAuthDatabase() { TestManager::registerTestModule(this); }
9994
const char *getName() { return "TestAuthDatabase"; }
10095

10196
void runTests(IGameDef *gamedef);
@@ -112,14 +107,16 @@ class TestAuthDatabase : public TestBase
112107
void testDelete();
113108

114109
private:
115-
std::string test_dir;
116110
AuthDatabaseProvider *auth_provider;
117111
};
118112

119113
static TestAuthDatabase g_test_instance;
120114

121115
void TestAuthDatabase::runTests(IGameDef *gamedef)
122116
{
117+
// fixed directory, for persistence
118+
thread_local const std::string test_dir = getTestTempDirectory();
119+
123120
// Each set of tests is run twice for each database type:
124121
// one where we reuse the same AuthDatabase object (to test local caching),
125122
// and one where we create a new AuthDatabase object for each call

0 commit comments

Comments
 (0)
Please sign in to comment.