Skip to content

Commit

Permalink
Add an option to disable unittest build, & disable them on Docker bui…
Browse files Browse the repository at this point in the history
…ld (#9677)
  • Loading branch information
nerzhul committed Apr 16, 2020
1 parent 093e79e commit 7539267
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -49,6 +49,7 @@ set(RUN_IN_PLACE ${DEFAULT_RUN_IN_PLACE} CACHE BOOL

set(BUILD_CLIENT TRUE CACHE BOOL "Build client")
set(BUILD_SERVER FALSE CACHE BOOL "Build server")
set(BUILD_UNITTESTS TRUE CACHE BOOL "Build unittests")


set(WARN_ALL TRUE CACHE BOOL "Enable -Wall for Release build")
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Expand Up @@ -30,6 +30,7 @@ RUN apk add --no-cache git build-base irrlicht-dev cmake bzip2-dev libpng-dev \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SERVER=TRUE \
-DBUILD_UNITTESTS=FALSE \
-DBUILD_CLIENT=FALSE && \
make -j2 && \
make install
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -218,6 +218,7 @@ General options and their default values:

BUILD_CLIENT=TRUE - Build Minetest client
BUILD_SERVER=FALSE - Build Minetest server
BUILD_UNITTESTS=TRUE - Build unittest sources
CMAKE_BUILD_TYPE=Release - Type of build (Release vs. Debug)
Release - Release build
Debug - Debug build
Expand Down
11 changes: 9 additions & 2 deletions src/CMakeLists.txt
Expand Up @@ -435,9 +435,12 @@ set(common_SRCS
${JTHREAD_SRCS}
${common_SCRIPT_SRCS}
${UTIL_SRCS}
${UNITTEST_SRCS}
)

if(BUILD_UNITTESTS)
set(common_SRCS ${common_SRCS} ${UNITTEST_SRCS})
endif()


# This gives us the icon and file version information
if(WIN32)
Expand Down Expand Up @@ -472,8 +475,12 @@ set(client_SRCS
${client_network_SRCS}
${client_irrlicht_changes_SRCS}
${client_SCRIPT_SRCS}
${UNITTEST_CLIENT_SRCS}
)

if(BUILD_UNITTESTS)
set(client_SRCS ${client_SRCS} ${UNITTEST_CLIENT_SRCS})
endif()

list(SORT client_SRCS)

# Server sources
Expand Down
1 change: 1 addition & 0 deletions src/cmake_config.h.in
Expand Up @@ -34,3 +34,4 @@
#cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H
#cmakedefine01 CURSES_HAVE_NCURSESW_NCURSES_H
#cmakedefine01 CURSES_HAVE_NCURSESW_CURSES_H
#cmakedefine01 BUILD_UNITTESTS
6 changes: 6 additions & 0 deletions src/main.cpp
Expand Up @@ -187,7 +187,13 @@ int main(int argc, char *argv[])
#ifndef __ANDROID__
// Run unit tests
if (cmd_args.getFlag("run-unittests")) {
#if BUILD_UNITTESTS
return run_tests();
#else
errorstream << "Unittest support is not enabled in this binary. "
<< "If you want to enable it, compile project with BUILD_UNITTESTS=1 flag."
<< std::endl;
#endif
}
#endif

Expand Down

0 comments on commit 7539267

Please sign in to comment.