Skip to content

Commit

Permalink
build/lua: add TEST_BUILD define/tarantool.build flag
Browse files Browse the repository at this point in the history
In the commit 22d507d ("iproto: don't hang on uncancellable iproto
request") we used TEST_BUILD define which is absent, we only have
a CMake build option with such name. Let's add a define too.

While at it let's also show this flag in the `tarantool.build` table.

Follow-up #8423

@TarantoolBot document
Title: new tarantool.build.test_build flag

It is `true` if `TEST_BUILD` build option is set and `false` otherwise.
  • Loading branch information
nshy authored and locker committed Feb 26, 2024
1 parent a12998a commit 94d2813
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ elseif(IS_DIRECTORY .git AND GIT)
)
endif()

option(TEST_BUILD "Abort if memory leak is found." OFF)
option(TEST_BUILD "Use defaults suited for tests" OFF)
set(ABORT_ON_LEAK_DEFAULT ${TEST_BUILD})
option(ABORT_ON_LEAK "Abort if memory leak is found." ${ABORT_ON_LEAK_DEFAULT})

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## feature/box

* Added a new flag `tarantool.build.test_build` that shows whether a build
flag `TEST_BUILD` is set.
9 changes: 9 additions & 0 deletions src/lua/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,15 @@ luaopen_tarantool(lua_State *L)
#endif
lua_settable(L, -3);

/* build.test_build */
lua_pushstring(L, "test_build");
#ifdef TEST_BUILD
lua_pushboolean(L, true);
#else
lua_pushboolean(L, false);
#endif
lua_settable(L, -3);

lua_settable(L, -3); /* box.info.build */

/* debug */
Expand Down
1 change: 1 addition & 0 deletions src/trivia/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
#cmakedefine BUILD_STATIC 1
#cmakedefine EMBED_LUAZLIB 1
#cmakedefine EMBED_LUAZIP 1
#cmakedefine TEST_BUILD 1

/*
* vim: syntax=c
Expand Down
5 changes: 5 additions & 0 deletions test/app-luatest/tarantool_package_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ g.test_build_asan = function()
local asan = b.flags:match('-fsanitize=[%a,]*address') ~= nil
t.assert_equals(b.asan, asan)
end

g.test_build_test_build = function()
local b = tarantool.build
t.assert_equals(type(b.test_build), 'boolean')
end

0 comments on commit 94d2813

Please sign in to comment.