aboutsummaryrefslogtreecommitdiff
path: root/src/unittest/test_authdatabase.cpp
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2018-09-28 20:12:11 +0200
committerGitHub <noreply@github.com>2018-09-28 20:12:11 +0200
commitb9343a7da4b02f48ed298c5d352f4fbcda585822 (patch)
tree44172ff76c4370971852eb6583ed9eb14859c4c7 /src/unittest/test_authdatabase.cpp
parentce2d33eb97238e2e050d065a8f0838749a0b31d0 (diff)
downloadminetest-b9343a7da4b02f48ed298c5d352f4fbcda585822.tar.gz
minetest-b9343a7da4b02f48ed298c5d352f4fbcda585822.tar.bz2
minetest-b9343a7da4b02f48ed298c5d352f4fbcda585822.zip
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.
Diffstat (limited to 'src/unittest/test_authdatabase.cpp')
-rw-r--r--src/unittest/test_authdatabase.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/unittest/test_authdatabase.cpp b/src/unittest/test_authdatabase.cpp
index 1e8fd233d..1e1744d40 100644
--- a/src/unittest/test_authdatabase.cpp
+++ b/src/unittest/test_authdatabase.cpp
@@ -90,12 +90,7 @@ private:
class TestAuthDatabase : public TestBase
{
public:
- TestAuthDatabase()
- {
- TestManager::registerTestModule(this);
- // fixed directory, for persistence
- test_dir = getTestTempDirectory();
- }
+ TestAuthDatabase() { TestManager::registerTestModule(this); }
const char *getName() { return "TestAuthDatabase"; }
void runTests(IGameDef *gamedef);
@@ -112,7 +107,6 @@ public:
void testDelete();
private:
- std::string test_dir;
AuthDatabaseProvider *auth_provider;
};
@@ -120,6 +114,9 @@ static TestAuthDatabase g_test_instance;
void TestAuthDatabase::runTests(IGameDef *gamedef)
{
+ // fixed directory, for persistence
+ thread_local const std::string test_dir = getTestTempDirectory();
+
// Each set of tests is run twice for each database type:
// one where we reuse the same AuthDatabase object (to test local caching),
// and one where we create a new AuthDatabase object for each call