From 9b0896d9e63143ce4e894365639c431f682b2958 Mon Sep 17 00:00:00 2001
From: Gleb Kashkin <g.kashkin@tarantool.org>
Date: Sun, 3 Sep 2023 19:06:25 +0000
Subject: [PATCH] test: make treegen.clean more durable

Usually treegen.clean is called after a test by g.after_all function
or an equivalent. In some rare cases internal helpers use their own
treegen and clean up after themself. In such a case, treegen.clean
would look for an internal list of all directories and find nil. This
causes an error in ipairs iteration in internal logic and fails the
whole test.

This patch adds minor durability improvement for such a case. Now if
internal list of all directories is nil (e.g. when treegen.clean was
called beforehand), the function does nothing.

Part of #8967

NO_DOC=test helper update
NO_CHANGELOG=see NO_DOC
NO_TEST=see NO_DOC
---
 test/treegen.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/treegen.lua b/test/treegen.lua
index 987ff20df4..5d41065f56 100644
--- a/test/treegen.lua
+++ b/test/treegen.lua
@@ -79,7 +79,7 @@ end
 -- unless KEEP_DATA environment variable is set to a
 -- non-empty value.
 function treegen.clean(g)
-    local dirs = table.copy(g.tempdirs)
+    local dirs = table.copy(g.tempdirs) or {}
     g.tempdirs = nil
 
     local keep_data = (os.getenv('KEEP_DATA') or '') ~= ''
-- 
GitLab