Skip to content

Commit 56cc2bb

Browse files
committed
Merge pull request godotengine#105848 from leandro-benedet-garcia/delete_cache
Delete test cache before running it
2 parents 59cd4b8 + ed35b9e commit 56cc2bb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/test_main.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
#include "test_main.h"
3232

33+
#include "core/error/error_macros.h"
34+
#include "core/io/dir_access.h"
3335
#include "modules/modules_enabled.gen.h"
3436

3537
#ifdef TOOLS_ENABLED
@@ -232,6 +234,15 @@ int test_main(int argc, char *argv[]) {
232234

233235
WorkerThreadPool::get_singleton()->init();
234236

237+
String test_path = OS::get_singleton()->get_cache_path().path_join("godot_test");
238+
239+
Ref<DirAccess> da;
240+
if (DirAccess::exists(test_path)) {
241+
da = DirAccess::open(test_path);
242+
ERR_FAIL_COND_V(da.is_null(), 0);
243+
ERR_FAIL_COND_V_MSG(da->erase_contents_recursive() != OK, 0, "Failed to delete files");
244+
}
245+
235246
// Run custom test tools.
236247
if (test_commands) {
237248
for (const KeyValue<String, TestFunc> &E : (*test_commands)) {

0 commit comments

Comments
 (0)