From 4aa819bdbeebd4335d6fab2c6c868f516b28429b Mon Sep 17 00:00:00 2001
From: Vladimir Davydov <vdavydov@tarantool.org>
Date: Fri, 3 Nov 2023 21:08:11 +0300
Subject: [PATCH] test: move Lua tests from /static-build/test to /test/app-tap

The tests are TAP compatible and applicable to all Tarantool builds so
there's no need to run them with ctest. We just need to add a couple
skip conditions:
 - The luarocks test shouldn't be run on dynamic builds because luarocks
   modules aren't embedded there.
 - The traceback test should be run only if ENABLE_BACKTRACE was set at
   build time.

Part of #9242

NO_DOC=refactoring
NO_TEST=refactoring
NO_CHANGELOG=refactoring

(cherry picked from commit 1eb98ef357a4dcc21c0f0d796fd999661f5cf560)
---
 static-build/cmake/AddTests.cmake              | 18 ------------------
 .../test => test/app-tap}/exports.test.lua     |  0
 .../test => test/app-tap}/luarocks.test.lua    |  8 ++++++++
 .../test => test/app-tap}/traceback.test.lua   | 10 ++++++++++
 4 files changed, 18 insertions(+), 18 deletions(-)
 rename {static-build/test => test/app-tap}/exports.test.lua (100%)
 rename {static-build/test => test/app-tap}/luarocks.test.lua (88%)
 rename {static-build/test => test/app-tap}/traceback.test.lua (56%)

diff --git a/static-build/cmake/AddTests.cmake b/static-build/cmake/AddTests.cmake
index 14abb975d2..90602c8c09 100644
--- a/static-build/cmake/AddTests.cmake
+++ b/static-build/cmake/AddTests.cmake
@@ -6,21 +6,3 @@ add_test(
         -D FILE=${TARANTOOL_BINARY}
         -P ${CMAKE_CURRENT_LIST_DIR}/CheckDependencies.cmake
 )
-
-add_test(
-    NAME check-exports
-    COMMAND ${TARANTOOL_BINARY}
-            ${CMAKE_CURRENT_LIST_DIR}/../test/exports.test.lua
-)
-
-add_test(
-    NAME check-traceback
-    COMMAND ${TARANTOOL_BINARY}
-            ${CMAKE_CURRENT_LIST_DIR}/../test/traceback.test.lua
-)
-
-add_test(
-    NAME check-luarocks
-    COMMAND ${TARANTOOL_BINARY}
-            ${CMAKE_CURRENT_LIST_DIR}/../test/luarocks.test.lua
-)
diff --git a/static-build/test/exports.test.lua b/test/app-tap/exports.test.lua
similarity index 100%
rename from static-build/test/exports.test.lua
rename to test/app-tap/exports.test.lua
diff --git a/static-build/test/luarocks.test.lua b/test/app-tap/luarocks.test.lua
similarity index 88%
rename from static-build/test/luarocks.test.lua
rename to test/app-tap/luarocks.test.lua
index 303e679d14..02fdf60126 100755
--- a/static-build/test/luarocks.test.lua
+++ b/test/app-tap/luarocks.test.lua
@@ -1,8 +1,16 @@
 #!/usr/bin/env tarantool
 
 local tap = require('tap')
+local tarantool = require('tarantool')
+
 local test = tap.test('embedded-luarocks')
 
+if tarantool.build.linking == 'dynamic' then
+    test:plan(1)
+    test:skip('luarocks is not embedded in dynamic build')
+    os.exit(0)
+end
+
 test:plan(3)
 
 local function find_luarocks_modules(tbl)
diff --git a/static-build/test/traceback.test.lua b/test/app-tap/traceback.test.lua
similarity index 56%
rename from static-build/test/traceback.test.lua
rename to test/app-tap/traceback.test.lua
index 32e1ed8b5b..87a51fb23e 100755
--- a/static-build/test/traceback.test.lua
+++ b/test/app-tap/traceback.test.lua
@@ -1,9 +1,19 @@
 #!/usr/bin/env tarantool
 
 local tap = require('tap')
+local tarantool = require('tarantool')
 local fiber = require('fiber')
 
 local test = tap.test('traceback')
+
+local _, _, enable_bt = string.find(tarantool.build.options,
+                                    '-DENABLE_BACKTRACE=(%a+)')
+if enable_bt == 'FALSE' then
+    test:plan(1)
+    test:skip('backtrace is disabled')
+    os.exit(0)
+end
+
 test:plan(1)
 
 local info = fiber.info()[fiber.id()]
-- 
GitLab