diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2025-03-06 09:32:02 +0100 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2025-03-06 09:32:02 +0100 |
commit | fc160438406458a11921566a4644c7f15d49c244 (patch) | |
tree | ca484f902d836626a45d973235a78cc85bae6e80 | |
parent | dacdd54a805aac286e07582706d8a0e85d1f69a4 (diff) | |
download | lanes-fc160438406458a11921566a4644c7f15d49c244.tar.gz lanes-fc160438406458a11921566a4644c7f15d49c244.tar.bz2 lanes-fc160438406458a11921566a4644c7f15d49c244.zip |
Makefile and code fixes to build the unit tests
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | Shared.mk | 114 | ||||
-rw-r--r-- | deep_test/deep_test.cpp | 34 | ||||
-rw-r--r-- | src/Makefile | 110 | ||||
-rw-r--r-- | unit_tests/Makefile | 31 | ||||
-rw-r--r-- | unit_tests/UnitTests.vcxproj | 1 | ||||
-rw-r--r-- | unit_tests/UnitTests.vcxproj.filters | 6 | ||||
-rw-r--r-- | unit_tests/_pch.hpp | 2 | ||||
-rw-r--r-- | unit_tests/embedded_tests.cpp | 8 | ||||
-rw-r--r-- | unit_tests/init_and_shutdown.cpp | 5 | ||||
-rw-r--r-- | unit_tests/shared.cpp | 4 |
11 files changed, 184 insertions, 140 deletions
@@ -37,14 +37,19 @@ LUA=$(word 1,$(shell which lua5.1$(_LUAEXT)) $(shell which lua51$(_LUAEXT)) $(sh | |||
37 | 37 | ||
38 | _TARGET_SO=$(_TARGET_DIR)/core.$(_SO) | 38 | _TARGET_SO=$(_TARGET_DIR)/core.$(_SO) |
39 | 39 | ||
40 | _UNITTEST_TARGET=$(_TARGET_DIR)/UnitTests$(_LUAEXT) | ||
41 | |||
40 | _PREFIX=LUA_CPATH="./src/?.$(_SO)" LUA_PATH="./src/?.lua;./tests/?.lua" | 42 | _PREFIX=LUA_CPATH="./src/?.$(_SO)" LUA_PATH="./src/?.lua;./tests/?.lua" |
41 | 43 | ||
42 | #--- | 44 | #--- |
43 | all: $(_TARGET_SO) | 45 | all: $(_TARGET_SO) $(_UNITTEST_TARGET) |
44 | 46 | ||
45 | $(_TARGET_SO): src/*.lua src/*.cpp src/*.h src/*.hpp | 47 | $(_TARGET_SO): src/*.lua src/*.cpp src/*.h src/*.hpp |
46 | cd src && $(MAKE) LUA=$(LUA) | 48 | cd src && $(MAKE) LUA=$(LUA) |
47 | 49 | ||
50 | $(_UNITTEST_TARGET): $(_TARGET_SO) | ||
51 | cd unit_tests && $(MAKE) | ||
52 | |||
48 | clean: | 53 | clean: |
49 | cd src && $(MAKE) clean | 54 | cd src && $(MAKE) clean |
50 | 55 | ||
@@ -271,7 +276,7 @@ endif | |||
271 | # 2.0.1: Running this (instant exit of the main Lua state) occasionally | 276 | # 2.0.1: Running this (instant exit of the main Lua state) occasionally |
272 | # segfaults (1:15 or so on OS X PowerPC G4). | 277 | # segfaults (1:15 or so on OS X PowerPC G4). |
273 | # | 278 | # |
274 | require: $(_TARGET_SO) | 279 | require_module: $(_TARGET_SO) |
275 | $(_PREFIX) $(LUA) -e "require '$(MODULE)'" | 280 | $(_PREFIX) $(LUA) -e "require '$(MODULE)'" |
276 | 281 | ||
277 | run: $(_TARGET_SO) | 282 | run: $(_TARGET_SO) |
diff --git a/Shared.mk b/Shared.mk new file mode 100644 index 0000000..56c951c --- /dev/null +++ b/Shared.mk | |||
@@ -0,0 +1,114 @@ | |||
1 | CC= g++ -std=c++20 | ||
2 | |||
3 | # LuaRocks gives 'LIBFLAG' from the outside | ||
4 | # | ||
5 | LIBFLAG=-shared | ||
6 | |||
7 | OPT_FLAGS=-O2 | ||
8 | # -O0 -g | ||
9 | |||
10 | ifeq "$(findstring MINGW,$(shell uname -s))" "MINGW" | ||
11 | # MinGW MSYS on Windows | ||
12 | # | ||
13 | _SO=dll | ||
14 | _LUAEXT=.exe | ||
15 | TIME=timeit.exe | ||
16 | else | ||
17 | _SO=so | ||
18 | _LUAEXT= | ||
19 | endif | ||
20 | |||
21 | ifeq "$(LUAROCKS)" "" | ||
22 | ifeq "$(findstring MINGW,$(shell uname -s))" "MINGW" | ||
23 | # MinGW MSYS on Windows | ||
24 | # | ||
25 | # - 'lua' and 'luac' expected to be on the path | ||
26 | # - %LUA_DEV% must lead to include files and libraries (Lua for Windows >= 5.1.3.14) | ||
27 | # - %MSCVR80% must be the full pathname of 'msvcr80.dll' | ||
28 | # | ||
29 | ifeq "$(LUA_DEV)" "" | ||
30 | $(warning LUA_DEV not defined - try i.e. 'make LUA_DEV=/c/Program\ Files/Lua/5.1') | ||
31 | # this assumes Lua was built and installed from source and everything is located in default folders (/usr/local/include and /usr/local/bin) | ||
32 | LUA_FLAGS:=-I "/usr/local/include" | ||
33 | LUA_LIBS:=$(word 1,$(shell which lua54.$(_SO)) $(shell which lua53.$(_SO)) $(shell which lua52.$(_SO)) $(shell which lua51$(_SO))) | ||
34 | else | ||
35 | LUA_FLAGS:=-I "$(LUA_DEV)/include" | ||
36 | LUA_LIBS:="$(LUA_DEV)/lua5.1.dll" -lgcc | ||
37 | endif | ||
38 | LIBFLAG=-shared -Wl,-Map,lanes.map | ||
39 | else | ||
40 | # Autodetect LUA_FLAGS and/or LUA_LIBS | ||
41 | # | ||
42 | ifneq "$(shell which pkg-config)" "" | ||
43 | ifeq "$(shell pkg-config --exists luajit && echo 1)" "1" | ||
44 | LUA_FLAGS:=$(shell pkg-config --cflags luajit) | ||
45 | LUA_LIBS:=$(shell pkg-config --libs luajit) | ||
46 | # | ||
47 | # Debian: -I/usr/include/luajit-2.0 | ||
48 | # -lluajit-5.1 | ||
49 | else | ||
50 | ifeq "$(shell pkg-config --exists lua5.1 && echo 1)" "1" | ||
51 | LUA_FLAGS:=$(shell pkg-config --cflags lua5.1) | ||
52 | LUA_LIBS:=$(shell pkg-config --libs lua5.1) | ||
53 | # | ||
54 | # Ubuntu: -I/usr/include/lua5.1 | ||
55 | # -llua5.1 | ||
56 | else | ||
57 | ifeq "$(shell pkg-config --exists lua && echo 1)" "1" | ||
58 | LUA_FLAGS:=$(shell pkg-config --cflags lua) | ||
59 | LUA_LIBS:=$(shell pkg-config --libs lua) | ||
60 | # | ||
61 | # OS X fink with pkg-config: | ||
62 | # -I/sw/include | ||
63 | # -L/sw/lib -llua -lm | ||
64 | else | ||
65 | $(warning *** 'pkg-config' existed but did not know of 'lua[5.1]' - Good luck!) | ||
66 | LUA_FLAGS:= | ||
67 | LUA_LIBS:=-llua | ||
68 | endif | ||
69 | endif | ||
70 | endif | ||
71 | else | ||
72 | # No 'pkg-config'; try defaults | ||
73 | # | ||
74 | ifeq "$(shell uname -s)" "Darwin" | ||
75 | $(warning *** Assuming 'fink' at default path) | ||
76 | LUA_FLAGS:=-I/sw/include | ||
77 | LUA_LIBS:=-L/sw/lib -llua | ||
78 | else | ||
79 | $(warning *** Assuming an arbitrary Lua installation; try installing 'pkg-config') | ||
80 | LUA_FLAGS:= | ||
81 | LUA_LIBS:=-llua | ||
82 | endif | ||
83 | endif | ||
84 | endif | ||
85 | |||
86 | ifeq "$(shell uname -s)" "Darwin" | ||
87 | # Some machines need 'MACOSX_DEPLOYMENT_TARGET=10.3' for using '-undefined dynamic_lookup' | ||
88 | # (at least PowerPC running 10.4.11); does not harm the others | ||
89 | # | ||
90 | CC = MACOSX_DEPLOYMENT_TARGET=10.3 gcc | ||
91 | LIBFLAG = -bundle -undefined dynamic_lookup | ||
92 | endif | ||
93 | |||
94 | CFLAGS=-Wall -Werror $(OPT_FLAGS) $(LUA_FLAGS) | ||
95 | LIBS=$(LUA_LIBS) | ||
96 | endif | ||
97 | |||
98 | #--- | ||
99 | # PThread platform specifics | ||
100 | # | ||
101 | ifeq "$(shell uname -s)" "Linux" | ||
102 | # -D_GNU_SOURCE needed for 'pthread_mutexattr_settype' | ||
103 | CFLAGS += -D_GNU_SOURCE -fPIC | ||
104 | |||
105 | # Use of -DUSE_PTHREAD_TIMEDJOIN is possible, but not recommended (slower & keeps threads | ||
106 | # unreleased somewhat longer) | ||
107 | #CFLAGS += -DUSE_PTHREAD_TIMEDJOIN | ||
108 | |||
109 | LIBS += -lpthread | ||
110 | endif | ||
111 | |||
112 | ifeq "$(shell uname -s)" "BSD" | ||
113 | LIBS += -lpthread | ||
114 | endif | ||
diff --git a/deep_test/deep_test.cpp b/deep_test/deep_test.cpp index 46f99d9..cbc33ca 100644 --- a/deep_test/deep_test.cpp +++ b/deep_test/deep_test.cpp | |||
@@ -204,44 +204,44 @@ static int clonable_get(lua_State* const L_) | |||
204 | // ################################################################################################# | 204 | // ################################################################################################# |
205 | 205 | ||
206 | [[nodiscard]] | 206 | [[nodiscard]] |
207 | static int clonable_set(lua_State* L) | 207 | static int clonable_set(lua_State* const L_) |
208 | { | 208 | { |
209 | MyClonableUserdata* self = static_cast<MyClonableUserdata*>(lua_touserdata(L, 1)); | 209 | MyClonableUserdata* _self = static_cast<MyClonableUserdata*>(lua_touserdata(L_, 1)); |
210 | lua_Integer i = lua_tointeger(L, 2); | 210 | lua_Integer i = lua_tointeger(L_, 2); |
211 | self->val = i; | 211 | _self->val = i; |
212 | return 0; | 212 | return 0; |
213 | } | 213 | } |
214 | 214 | ||
215 | // ################################################################################################# | 215 | // ################################################################################################# |
216 | 216 | ||
217 | [[nodiscard]] | 217 | [[nodiscard]] |
218 | static int clonable_setuv(lua_State* L) | 218 | static int clonable_setuv(lua_State* const L_) |
219 | { | 219 | { |
220 | MyClonableUserdata* const _self{ static_cast<MyClonableUserdata*>(lua_touserdata(L, 1)) }; | 220 | [[maybe_unused]] MyClonableUserdata* const _self{ static_cast<MyClonableUserdata*>(lua_touserdata(L_, 1)) }; |
221 | UserValueIndex const _uv{ static_cast<UserValueIndex::type>(luaL_optinteger(L, 2, 1)) }; | 221 | UserValueIndex const _uv{ static_cast<UserValueIndex::type>(luaL_optinteger(L_, 2, 1)) }; |
222 | lua_settop(L, 3); | 222 | lua_settop(L_, 3); |
223 | lua_pushboolean(L, lua_setiuservalue(L, StackIndex{ 1 }, _uv) != 0); | 223 | lua_pushboolean(L_, lua_setiuservalue(L_, StackIndex{ 1 }, _uv) != 0); |
224 | return 1; | 224 | return 1; |
225 | } | 225 | } |
226 | 226 | ||
227 | // ################################################################################################# | 227 | // ################################################################################################# |
228 | 228 | ||
229 | [[nodiscard]] | 229 | [[nodiscard]] |
230 | static int clonable_getuv(lua_State* L) | 230 | static int clonable_getuv(lua_State* const L_) |
231 | { | 231 | { |
232 | MyClonableUserdata* const _self{ static_cast<MyClonableUserdata*>(lua_touserdata(L, 1)) }; | 232 | [[maybe_unused]] MyClonableUserdata* const _self{ static_cast<MyClonableUserdata*>(lua_touserdata(L_, 1)) }; |
233 | UserValueIndex const _uv{ static_cast<UserValueIndex::type>(luaL_optinteger(L, 2, 1)) }; | 233 | UserValueIndex const _uv{ static_cast<UserValueIndex::type>(luaL_optinteger(L_, 2, 1)) }; |
234 | lua_getiuservalue(L, StackIndex{ 1 }, _uv); | 234 | lua_getiuservalue(L_, StackIndex{ 1 }, _uv); |
235 | return 1; | 235 | return 1; |
236 | } | 236 | } |
237 | 237 | ||
238 | // ################################################################################################# | 238 | // ################################################################################################# |
239 | 239 | ||
240 | [[nodiscard]] | 240 | [[nodiscard]] |
241 | static int clonable_tostring(lua_State* L) | 241 | static int clonable_tostring(lua_State* const L_) |
242 | { | 242 | { |
243 | MyClonableUserdata* self = static_cast<MyClonableUserdata*>(lua_touserdata(L, 1)); | 243 | MyClonableUserdata* _self = static_cast<MyClonableUserdata*>(lua_touserdata(L_, 1)); |
244 | luaG_pushstring(L, "%p:clonable(%d)", lua_topointer(L, 1), self->val); | 244 | luaG_pushstring(L_, "%p:clonable(%d)", lua_topointer(L_, 1), _self->val); |
245 | return 1; | 245 | return 1; |
246 | } | 246 | } |
247 | 247 | ||
@@ -250,7 +250,7 @@ static int clonable_tostring(lua_State* L) | |||
250 | [[nodiscard]] | 250 | [[nodiscard]] |
251 | static int clonable_gc(lua_State* const L_) | 251 | static int clonable_gc(lua_State* const L_) |
252 | { | 252 | { |
253 | MyClonableUserdata* self = static_cast<MyClonableUserdata*>(lua_touserdata(L_, 1)); | 253 | [[maybe_unused]] MyClonableUserdata* _self = static_cast<MyClonableUserdata*>(lua_touserdata(L_, 1)); |
254 | if (lua_getiuservalue(L_, kIdxTop, UserValueIndex{ 1 }) == LUA_TFUNCTION) { | 254 | if (lua_getiuservalue(L_, kIdxTop, UserValueIndex{ 1 }) == LUA_TFUNCTION) { |
255 | lua_call(L_, 0, 0); | 255 | lua_call(L_, 0, 0); |
256 | } | 256 | } |
diff --git a/src/Makefile b/src/Makefile index f2e2eb5..262f970 100644 --- a/src/Makefile +++ b/src/Makefile | |||
@@ -5,120 +5,16 @@ | |||
5 | # make LUAROCKS=1 CFLAGS=... LIBFLAG=... LuaRocks automated build | 5 | # make LUAROCKS=1 CFLAGS=... LIBFLAG=... LuaRocks automated build |
6 | # | 6 | # |
7 | 7 | ||
8 | include ../Shared.mk | ||
9 | |||
8 | MODULE=lanes | 10 | MODULE=lanes |
9 | 11 | ||
10 | CC= g++ -std=c++20 | 12 | CC= g++ -std=c++20 |
11 | 13 | ||
12 | SRC=_pch.cpp allocator.cpp cancel.cpp compat.cpp deep.cpp intercopycontext.cpp keeper.cpp lane.cpp lanes.cpp linda.cpp lindafactory.cpp nameof.cpp state.cpp threading.cpp tools.cpp tracker.cpp universe.cpp | 14 | SRC=$(wildcard *.cpp) |
13 | 15 | ||
14 | OBJ=$(SRC:.cpp=.o) | 16 | OBJ=$(SRC:.cpp=.o) |
15 | 17 | ||
16 | # LuaRocks gives 'LIBFLAG' from the outside | ||
17 | # | ||
18 | LIBFLAG=-shared | ||
19 | |||
20 | OPT_FLAGS=-O2 | ||
21 | # -O0 -g | ||
22 | |||
23 | _SO=so | ||
24 | ifeq "$(findstring MINGW,$(shell uname -s))" "MINGW" | ||
25 | _SO=dll | ||
26 | endif | ||
27 | |||
28 | ifeq "$(LUAROCKS)" "" | ||
29 | ifeq "$(findstring MINGW,$(shell uname -s))" "MINGW" | ||
30 | # MinGW MSYS on Windows | ||
31 | # | ||
32 | # - 'lua' and 'luac' expected to be on the path | ||
33 | # - %LUA_DEV% must lead to include files and libraries (Lua for Windows >= 5.1.3.14) | ||
34 | # - %MSCVR80% must be the full pathname of 'msvcr80.dll' | ||
35 | # | ||
36 | ifeq "$(LUA_DEV)" "" | ||
37 | $(warning LUA_DEV not defined - try i.e. 'make LUA_DEV=/c/Program\ Files/Lua/5.1') | ||
38 | # this assumes Lua was built and installed from source and everything is located in default folders (/usr/local/include and /usr/local/bin) | ||
39 | LUA_FLAGS:=-I "/usr/local/include" | ||
40 | LUA_LIBS:=$(word 1,$(shell which lua54.$(_SO)) $(shell which lua53.$(_SO)) $(shell which lua52.$(_SO)) $(shell which lua51$(_SO))) | ||
41 | else | ||
42 | LUA_FLAGS:=-I "$(LUA_DEV)/include" | ||
43 | LUA_LIBS:="$(LUA_DEV)/lua5.1.dll" -lgcc | ||
44 | endif | ||
45 | LIBFLAG=-shared -Wl,-Map,lanes.map | ||
46 | else | ||
47 | # Autodetect LUA_FLAGS and/or LUA_LIBS | ||
48 | # | ||
49 | ifneq "$(shell which pkg-config)" "" | ||
50 | ifeq "$(shell pkg-config --exists luajit && echo 1)" "1" | ||
51 | LUA_FLAGS:=$(shell pkg-config --cflags luajit) | ||
52 | LUA_LIBS:=$(shell pkg-config --libs luajit) | ||
53 | # | ||
54 | # Debian: -I/usr/include/luajit-2.0 | ||
55 | # -lluajit-5.1 | ||
56 | else | ||
57 | ifeq "$(shell pkg-config --exists lua5.1 && echo 1)" "1" | ||
58 | LUA_FLAGS:=$(shell pkg-config --cflags lua5.1) | ||
59 | LUA_LIBS:=$(shell pkg-config --libs lua5.1) | ||
60 | # | ||
61 | # Ubuntu: -I/usr/include/lua5.1 | ||
62 | # -llua5.1 | ||
63 | else | ||
64 | ifeq "$(shell pkg-config --exists lua && echo 1)" "1" | ||
65 | LUA_FLAGS:=$(shell pkg-config --cflags lua) | ||
66 | LUA_LIBS:=$(shell pkg-config --libs lua) | ||
67 | # | ||
68 | # OS X fink with pkg-config: | ||
69 | # -I/sw/include | ||
70 | # -L/sw/lib -llua -lm | ||
71 | else | ||
72 | $(warning *** 'pkg-config' existed but did not know of 'lua[5.1]' - Good luck!) | ||
73 | LUA_FLAGS:= | ||
74 | LUA_LIBS:=-llua | ||
75 | endif | ||
76 | endif | ||
77 | endif | ||
78 | else | ||
79 | # No 'pkg-config'; try defaults | ||
80 | # | ||
81 | ifeq "$(shell uname -s)" "Darwin" | ||
82 | $(warning *** Assuming 'fink' at default path) | ||
83 | LUA_FLAGS:=-I/sw/include | ||
84 | LUA_LIBS:=-L/sw/lib -llua | ||
85 | else | ||
86 | $(warning *** Assuming an arbitrary Lua installation; try installing 'pkg-config') | ||
87 | LUA_FLAGS:= | ||
88 | LUA_LIBS:=-llua | ||
89 | endif | ||
90 | endif | ||
91 | endif | ||
92 | |||
93 | ifeq "$(shell uname -s)" "Darwin" | ||
94 | # Some machines need 'MACOSX_DEPLOYMENT_TARGET=10.3' for using '-undefined dynamic_lookup' | ||
95 | # (at least PowerPC running 10.4.11); does not harm the others | ||
96 | # | ||
97 | CC = MACOSX_DEPLOYMENT_TARGET=10.3 gcc | ||
98 | LIBFLAG = -bundle -undefined dynamic_lookup | ||
99 | endif | ||
100 | |||
101 | CFLAGS=-Wall -Werror $(OPT_FLAGS) $(LUA_FLAGS) | ||
102 | LIBS=$(LUA_LIBS) | ||
103 | endif | ||
104 | |||
105 | #--- | ||
106 | # PThread platform specifics | ||
107 | # | ||
108 | ifeq "$(shell uname -s)" "Linux" | ||
109 | # -D_GNU_SOURCE needed for 'pthread_mutexattr_settype' | ||
110 | CFLAGS += -D_GNU_SOURCE -fPIC | ||
111 | |||
112 | # Use of -DUSE_PTHREAD_TIMEDJOIN is possible, but not recommended (slower & keeps threads | ||
113 | # unreleased somewhat longer) | ||
114 | #CFLAGS += -DUSE_PTHREAD_TIMEDJOIN | ||
115 | |||
116 | LIBS += -lpthread | ||
117 | endif | ||
118 | |||
119 | ifeq "$(shell uname -s)" "BSD" | ||
120 | LIBS += -lpthread | ||
121 | endif | ||
122 | 18 | ||
123 | MODULE_DIR=$(MODULE) | 19 | MODULE_DIR=$(MODULE) |
124 | 20 | ||
diff --git a/unit_tests/Makefile b/unit_tests/Makefile new file mode 100644 index 0000000..9cc192b --- /dev/null +++ b/unit_tests/Makefile | |||
@@ -0,0 +1,31 @@ | |||
1 | # | ||
2 | # Lanes/unit_tests/Makefile | ||
3 | # | ||
4 | |||
5 | include ../Shared.mk | ||
6 | |||
7 | SRC=$(wildcard *.cpp) ../src/deep.cpp ../src/compat.cpp | ||
8 | |||
9 | OBJ=$(SRC:.cpp=.o) | ||
10 | |||
11 | |||
12 | _UNITTEST_TARGET=UnitTests$(_LUAEXT) | ||
13 | |||
14 | #--- | ||
15 | all: $(_UNITTEST_TARGET) | ||
16 | |||
17 | _pch.hpp.gch: _pch.hpp | ||
18 | $(CC) -I "../.." $(CFLAGS) -x c++-header _pch.hpp -o _pch.hpp.gch | ||
19 | |||
20 | %.o: %.cpp _pch.hpp.gch *.h *.hpp Makefile | ||
21 | $(CC) -I "../.." $(CFLAGS) -c $< | ||
22 | |||
23 | # Note: Don't put $(LUA_LIBS) ahead of $^; MSYS will not like that (I think) | ||
24 | # | ||
25 | $(_UNITTEST_TARGET): $(OBJ) | ||
26 | $(CC) $(LIBFLAG) $^ $(LIBS) $(LUA_LIBS) -o $@ | ||
27 | |||
28 | clean: | ||
29 | -rm -rf $(_UNITTEST_TARGET) *.o *.map | ||
30 | |||
31 | .PROXY: all clean | ||
diff --git a/unit_tests/UnitTests.vcxproj b/unit_tests/UnitTests.vcxproj index 5cc3b2f..7cdbafe 100644 --- a/unit_tests/UnitTests.vcxproj +++ b/unit_tests/UnitTests.vcxproj | |||
@@ -345,6 +345,7 @@ | |||
345 | </ItemGroup> | 345 | </ItemGroup> |
346 | <ItemGroup> | 346 | <ItemGroup> |
347 | <None Include="Catch2.runsettings" /> | 347 | <None Include="Catch2.runsettings" /> |
348 | <None Include="Makefile" /> | ||
348 | <None Include="scripts\coro\basics.lua" /> | 349 | <None Include="scripts\coro\basics.lua" /> |
349 | <None Include="scripts\coro\error_handling.lua" /> | 350 | <None Include="scripts\coro\error_handling.lua" /> |
350 | <None Include="scripts\lane\cooperative_shutdown.lua" /> | 351 | <None Include="scripts\lane\cooperative_shutdown.lua" /> |
diff --git a/unit_tests/UnitTests.vcxproj.filters b/unit_tests/UnitTests.vcxproj.filters index 45ae229..c4e85c5 100644 --- a/unit_tests/UnitTests.vcxproj.filters +++ b/unit_tests/UnitTests.vcxproj.filters | |||
@@ -51,6 +51,9 @@ | |||
51 | <Filter Include="Catch2"> | 51 | <Filter Include="Catch2"> |
52 | <UniqueIdentifier>{2e1bf85c-7722-42ba-86f8-ac0f5a494ac5}</UniqueIdentifier> | 52 | <UniqueIdentifier>{2e1bf85c-7722-42ba-86f8-ac0f5a494ac5}</UniqueIdentifier> |
53 | </Filter> | 53 | </Filter> |
54 | <Filter Include="Make"> | ||
55 | <UniqueIdentifier>{c62af5d9-9161-4ca1-9b58-6837e2907e35}</UniqueIdentifier> | ||
56 | </Filter> | ||
54 | </ItemGroup> | 57 | </ItemGroup> |
55 | <ItemGroup> | 58 | <ItemGroup> |
56 | <None Include="scripts\linda\send_receive.lua"> | 59 | <None Include="scripts\linda\send_receive.lua"> |
@@ -107,5 +110,8 @@ | |||
107 | <None Include="Catch2.runsettings"> | 110 | <None Include="Catch2.runsettings"> |
108 | <Filter>Catch2</Filter> | 111 | <Filter>Catch2</Filter> |
109 | </None> | 112 | </None> |
113 | <None Include="Makefile"> | ||
114 | <Filter>Make</Filter> | ||
115 | </None> | ||
110 | </ItemGroup> | 116 | </ItemGroup> |
111 | </Project> \ No newline at end of file | 117 | </Project> \ No newline at end of file |
diff --git a/unit_tests/_pch.hpp b/unit_tests/_pch.hpp index 7fa18a2..1e98c5a 100644 --- a/unit_tests/_pch.hpp +++ b/unit_tests/_pch.hpp | |||
@@ -1,9 +1,11 @@ | |||
1 | #pragma once | 1 | #pragma once |
2 | 2 | ||
3 | #include <atomic> | ||
3 | #include <cassert> | 4 | #include <cassert> |
4 | #include <filesystem> | 5 | #include <filesystem> |
5 | #include <source_location> | 6 | #include <source_location> |
6 | #include <mutex> | 7 | #include <mutex> |
8 | #include <thread> | ||
7 | #include <variant> | 9 | #include <variant> |
8 | 10 | ||
9 | #include "catch_amalgamated.hpp" | 11 | #include "catch_amalgamated.hpp" |
diff --git a/unit_tests/embedded_tests.cpp b/unit_tests/embedded_tests.cpp index bf2dd6e..1a63721 100644 --- a/unit_tests/embedded_tests.cpp +++ b/unit_tests/embedded_tests.cpp | |||
@@ -60,14 +60,6 @@ TEST_CASE("lanes.embedding") | |||
60 | lua_pop(S, 1); | 60 | lua_pop(S, 1); |
61 | S.stackCheck(0); | 61 | S.stackCheck(0); |
62 | 62 | ||
63 | auto load_lanes_lua = +[](lua_State* const L_) { | ||
64 | if (0 == luaL_dofile(L_, "lanes.lua")) { | ||
65 | return 1; | ||
66 | } else { | ||
67 | return 0; | ||
68 | } | ||
69 | }; | ||
70 | |||
71 | _p_luaopen_lanes_embedded(S, local::load_lanes_lua); // S: lanes | 63 | _p_luaopen_lanes_embedded(S, local::load_lanes_lua); // S: lanes |
72 | lua_pop(S, 1); | 64 | lua_pop(S, 1); |
73 | S.stackCheck(0); | 65 | S.stackCheck(0); |
diff --git a/unit_tests/init_and_shutdown.cpp b/unit_tests/init_and_shutdown.cpp index 78c472f..147a742 100644 --- a/unit_tests/init_and_shutdown.cpp +++ b/unit_tests/init_and_shutdown.cpp | |||
@@ -756,11 +756,6 @@ TEST_CASE("lanes.on_state_create setting") | |||
756 | LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; | 756 | LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; |
757 | 757 | ||
758 | local::OnStateCreateCallsCount.store(0, std::memory_order_relaxed); | 758 | local::OnStateCreateCallsCount.store(0, std::memory_order_relaxed); |
759 | auto on_state_create = +[](lua_State* const L_) { | ||
760 | local::OnStateCreateCallsCount.fetch_add(1, std::memory_order_relaxed); | ||
761 | return 0; | ||
762 | }; | ||
763 | |||
764 | 759 | ||
765 | SECTION("on_state_create called in Keeper states") | 760 | SECTION("on_state_create called in Keeper states") |
766 | { | 761 | { |
diff --git a/unit_tests/shared.cpp b/unit_tests/shared.cpp index 73aeadd..023e917 100644 --- a/unit_tests/shared.cpp +++ b/unit_tests/shared.cpp | |||
@@ -101,7 +101,9 @@ namespace | |||
101 | TEST_CASE("lanes.stack checker") | 101 | TEST_CASE("lanes.stack checker") |
102 | { | 102 | { |
103 | LuaState _L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; | 103 | LuaState _L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; |
104 | #if HAVE_LUA_ASSERT() | ||
104 | StackChecker::CallsCassert = false; | 105 | StackChecker::CallsCassert = false; |
106 | #endif // HAVE_LUA_ASSERT() | ||
105 | 107 | ||
106 | auto _doStackCheckerTest = [&_L](lua_CFunction const _f, LuaError const _expected) { | 108 | auto _doStackCheckerTest = [&_L](lua_CFunction const _f, LuaError const _expected) { |
107 | lua_pushcfunction(_L, _f); | 109 | lua_pushcfunction(_L, _f); |
@@ -223,7 +225,7 @@ std::string_view LuaState::doStringAndRet(std::string_view const& str_) const | |||
223 | STACK_CHECK(L, 1); // the error message is on the stack | 225 | STACK_CHECK(L, 1); // the error message is on the stack |
224 | return ""; | 226 | return ""; |
225 | } | 227 | } |
226 | LuaError const _callErr{ lua_pcall(L, 0, 1, 0) }; // L: "<msg>"?|retstring | 228 | [[maybe_unused]] LuaError const _callErr{ lua_pcall(L, 0, 1, 0) }; // L: "<msg>"?|retstring |
227 | STACK_CHECK(L, 1); | 229 | STACK_CHECK(L, 1); |
228 | return luaG_tostring(L, kIdxTop); | 230 | return luaG_tostring(L, kIdxTop); |
229 | } | 231 | } |