1
1
# Test suite that has been added from PUC-Rio Lua 5.1 test archive
2
- # in scope of https://github.com/tarantool/tarantool/issues/4473 .
2
+ # in scope of https://github.com/tarantool/tarantool/issues/5845 .
3
3
4
4
# See the rationale in the root CMakeLists.txt.
5
5
cmake_minimum_required (VERSION 3.1 FATAL_ERROR )
6
6
7
- set (TEST_RUNNER ${CMAKE_CURRENT_SOURCE_DIR} /all.lua )
8
- set (LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR} /libs )
9
- set (TESTLIB_PATH ${CMAKE_CURRENT_BINARY_DIR} /libs )
10
-
11
- # XXX: -fPIC is required to linking with static library.
12
- if (NOT BUILDMODE STREQUAL "static" )
13
- # Build additional C libraries for tests.
14
- macro (build_lib lib sources )
15
- add_library (${lib} SHARED EXCLUDE_FROM_ALL ${sources} )
16
- target_include_directories (${lib} PRIVATE
17
- ${LUAJIT_SOURCE_DIR}
18
- )
19
- set_target_properties (${lib} PROPERTIES
20
- LIBRARY_OUTPUT_DIRECTORY "${TESTLIB_PATH} "
21
- PREFIX ""
22
- )
23
- if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
24
- set_target_properties (${lib} PROPERTIES
25
- LINK_FLAGS "-undefined dynamic_lookup"
26
- )
27
- endif ()
28
- target_link_libraries (${lib} PRIVATE libluajit_shared )
29
- list (APPEND TESTLIBS ${lib} )
30
- endmacro ()
31
-
32
- build_lib (lib1 ${LIB_SOURCES} /lib1.c )
33
- build_lib (lib11 ${LIB_SOURCES} /lib1.c ${LIB_SOURCES} /lib11.c )
34
- build_lib (lib2 ${LIB_SOURCES} /lib2.c )
35
- build_lib (lib21 ${LIB_SOURCES} /lib2.c ${LIB_SOURCES} /lib21.c )
36
-
37
- set (LIB2COPY "${TESTLIB_PATH} /lib2${CMAKE_SHARED_LIBRARY_SUFFIX} " )
38
- set (LIB_COPY "${TESTLIB_PATH} /-lib2${CMAKE_SHARED_LIBRARY_SUFFIX} " )
39
-
40
- add_custom_command (
41
- COMMENT "Copping lib2 to -lib2 for PUC-Rio Lua 5.1 tests"
42
- OUTPUT ${LIB_COPY}
43
- DEPENDS ${TESTLIBS}
44
- COMMAND ${CMAKE_COMMAND} -E copy ${LIB2COPY} ${LIB_COPY}
45
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
46
- )
47
- list (APPEND TESTLIBS ${LIB_COPY} )
48
- endif ()
49
-
50
- set (CUSTOM_TEST_DIR ${TESTLIB_PATH} /P1 )
51
- add_custom_command (
52
- COMMENT "Create directory for PUC-Rio Lua 5.1 tests"
53
- OUTPUT ${CUSTOM_TEST_DIR}
54
- COMMAND ${CMAKE_COMMAND} -E make_directory ${CUSTOM_TEST_DIR}
55
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
56
- )
57
-
7
+ add_subdirectory (libs )
8
+
9
+ # XXX: There are two ways to set up the proper environment in
10
+ # the suite README:
11
+ # * set LUA_PATH to "?;./?.lua"
12
+ # * or, better yet, set LUA_PATH to "./?.lua;;" and LUA_INIT to
13
+ # "package.path = '?;'..package.path"
14
+ # Unfortunately, Tarantool doesn't support LUA_INIT and most
15
+ # likely it never will. For more info, see
16
+ # https://github.com/tarantool/tarantool/issues/5744
17
+ # Hence, there is no way other than set LUA_PATH environment
18
+ # variable as proposed in the first case.
58
19
set (LUA_PATH "?\; ${CMAKE_CURRENT_SOURCE_DIR} /?.lua" )
20
+ # XXX: All libraries required for the tests are built in libs
21
+ # directory. To use them in the suite being run in the current
22
+ # working directory, LUA_CPATH has to be adjusted.
23
+ set (LUA_CPATH "${CMAKE_CURRENT_BINARY_DIR} /libs/?${CMAKE_SHARED_LIBRARY_SUFFIX} " )
59
24
60
25
# TODO: PUC-Rio Lua 5.1 test suite also has special header
61
26
# <ltests.h> and <ltests.c> translation unit to check some
@@ -64,25 +29,17 @@ set(LUA_PATH "?\;${CMAKE_CURRENT_SOURCE_DIR}/?.lua")
64
29
# consistency and also contains tests for yield in hooks
65
30
# and for the Lua C API.
66
31
# But, unfortunately, <ltests.c> depends on specific PUC-Rio Lua 5.1
67
- # internal headers and should be adopted for LuaJIT.
68
-
69
- add_custom_target (PUC-Lua-5.1-tests
70
- DEPENDS ${LUAJIT_TEST_BINARY} ${TESTLIBS} ${CUSTOM_TEST_DIR}
71
- )
32
+ # internal headers and should be adapted for LuaJIT.
72
33
34
+ add_custom_target (PUC-Lua-5.1-tests DEPENDS ${LUAJIT_TEST_BINARY}
35
+ PUC-Lua-5.1-tests-prepare )
73
36
add_custom_command (TARGET PUC-Lua-5.1-tests
74
37
COMMENT "Running PUC-Rio Lua 5.1 tests"
75
38
COMMAND
76
39
env
77
- # Tarantool doesn't support LUA_INIT and most likely it
78
- # never will.
79
- # See https://github.com/tarantool/tarantool/issues/5744
80
- # for more info.
81
- # LUA_PATH="${CMAKE_CURRENT_BINARY_DIR}/?.lua\;\;"
82
- # LUA_INIT="package.path='?\;'..package.path"
83
- # So use less preferable way for tests.
84
40
LUA_PATH= "${LUA_PATH} \;\; "
85
- ${LUAJIT_TEST_COMMAND} ${TEST_RUNNER}
41
+ LUA_CPATH= "${LUA_CPATH} \;\; "
42
+ ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR} /all.lua
86
43
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
87
44
)
88
45
0 commit comments