Skip to content

Commit c0c53e8

Browse files
committed
fixup-1
1 parent 19e526e commit c0c53e8

File tree

2 files changed

+73
-65
lines changed

2 files changed

+73
-65
lines changed

test/PUC-Lua-5.1-tests/CMakeLists.txt

Lines changed: 22 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,26 @@
11
# 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.
33

44
# See the rationale in the root CMakeLists.txt.
55
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
66

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.
5819
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}")
5924

6025
# TODO: PUC-Rio Lua 5.1 test suite also has special header
6126
# <ltests.h> and <ltests.c> translation unit to check some
@@ -64,25 +29,17 @@ set(LUA_PATH "?\;${CMAKE_CURRENT_SOURCE_DIR}/?.lua")
6429
# consistency and also contains tests for yield in hooks
6530
# and for the Lua C API.
6631
# 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.
7233

34+
add_custom_target(PUC-Lua-5.1-tests DEPENDS ${LUAJIT_TEST_BINARY}
35+
PUC-Lua-5.1-tests-prepare)
7336
add_custom_command(TARGET PUC-Lua-5.1-tests
7437
COMMENT "Running PUC-Rio Lua 5.1 tests"
7538
COMMAND
7639
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.
8440
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
8643
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
8744
)
8845

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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/5845.
3+
4+
# See the rationale in the root CMakeLists.txt.
5+
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
6+
7+
# Build additional C libraries for tests.
8+
macro(BuildTestCLib lib sources)
9+
add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources})
10+
target_include_directories(${lib} PRIVATE
11+
${LUAJIT_SOURCE_DIR}
12+
)
13+
set_target_properties(${lib} PROPERTIES
14+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
15+
PREFIX ""
16+
)
17+
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
18+
set_target_properties(${lib} PROPERTIES
19+
LINK_FLAGS "-undefined dynamic_lookup"
20+
)
21+
endif()
22+
list(APPEND TESTLIBS ${lib})
23+
endmacro()
24+
25+
BuildTestCLib(lib1 lib1.c)
26+
BuildTestCLib(lib11 lib1.c lib11.c)
27+
BuildTestCLib(lib2 lib2.c)
28+
BuildTestCLib(lib21 lib2.c lib21.c)
29+
30+
# TODO: Add the rationale for this (mention the test case it is
31+
# needed for).
32+
set(LIB2ORIG "${CMAKE_CURRENT_BINARY_DIR}/lib2${CMAKE_SHARED_LIBRARY_SUFFIX}")
33+
set(LIB2COPY "${CMAKE_CURRENT_BINARY_DIR}/-lib2${CMAKE_SHARED_LIBRARY_SUFFIX}")
34+
add_custom_command(
35+
OUTPUT ${LIB2COPY}
36+
COMMENT "Copying lib2 to -lib2 for PUC-Rio Lua 5.1 tests"
37+
COMMAND ${CMAKE_COMMAND} -E copy ${LIB2ORIG} ${LIB2COPY}
38+
DEPENDS ${TESTLIBS}
39+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
40+
)
41+
list(APPEND TESTLIBS ${LIB2COPY})
42+
43+
# TODO: Add the comment pointing to README.
44+
add_custom_target(PUC-Lua-5.1-tests-prepare DEPENDS ${TESTLIBS})
45+
add_custom_command(TARGET PUC-Lua-5.1-tests-prepare
46+
COMMENT "Create directory for PUC-Rio Lua 5.1 tests"
47+
COMMAND ${CMAKE_COMMAND} -E make_directory P1
48+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
49+
)
50+
51+
# vim: expandtab tabstop=2 shiftwidth=2

0 commit comments

Comments
 (0)