2
0
Эх сурвалжийг харах

Merge pull request #105848 from leandro-benedet-garcia/delete_cache

Delete test cache before running it
Thaddeus Crews 3 сар өмнө
parent
commit
56cc2bb68a
1 өөрчлөгдсөн 11 нэмэгдсэн , 0 устгасан
  1. 11 0
      tests/test_main.cpp

+ 11 - 0
tests/test_main.cpp

@@ -30,6 +30,8 @@
 
 #include "test_main.h"
 
+#include "core/error/error_macros.h"
+#include "core/io/dir_access.h"
 #include "modules/modules_enabled.gen.h"
 
 #ifdef TOOLS_ENABLED
@@ -232,6 +234,15 @@ int test_main(int argc, char *argv[]) {
 
 	WorkerThreadPool::get_singleton()->init();
 
+	String test_path = OS::get_singleton()->get_cache_path().path_join("godot_test");
+
+	Ref<DirAccess> da;
+	if (DirAccess::exists(test_path)) {
+		da = DirAccess::open(test_path);
+		ERR_FAIL_COND_V(da.is_null(), 0);
+		ERR_FAIL_COND_V_MSG(da->erase_contents_recursive() != OK, 0, "Failed to delete files");
+	}
+
 	// Run custom test tools.
 	if (test_commands) {
 		for (const KeyValue<String, TestFunc> &E : (*test_commands)) {