Skip to content

Commit 7539267

Browse files
authored
Add an option to disable unittest build, & disable them on Docker build (#9677)
1 parent 093e79e commit 7539267

File tree

6 files changed

+19
-2
lines changed

6 files changed

+19
-2
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ set(RUN_IN_PLACE ${DEFAULT_RUN_IN_PLACE} CACHE BOOL
4949

5050
set(BUILD_CLIENT TRUE CACHE BOOL "Build client")
5151
set(BUILD_SERVER FALSE CACHE BOOL "Build server")
52+
set(BUILD_UNITTESTS TRUE CACHE BOOL "Build unittests")
5253

5354

5455
set(WARN_ALL TRUE CACHE BOOL "Enable -Wall for Release build")

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ RUN apk add --no-cache git build-base irrlicht-dev cmake bzip2-dev libpng-dev \
3030
-DCMAKE_INSTALL_PREFIX=/usr/local \
3131
-DCMAKE_BUILD_TYPE=Release \
3232
-DBUILD_SERVER=TRUE \
33+
-DBUILD_UNITTESTS=FALSE \
3334
-DBUILD_CLIENT=FALSE && \
3435
make -j2 && \
3536
make install

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ General options and their default values:
218218

219219
BUILD_CLIENT=TRUE - Build Minetest client
220220
BUILD_SERVER=FALSE - Build Minetest server
221+
BUILD_UNITTESTS=TRUE - Build unittest sources
221222
CMAKE_BUILD_TYPE=Release - Type of build (Release vs. Debug)
222223
Release - Release build
223224
Debug - Debug build

src/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,12 @@ set(common_SRCS
435435
${JTHREAD_SRCS}
436436
${common_SCRIPT_SRCS}
437437
${UTIL_SRCS}
438-
${UNITTEST_SRCS}
439438
)
440439

440+
if(BUILD_UNITTESTS)
441+
set(common_SRCS ${common_SRCS} ${UNITTEST_SRCS})
442+
endif()
443+
441444

442445
# This gives us the icon and file version information
443446
if(WIN32)
@@ -472,8 +475,12 @@ set(client_SRCS
472475
${client_network_SRCS}
473476
${client_irrlicht_changes_SRCS}
474477
${client_SCRIPT_SRCS}
475-
${UNITTEST_CLIENT_SRCS}
476478
)
479+
480+
if(BUILD_UNITTESTS)
481+
set(client_SRCS ${client_SRCS} ${UNITTEST_CLIENT_SRCS})
482+
endif()
483+
477484
list(SORT client_SRCS)
478485

479486
# Server sources

src/cmake_config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@
3434
#cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H
3535
#cmakedefine01 CURSES_HAVE_NCURSESW_NCURSES_H
3636
#cmakedefine01 CURSES_HAVE_NCURSESW_CURSES_H
37+
#cmakedefine01 BUILD_UNITTESTS

src/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,13 @@ int main(int argc, char *argv[])
187187
#ifndef __ANDROID__
188188
// Run unit tests
189189
if (cmd_args.getFlag("run-unittests")) {
190+
#if BUILD_UNITTESTS
190191
return run_tests();
192+
#else
193+
errorstream << "Unittest support is not enabled in this binary. "
194+
<< "If you want to enable it, compile project with BUILD_UNITTESTS=1 flag."
195+
<< std::endl;
196+
#endif
191197
}
192198
#endif
193199

0 commit comments

Comments
 (0)